Example usage for org.springframework.web.servlet.view.xslt XsltView setUrl

List of usage examples for org.springframework.web.servlet.view.xslt XsltView setUrl

Introduction

In this page you can find the example usage for org.springframework.web.servlet.view.xslt XsltView setUrl.

Prototype

public void setUrl(@Nullable String url) 

Source Link

Document

Set the URL of the resource that this view wraps.

Usage

From source file:org.jasig.portlet.proxy.mvc.portlet.xslt.XsltPortletController.java

@RequestMapping
public ModelAndView showContent(PortletRequest request) {
    final ModelAndView mv = new ModelAndView();

    final PortletPreferences preferences = request.getPreferences();

    // locate the content service to use to retrieve our XML
    final String contentServiceKey = preferences.getValue(CONTENT_SERVICE_KEY, null);
    final IContentService contentService = applicationContext.getBean(contentServiceKey, IContentService.class);
    final IContentRequest proxyRequest = contentService.getRequest(request);

    // retrieve the XML content
    final IContentResponse proxyResponse = contentService.getContent(proxyRequest, request);
    try {//from w  w  w .  j  a va 2  s.  c  om
        mv.addObject("xml", proxyResponse.getContent());
    } finally {
        proxyResponse.close();
    }

    // set the appropriate view name
    final String mainXslt = preferences.getValue(MAIN_XSLT_KEY, null);
    final String mobileXslt = preferences.getValue(MOBILE_XSLT_KEY, null);
    final String xslt;
    if (mobileXslt != null) {
        final boolean isMobile = viewSelector.isMobile(request);
        xslt = isMobile ? mobileXslt : mainXslt;
    } else {
        xslt = mainXslt;
    }

    // create an XSLT view using the configured source
    final XsltView view = new XsltView();
    view.setUrl(xslt);
    view.setSourceKey("xml");
    view.setApplicationContext(this.applicationContext);
    mv.setView(view);

    return mv;
}