@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { _log.info("render()"); try { TaskRecord taskRecord = ActionUtil.getTaskRecord(renderRequest); renderRequest.setAttribute(TimetrackerWebKeys.TASK_RECORD, taskRecord); } catch (Exception e) { if (e instanceof NoSuchTaskRecordException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/error.jsp"; } else { throw new PortletException(e); } } return getPath(); }
/** * Routes between global configuration editing and tab editing * * @param request The request * @param response The response * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @Override protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException { // Very, very simple routing. That's all we need, folks. String editModeParam = ParamUtil.get(request, PortletRequestParameter.EDIT_MODE.getName(), StringPool.BLANK); EditMode editMode = EditMode.getEditMode(editModeParam); switch(editMode) { case TAB: this.doEditTab(request, response); break; case FACET: this.doEditFacet(request, response); break; default: this.doEditGlobal(request, response); break; } }
/** * Renders an ADT. * * @param request the request * @param response the response * @param templateCtx the template context * @param templateUUID the UUID of the ADT (DDMTemplate object/table) to render * @throws TemplateNotFoundException if no template having such UUID could be found * @throws CouldNotRenderTemplateException if the template could not be rendered */ public void renderADT(RenderRequest request, RenderResponse response, Map<String, Object> templateCtx, String templateUUID) throws CouldNotRenderTemplateException, TemplateNotFoundException { HttpServletRequest httpServletRequest = this.portal.getHttpServletRequest(request); HttpServletResponse httpServletResponse = this.portal.getHttpServletResponse(response); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long companyId = themeDisplay.getCompanyId(); try { List<DDMTemplate> ddmTemplates = this.getDDMTemplateLocalService().getDDMTemplatesByUuidAndCompanyId(templateUUID, companyId); if (ddmTemplates.isEmpty()) { throw new TemplateNotFoundException("No ADT found with companyId ["+companyId+"] and UUID ["+templateUUID+"]"); } String renderedTemplate = this.getPortletDisplayTemplate().renderDDMTemplate(httpServletRequest, httpServletResponse, ddmTemplates.get(0), Collections.emptyList(), templateCtx); response.getWriter().write(renderedTemplate); } catch (Exception e) { throw new CouldNotRenderTemplateException("Could not render from ADT [" + templateUUID + "]", e); } }
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { _log.info("render()"); try { Contact contact = ActionUtil.getContact(renderRequest); renderRequest.setAttribute(ContactManagerWebKeys.CONTACT, contact); } catch (Exception e) { if (e instanceof NoSuchContactException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/error.jsp"; } else { throw new PortletException(e); } } return getPath(); }
private void renderFromMobilink( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { renderFrontendWebEmployeePortlet(renderRequest, renderResponse); renderFrontendWebJobposPortlet(renderRequest, renderResponse); renderFrontendWebAdminPortlet(renderRequest, renderResponse); renderFrontendWebWorkingUnitPortlet(renderRequest, renderResponse); renderFrontendWebNotificationPortlet(renderRequest, renderResponse); renderRequest.setAttribute( "url", generateURLCommon(renderRequest, renderResponse)); renderRequest.setAttribute("constants", generalConstantsCommon(renderRequest)); renderRequest.setAttribute("param", generalParamsCommon(renderRequest)); }
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { // Get Mode String mode = ParamUtil.getString( renderRequest, LDFPortletKeys.MODE, LDFPortletKeys.MODE_ORGANIZAION); // Carry around mode renderRequest.setAttribute(LDFPortletKeys.MODE, mode); if(_log.isDebugEnabled()) { _log.debug("mode <" + mode + ">"); _log.debug("jsp <" + _commonUtil .getPageFromMode() .getOrDefault(mode, LDFPortletKeys.JSP_ORGANIZAION) + ">"); } return _commonUtil .getPageFromMode() .getOrDefault(mode, LDFPortletKeys.JSP_ORGANIZAION); }
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { _log.info("render()"); try { Measurement measurement = ActionUtil.getMeasurement(renderRequest); renderRequest.setAttribute(DataManagerWebKeys.MEASUREMENT, measurement); } catch (Exception e) { if (e instanceof NoSuchMeasurementException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/error.jsp"; } else { throw new PortletException(e); } } return getPath(); }
@SuppressWarnings("unchecked") public static List<String> generateCSVOutput( PortletConfig portletConfig, RenderRequest renderRequest) { String title = (String) renderRequest.getAttribute("title"); EnumSet<ExecutionMode> executionMode = (EnumSet<ExecutionMode>)renderRequest.getAttribute("executionMode"); Map<Company, Long> companyProcessTime = (Map<Company, Long>)renderRequest.getAttribute( "companyProcessTime"); Map<Company, Map<Long, List<Comparison>>> companyResultDataMap = (Map<Company, Map<Long, List<Comparison>>>) renderRequest.getAttribute("companyResultDataMap"); Map<Company, String> companyError = (Map<Company, String>) renderRequest.getAttribute("companyError"); if ((executionMode == null)||(companyProcessTime == null)|| (companyResultDataMap == null)) { return null; } return generateCSVOutput( portletConfig, title, renderRequest.getLocale(), true, companyProcessTime, companyResultDataMap, companyError); }
private String determineDefaultPhase(Method handlerMethod) { if (void.class != handlerMethod.getReturnType()) { return PortletRequest.RENDER_PHASE; } for (Class<?> argType : handlerMethod.getParameterTypes()) { if (ActionRequest.class.isAssignableFrom(argType) || ActionResponse.class.isAssignableFrom(argType) || InputStream.class.isAssignableFrom(argType) || Reader.class.isAssignableFrom(argType)) { return PortletRequest.ACTION_PHASE; } else if (RenderRequest.class.isAssignableFrom(argType) || RenderResponse.class.isAssignableFrom(argType) || OutputStream.class.isAssignableFrom(argType) || Writer.class.isAssignableFrom(argType)) { return PortletRequest.RENDER_PHASE; } else if (ResourceRequest.class.isAssignableFrom(argType) || ResourceResponse.class.isAssignableFrom(argType)) { return PortletRequest.RESOURCE_PHASE; } else if (EventRequest.class.isAssignableFrom(argType) || EventResponse.class.isAssignableFrom(argType)) { return PortletRequest.EVENT_PHASE; } } return ""; }
@Override public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception { // If the portlet is minimized and we don't want to render then return null. if (WindowState.MINIMIZED.equals(request.getWindowState()) && !this.renderWhenMinimized) { return null; } // Delegate to PortletContentGenerator for checking and preparing. checkAndPrepare(request, response); // Execute in synchronized block if required. if (this.synchronizeOnSession) { PortletSession session = request.getPortletSession(false); if (session != null) { Object mutex = PortletUtils.getSessionMutex(session); synchronized (mutex) { return handleRenderRequestInternal(request, response); } } } return handleRenderRequestInternal(request, response); }
/** * Determine an error ModelAndView via the registered HandlerExceptionResolvers. * @param request current portlet request * @param response current portlet response * @param handler the executed handler, or null if none chosen at the time of * the exception (for example, if multipart resolution failed) * @param ex the exception that got thrown during handler execution * @return a corresponding ModelAndView to forward to * @throws Exception if no error ModelAndView found */ protected ModelAndView processHandlerException( RenderRequest request, RenderResponse response, Object handler, Exception ex) throws Exception { ModelAndView exMv = null; for (Iterator<HandlerExceptionResolver> it = this.handlerExceptionResolvers.iterator(); exMv == null && it.hasNext();) { HandlerExceptionResolver resolver = it.next(); exMv = resolver.resolveException(request, response, handler, ex); } if (exMv != null) { if (logger.isDebugEnabled()) { logger.debug("HandlerExceptionResolver returned ModelAndView [" + exMv + "] for exception"); } logger.warn("Handler execution resulted in exception - forwarding to resolved error view", ex); return exMv; } else { throw ex; } }
/** * Trigger afterCompletion callbacks on the mapped HandlerInterceptors. * Will just invoke afterCompletion for all interceptors whose preHandle * invocation has successfully completed and returned true. * @param mappedHandler the mapped HandlerExecutionChain * @param interceptorIndex index of last interceptor that successfully completed * @param ex Exception thrown on handler execution, or null if none * @see HandlerInterceptor#afterRenderCompletion */ private void triggerAfterRenderCompletion(HandlerExecutionChain mappedHandler, int interceptorIndex, RenderRequest request, RenderResponse response, Exception ex) throws Exception { // Apply afterCompletion methods of registered interceptors. if (mappedHandler != null) { HandlerInterceptor[] interceptors = mappedHandler.getInterceptors(); if (interceptors != null) { for (int i = interceptorIndex; i >= 0; i--) { HandlerInterceptor interceptor = interceptors[i]; try { interceptor.afterRenderCompletion(request, response, mappedHandler.getHandler(), ex); } catch (Throwable ex2) { logger.error("HandlerInterceptor.afterCompletion threw exception", ex2); } } } } }
@Test public void testNativeRequest() { MockRenderRequest portletRequest = new MockRenderRequest(); MockRenderResponse portletResponse = new MockRenderResponse(); PortletWebRequest request = new PortletWebRequest(portletRequest, portletResponse); assertSame(portletRequest, request.getNativeRequest()); assertSame(portletRequest, request.getNativeRequest(PortletRequest.class)); assertSame(portletRequest, request.getNativeRequest(RenderRequest.class)); assertSame(portletRequest, request.getNativeRequest(MockRenderRequest.class)); assertNull(request.getNativeRequest(MultipartRequest.class)); assertSame(portletResponse, request.getNativeResponse()); assertSame(portletResponse, request.getNativeResponse(PortletResponse.class)); assertSame(portletResponse, request.getNativeResponse(RenderResponse.class)); assertSame(portletResponse, request.getNativeResponse(MockRenderResponse.class)); assertNull(request.getNativeResponse(MultipartRequest.class)); }
@Test public void testDecoratedNativeRequest() { MockRenderRequest portletRequest = new MockRenderRequest(); MockRenderResponse portletResponse = new MockRenderResponse(); PortletRequest decoratedRequest = new PortletRequestWrapper(portletRequest); PortletResponse decoratedResponse = new PortletResponseWrapper(portletResponse); PortletWebRequest request = new PortletWebRequest(decoratedRequest, decoratedResponse); assertSame(decoratedRequest, request.getNativeRequest()); assertSame(decoratedRequest, request.getNativeRequest(PortletRequest.class)); assertSame(portletRequest, request.getNativeRequest(RenderRequest.class)); assertSame(portletRequest, request.getNativeRequest(MockRenderRequest.class)); assertNull(request.getNativeRequest(MultipartRequest.class)); assertSame(decoratedResponse, request.getNativeResponse()); assertSame(decoratedResponse, request.getNativeResponse(PortletResponse.class)); assertSame(portletResponse, request.getNativeResponse(RenderResponse.class)); assertSame(portletResponse, request.getNativeResponse(MockRenderResponse.class)); assertNull(request.getNativeResponse(MultipartRequest.class)); }
/** * Routes between search results and single asset view * * @param request The request * @param response The response * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @Override protected void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException { String viewModeParam = ParamUtil.getString(request, PortletRequestParameter.VIEW_MODE.getName(), StringPool.BLANK); ViewMode viewMode = ViewMode.getViewMode(viewModeParam); switch(viewMode) { case VIEW_JOURNAL: this.doViewJournal(request, response); break; default: this.doViewResults(request, response); break; } }
@Override protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException { String lang = request.getLocale().getLanguage(); String templatePath; if(HELP_TEMPLATES.containsKey(lang)) { templatePath = HELP_TEMPLATES.get(lang); } else { templatePath = HELP_TEMPLATES.get(StringPool.BLANK); } Map<String, Object> ctx = Collections.singletonMap("ns", response.getNamespace()); this.renderTemplate(request, response, ctx, templatePath); }
/** * Renders the given template * * @param request The request * @param response The response * @param ctx The template context * @param templatePath The path of the template, relative to the templates path given in the init parameters * * @throws PortletException Thrown if there is an error during template processing * @throws IOException Thrown if there is an error while writing the response */ public void renderTemplate(RenderRequest request, RenderResponse response, Map<String, Object> ctx, String templatePath) throws PortletException, IOException { PortletContext portletCtx = this.getPortletContext(); String templateResourcePath = String.format(TEMPLATE_PATH_FORMAT, portletCtx.getPortletContextName(), this.templatesPath, templatePath); if(this.templateResourceLoader.hasTemplateResource(templateResourcePath)) { try { this.writeTemplate(request, response, ctx, templateResourcePath); } catch(TemplateException e) { throw new PortletException(e); } } else { throw new TemplateNotFoundException(templateResourcePath); } }
/** * Writes the template's rendering in the portlet response * * @param request The request * @param response The response * @param ctx The template context * @param templateResourcePath The template to write * * @throws IOException Thrown if something goes wrong when writing the response * @throws TemplateException Thrown if something goes wrong when processing the template */ private void writeTemplate(RenderRequest request, RenderResponse response, Map<String, Object> ctx, String templateResourcePath) throws TemplateException, IOException { TemplateResource templateResource = this.templateResourceLoader.getTemplateResource(templateResourcePath); Template template = this.templateManager.getTemplate(templateResource, false); this.templateManager.addTaglibSupport(template, this.portal.getHttpServletRequest(request), this.portal.getHttpServletResponse(response)); this.enrichTemplateContext(request, response, template); Set<Entry<String, Object>> contextObjects = ctx.entrySet(); for(Entry<String, Object> obj : contextObjects) { template.put(obj.getKey(), obj.getValue()); } template.processTemplate(response.getWriter()); }
/** * Puts commonly used variables in the template context * @param request The request * @param response The response * @param template The template */ private void enrichTemplateContext(RenderRequest request, RenderResponse response, Template template) { template.put(TemplateVariable.LOCALE.getVariableName(), request.getLocale()); template.put(TemplateVariable.PORTLET_CONTEXT.getVariableName(), this.getPortletContext()); template.put(TemplateVariable.REQUEST.getVariableName(), request); template.put(TemplateVariable.RESPONSE.getVariableName(), response); template.put(TemplateVariable.THEME_DISPLAY.getVariableName(), request.getAttribute(WebKeys.THEME_DISPLAY)); template.put(TemplateVariable.USER_INFO.getVariableName(), request.getAttribute(PortletRequest.USER_INFO)); }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL dossierInfoURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); dossierInfoURL.setPortletMode(PortletMode.VIEW); dossierInfoURL.setWindowState(LiferayWindowState.EXCLUSIVE); dossierInfoURL.setParameter( "mvcPath", "/templates/lookup_dossier/dossierinfo.ftl"); urlObject.put("dossierinfo", dossierInfoURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL registerResultURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); registerResultURL.setPortletMode(PortletMode.VIEW); registerResultURL.setWindowState(LiferayWindowState.EXCLUSIVE); registerResultURL.setParameter( "mvcPath", "/templates/applicant/register_result.ftl"); urlObject.put("register_result", registerResultURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL confirmPasswordURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); confirmPasswordURL.setPortletMode(PortletMode.VIEW); confirmPasswordURL.setWindowState(LiferayWindowState.EXCLUSIVE); confirmPasswordURL.setParameter( "mvcPath", "/templates/applicant/confirm_password.ftl"); urlObject.put("confirm_password", confirmPasswordURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL serviceInfoLookupURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); serviceInfoLookupURL.setPortletMode(PortletMode.VIEW); serviceInfoLookupURL.setWindowState(LiferayWindowState.EXCLUSIVE); serviceInfoLookupURL.setParameter( "mvcPath", "/templates/homepage/serviceinfo_lookup.ftl"); urlObject.put("serviceinfo_lookup", serviceInfoLookupURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL dossierLookupURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); dossierLookupURL.setPortletMode(PortletMode.VIEW); dossierLookupURL.setWindowState(LiferayWindowState.EXCLUSIVE); dossierLookupURL.setParameter( "mvcPath", "/templates/homepage/dossier_lookup.ftl"); urlObject.put("dossier_lookup", dossierLookupURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL dossierLookupURL = PortletURLFactoryUtil.create(renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); dossierLookupURL.setPortletMode(PortletMode.VIEW); dossierLookupURL.setWindowState(LiferayWindowState.EXCLUSIVE); dossierLookupURL.setParameter("mvcPath", "/templates/homepage/search_serviceinfo.ftl"); urlObject.put("dossier_lookup", dossierLookupURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put("portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL dossierLookupURL = PortletURLFactoryUtil.create(renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); dossierLookupURL.setPortletMode(PortletMode.VIEW); dossierLookupURL.setWindowState(LiferayWindowState.EXCLUSIVE); dossierLookupURL.setParameter("mvcPath", "/templates/homepage/dossier_lookup.ftl"); urlObject.put("dossier_lookup", dossierLookupURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put("portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override protected void doView( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PrintWriter printWriter = renderResponse.getWriter(); printWriter.print("opencps-lang Portlet - Hello World!"); }
protected String getCurrentFriendlyURL(RenderRequest renderRequest) { String url = _portal.getCurrentURL(renderRequest); if (url.length() > 0 && url.indexOf("?") > 0) { url = url.split("\\?")[0]; } return url; }
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { renderRequest.setAttribute(DummyFactoryConfiguration.class.getName(), _dummyFactoryConfiguration); super.doView(renderRequest, renderResponse); }
@Override protected void doDispatch( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { renderRequest.setAttribute(DummyFactoryConfiguration.class.getName(), _dummyFactoryConfiguration); super.doDispatch(renderRequest, renderResponse); }
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { response.setContentType("text/html"); PrintWriter writer = response.getWriter(); String user = request.getParameter("user"); writer.println("<h1>Hello "+user+"!</h1>"); }
private ResponseWrapper fetchContentFromCacheIfAvailable(final RenderRequest req, final String serviceUrl) { ResponseWrapper rslt = null; // default final List<CacheTuple> cacheKeysToTry = new ArrayList<>(); // Don't use private-scope caching for anonymous users if (req.getRemoteUser() != null) { cacheKeysToTry.add( // Private-scope cache key new CacheTuple(serviceUrl, req.getPortletMode().toString(), req.getWindowState().toString(), req.getRemoteUser()) ); } cacheKeysToTry.add( // Public-scope cache key new CacheTuple(serviceUrl, req.getPortletMode().toString(), req.getWindowState().toString()) ); for (CacheTuple key : cacheKeysToTry) { final Element cacheElement = this.responseCache.get(key); if (cacheElement != null) { rslt = (ResponseWrapper) cacheElement.getObjectValue(); break; } } return rslt; }
@Override public void doFilter( RenderRequest request, RenderResponse response, FilterChain chain) throws IOException, PortletException { System.out.println("Before filter"); request.setAttribute("CUSTOM_ATTRIBUTE", "My Custom Attribute Value"); chain.doFilter(request, response); System.out.println("After filter"); }
@RequestMapping public ModelAndView renderFormFirst(RenderRequest request) { ModelAndView modelAndView = new ModelAndView("login"); LoginForm loginForm = new LoginForm(); references(modelAndView); modelAndView.addObject("loginForm", loginForm); return modelAndView; }
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { // Inject configuration into render request. renderRequest.setAttribute(HystrixDemoConfiguration.class.getName(), _configuration); super.doView(renderRequest, renderResponse); }
@Override public void doView( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { if (_log.isDebugEnabled()) { _log.debug("Blade Message Portlet render"); } renderRequest.setAttribute( MessageDisplayConfiguration.class.getName(), _messageDisplayConfiguration); super.doView(renderRequest, renderResponse); }
/** * Return a ModelAndView object with the specified view name. */ @Override protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception { return new ModelAndView(getViewName()); }
/** * Point at which the JWT expires */ protected final Date getExpiration(RenderRequest renderRequest) { // Expiration of the JWT final PortletSession portletSession = renderRequest.getPortletSession(); final Date rslt = new Date( portletSession.getLastAccessedTime() + ((long) portletSession.getMaxInactiveInterval() * 1000L) ); return rslt; }
/** * This implementation delegates to {@link #afterCompletion}. */ @Override public void afterRenderCompletion( RenderRequest request, RenderResponse response, Object handler, Exception ex) throws Exception { afterCompletion(request, response, handler, ex); }