Search in sources :

Example 1 with PortletWebRequest

use of org.springframework.web.portlet.context.PortletWebRequest in project uPortal by Jasig.

the class ImagePortletController method handleRenderRequestInternal.

@Override
protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception {
    final Map<String, Object> model = new HashMap<String, Object>();
    final PortletPreferences preferences = request.getPreferences();
    final PortletWebRequest webRequest = new PortletWebRequest(request);
    // retrieve configuration information about the image from the portlet
    // preferences
    model.put("uri", getPreference("img-uri", webRequest, preferences));
    model.put("width", getPreference("img-width", webRequest, preferences));
    model.put("height", getPreference("img-height", webRequest, preferences));
    model.put("border", getPreference("img-border", webRequest, preferences));
    model.put("link", getPreference("img-link", webRequest, preferences));
    model.put("caption", getPreference("caption", webRequest, preferences));
    model.put("subcaption", getPreference("subcaption", webRequest, preferences));
    model.put("alt", getPreference("alt-text", webRequest, preferences));
    return new ModelAndView("/jsp/Image/imagePortlet", model);
}
Also used : PortletWebRequest(org.springframework.web.portlet.context.PortletWebRequest) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.portlet.ModelAndView) PortletPreferences(javax.portlet.PortletPreferences)

Example 2 with PortletWebRequest

use of org.springframework.web.portlet.context.PortletWebRequest in project uPortal by Jasig.

the class PortletSpELServiceImpl method getEvaluationContext.

/**
 * Return a SpEL evaluation context for the supplied portlet request.
 *
 * @param request PortletRequest
 * @return SpEL evaluation context for the supplied portlet request
 */
protected EvaluationContext getEvaluationContext(PortletRequest request) {
    Map<String, String> userInfo = (Map<String, String>) request.getAttribute(PortletRequest.USER_INFO);
    final SpELEnvironmentRoot root = new SpELEnvironmentRoot(new PortletWebRequest(request), userInfo);
    final StandardEvaluationContext context = new StandardEvaluationContext(root);
    // Allows for @myBeanName replacements
    context.setBeanResolver(this.beanResolver);
    return context;
}
Also used : PortletWebRequest(org.springframework.web.portlet.context.PortletWebRequest) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) Map(java.util.Map)

Aggregations

PortletWebRequest (org.springframework.web.portlet.context.PortletWebRequest)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 PortletPreferences (javax.portlet.PortletPreferences)1 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)1 ModelAndView (org.springframework.web.portlet.ModelAndView)1