ModelAndView alternatives

LabKey Support Forum (Inactive)
ModelAndView alternatives wnels2  2008-04-03 09:59
Status: Closed
 
I need to return a success or failure message back to a submitted gwt form. I would like to return plain/text with key words in the content. I don't know how to do this with out it getting inserted into Labey template. What is the most direct way to do this?

Thanks,
Bill
 
 
Matthew Bellew responded:  2008-04-03 10:06
If you don't want to use the default template you can specify which template to use with getPageConfig().setTemplate().

In your case you want

    getPageConfig().setTemplate(PageConfig.Template.None);
 
wnels2 responded:  2008-04-03 14:39
Thanks,
That worked. Do you know how to remove the jsp formating? I tryed the jsp below with and without the
<%@ page contentType="text/plain" %> but my text gets wrapped in <DIV> tags.

<%@ page import="org.labkey.ms2.pipeline.PipelineController.SearchFormResponseView.ResponseBean" %>
<%@ page import="org.labkey.api.view.HttpView" %>
<%@ page extends="org.labkey.api.jsp.JspBase" %>
<%
    HttpView<ResponseBean> me = (HttpView<ResponseBean>) HttpView.currentView();
    ResponseBean bean = me.getModelBean();
%>
<%@ page contentType="text/plain" %>
<%=bean.reply%>

Thanks,
Bill
 
jeckels responded:  2008-04-03 15:14
Hi Bill,

To avoid any extra formatting, you might want to try rendering your view within your action instead of returning a ModelAndView. Inside your action, you could call view.render(getViewContext().getRequest(), getViewContext().getResponse()); Then, return null from the action. This should prevent the framework from wrapping you in any other tags.

Josh
 
adam responded:  2008-04-03 15:21
You should be able to get rid of the <DIV> by setting the view's frametype to NONE:

    v.setFrame(WebPartView.FrameType.NONE);

But I agree that avoiding JSPs in this case is a good idea.
 
Matthew Bellew responded:  2008-04-03 18:57
Also see org.labkey.api.view.HtmlView
 
wnels2 responded:  2008-04-07 06:29
Thanks for all of the feedback!
I ended up using the getViewContext().getResponse()) method.
Bill