org.springframework.web.portlet.bind.annotation.RenderMapping Java Examples
The following examples show how to use
org.springframework.web.portlet.bind.annotation.RenderMapping.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@RequestMapping("VIEW") @RenderMapping public String myHandle(@ModelAttribute("myCommand")TestBean tb, BindingResult errors, Model model) { if (!model.containsAttribute("myKey")) { model.addAttribute("myKey", "myValue"); } return "myView"; }
Example #2
Source File: PortletController.java From liferay-angularjs-portlet with Apache License 2.0 | 5 votes |
@RenderMapping public String view(RenderRequest request, RenderResponse response, ModelMap model) { User user = (User) request.getAttribute(WebKeys.USER); String userScreenName = user != null ? user.getScreenName() : "anonymous"; ResourceURL baseResourceUrl = response.createResourceURL(); model.addAttribute("ajaxURL", baseResourceUrl.toString()); model.addAttribute("standalone", false); model.addAttribute("authenticatedUser", userScreenName); model.addAttribute("portletId", getPortletId(request)); model.addAttribute("portletAppContextPath", request.getContextPath() + "/"); return "index"; }
Example #3
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@RenderMapping public void myHandle(RenderResponse response) throws IOException { if (this.portletContext == null || this.request == null || this.response == null || this.session == null || this.webRequest == null) { throw new IllegalStateException(); } response.getWriter().write("myView"); }
Example #4
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override @RequestMapping("VIEW") @RenderMapping public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) { if (!model.containsKey("myKey")) { model.addAttribute("myKey", "myValue"); } return "myOtherView"; }
Example #5
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@RequestMapping("EDIT") @RenderMapping public String myOtherHandle(TB tb, BindingResult errors, ExtendedModelMap model, MySpecialArg arg) { TestBean tbReal = (TestBean) tb; tbReal.setName("myName"); assertTrue(model.get("ITestBean") instanceof DerivedTestBean); assertNotNull(arg); return super.myHandle(tbReal, errors, model); }
Example #6
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override @RequestMapping("VIEW") @RenderMapping public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) { if (!model.containsKey("myKey")) { model.addAttribute("myKey", "myValue"); } return "myView"; }
Example #7
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@RequestMapping("VIEW") @RenderMapping public String myHandle(@ModelAttribute("myCommand")TestBean tb, BindingResult errors, ModelMap model) { if (!model.containsKey("myKey")) { model.addAttribute("myKey", "myValue"); } return "myView"; }
Example #8
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@RequestMapping("VIEW") @RenderMapping public void myHandle(@ModelAttribute("testBean") TestBean tb, Errors errors, RenderResponse response, PortletSession session) throws IOException { assertTrue(tb.isJedi()); assertNull(session.getAttribute("testBean")); response.getWriter().write("test-" + tb.getName() + "-" + errors.getFieldError("age").getCode()); }
Example #9
Source File: AnnotationMethodHandlerAdapter.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected boolean isHandlerMethod(Method method) { if (this.mappings.containsKey(method)) { return true; } RequestMappingInfo mappingInfo = new RequestMappingInfo(); ActionMapping actionMapping = AnnotationUtils.findAnnotation(method, ActionMapping.class); RenderMapping renderMapping = AnnotationUtils.findAnnotation(method, RenderMapping.class); ResourceMapping resourceMapping = AnnotationUtils.findAnnotation(method, ResourceMapping.class); EventMapping eventMapping = AnnotationUtils.findAnnotation(method, EventMapping.class); RequestMapping requestMapping = AnnotationUtils.findAnnotation(method, RequestMapping.class); if (actionMapping != null) { mappingInfo.initPhaseMapping(PortletRequest.ACTION_PHASE, actionMapping.name(), actionMapping.params()); } if (renderMapping != null) { mappingInfo.initPhaseMapping(PortletRequest.RENDER_PHASE, renderMapping.windowState(), renderMapping.params()); } if (resourceMapping != null) { mappingInfo.initPhaseMapping(PortletRequest.RESOURCE_PHASE, resourceMapping.value(), new String[0]); } if (eventMapping != null) { mappingInfo.initPhaseMapping(PortletRequest.EVENT_PHASE, eventMapping.value(), new String[0]); } if (requestMapping != null) { mappingInfo.initStandardMapping(requestMapping.value(), requestMapping.method(), requestMapping.params(), requestMapping.headers()); if (mappingInfo.phase == null) { mappingInfo.phase = determineDefaultPhase(method); } } if (mappingInfo.phase != null) { this.mappings.put(method, mappingInfo); return true; } return false; }
Example #10
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@RequestMapping("EDIT") @RenderMapping public void myHandle(@RequestParam("param1") String p1, @RequestParam("param2") int p2, @RequestHeader("header1") long h1, @CookieValue("cookie1") Cookie c1, RenderResponse response) throws IOException { response.getWriter().write("test-" + p1 + "-" + p2 + "-" + h1 + "-" + c1.getValue()); }
Example #11
Source File: DefaultAnnotationHandlerMapping.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Derive portlet mode mappings from the handler's method-level mappings. * @param handlerType the handler type to introspect * @param beanName the name of the bean introspected * @param typeMapping the type level mapping (if any) * @return {@code true} if at least 1 handler method has been registered; * {@code false} otherwise */ protected boolean detectHandlerMethods(Class<?> handlerType, final String beanName, final RequestMapping typeMapping) { final Set<Boolean> handlersRegistered = new HashSet<Boolean>(1); Set<Class<?>> handlerTypes = new LinkedHashSet<Class<?>>(); handlerTypes.add(handlerType); handlerTypes.addAll(Arrays.asList(handlerType.getInterfaces())); for (Class<?> currentHandlerType : handlerTypes) { ReflectionUtils.doWithMethods(currentHandlerType, new ReflectionUtils.MethodCallback() { @Override public void doWith(Method method) { PortletRequestMappingPredicate predicate = null; String[] modeKeys = new String[0]; String[] params = new String[0]; if (typeMapping != null) { params = StringUtils.mergeStringArrays(typeMapping.params(), params); } ActionMapping actionMapping = AnnotationUtils.findAnnotation(method, ActionMapping.class); RenderMapping renderMapping = AnnotationUtils.findAnnotation(method, RenderMapping.class); ResourceMapping resourceMapping = AnnotationUtils.findAnnotation(method, ResourceMapping.class); EventMapping eventMapping = AnnotationUtils.findAnnotation(method, EventMapping.class); RequestMapping requestMapping = AnnotationUtils.findAnnotation(method, RequestMapping.class); if (actionMapping != null) { params = StringUtils.mergeStringArrays(params, actionMapping.params()); predicate = new ActionMappingPredicate(actionMapping.name(), params); } else if (renderMapping != null) { params = StringUtils.mergeStringArrays(params, renderMapping.params()); predicate = new RenderMappingPredicate(renderMapping.windowState(), params); } else if (resourceMapping != null) { predicate = new ResourceMappingPredicate(resourceMapping.value()); } else if (eventMapping != null) { predicate = new EventMappingPredicate(eventMapping.value()); } if (requestMapping != null) { modeKeys = requestMapping.value(); if (typeMapping != null) { if (!PortletAnnotationMappingUtils.validateModeMapping(modeKeys, typeMapping.value())) { throw new IllegalStateException("Mode mappings conflict between method and type level: " + Arrays.asList(modeKeys) + " versus " + Arrays.asList(typeMapping.value())); } } params = StringUtils.mergeStringArrays(params, requestMapping.params()); if (predicate == null) { predicate = new MethodLevelMappingPredicate(params); } } if (predicate != null) { if (modeKeys.length == 0) { if (typeMapping != null) { modeKeys = typeMapping.value(); } if (modeKeys.length == 0) { throw new IllegalStateException( "No portlet mode mappings specified - neither at type nor at method level"); } } for (String modeKey : modeKeys) { registerHandler(new PortletMode(modeKey), beanName, predicate); handlersRegistered.add(Boolean.TRUE); } } } }, ReflectionUtils.USER_DECLARED_METHODS); } return !handlersRegistered.isEmpty(); }
Example #12
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping(windowState = "MAXIMIZED", params = "report=third") public String renderSecond(RenderResponse response) { response.setProperty("RESPONSE", "renderThird"); return "renderThird"; }
Example #13
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping(windowState = "MAXIMIZED", params = "report=second") public String renderSecond(RenderResponse response) { response.setProperty("RESPONSE", "renderSecond"); return "renderSecond"; }
Example #14
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping public String renderFirst(RenderResponse response) { response.setProperty("RESPONSE", "renderFirst"); return "renderFirst"; }
Example #15
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping public void myDefaultHandle(Writer writer) throws IOException { writer.write("myView"); }
Example #16
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping("MAXIMIZED") public void myHandle(Writer writer, @RequestParam("test") String renderParam) throws IOException { writer.write("myLargeView-" + renderParam); }
Example #17
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping(params = "myParam=myOtherSpecialValue") public void myHandle(RenderResponse response) throws IOException { response.getWriter().write("myOtherSpecialView"); }
Example #18
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping public void myDefaultHandle(RenderResponse response) throws IOException { response.getWriter().write("myDefaultView"); }
Example #19
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping(params = "myParam=mySpecialValue") public void myHandle(RenderResponse response) throws IOException { response.getWriter().write("mySpecialView"); }
Example #20
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping(params = "surprise") public void mySurpriseHandle(RenderResponse response) throws IOException { response.getWriter().write("mySurpriseView"); }
Example #21
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping(params = {"view=my", "lang=de"}) public void myLangHandle(RenderResponse response) throws IOException { response.getWriter().write("myLangView"); }
Example #22
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RenderMapping(params = {"view", "!lang"}) public void myOtherHandle(RenderResponse response) throws IOException { response.getWriter().write("myOtherView"); }
Example #23
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RequestMapping("VIEW") @RenderMapping public void myHandle(TestBean tb, Errors errors, RenderResponse response) throws IOException { response.getWriter().write("test-" + tb.getName() + "-" + errors.getFieldError("age").getCode()); }
Example #24
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RequestMapping("HELP") @RenderMapping public void myHandle(TestBean tb, RenderResponse response) throws IOException { response.getWriter().write("test-" + tb.getName() + "-" + tb.getAge()); }
Example #25
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RequestMapping("VIEW") @RenderMapping public void myHandle(TestBean tb, Errors errors, RenderResponse response) throws IOException { response.getWriter().write("test-" + tb.getName() + "-" + errors.getFieldError("age").getCode()); }
Example #26
Source File: HelloController.java From Spring-MVC-Blueprints with MIT License | 4 votes |
@RenderMapping public String handleRenderRequest(RenderRequest request, RenderResponse response, Model model) { return "hello"; }
Example #27
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RequestMapping("EDIT") @RenderMapping public void myHandle(@RequestParam("param1") String p1, int param2, RenderResponse response, @RequestHeader("header1") String h1, @CookieValue("cookie1") String c1) throws IOException { response.getWriter().write("test-" + p1 + "-" + param2 + "-" + h1 + "-" + c1); }
Example #28
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RequestMapping("HELP") @RenderMapping public void myHandle(TestBean tb, RenderResponse response) throws IOException { response.getWriter().write("test-" + tb.getName() + "-" + tb.getAge()); }
Example #29
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RequestMapping("HELP") @RenderMapping public void myHandle(@ModelAttribute("tb") TestBean tb, RenderResponse response) throws IOException { response.getWriter().write("test-" + tb.getName() + "-" + tb.getAge()); }
Example #30
Source File: Portlet20AnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@RequestMapping("EDIT") @RenderMapping public void myHandle(@RequestParam("param1") String p1, int param2, RenderResponse response, @RequestHeader("header1") String h1, @CookieValue("cookie1") String c1) throws IOException { response.getWriter().write("test-" + p1 + "-" + param2 + "-" + h1 + "-" + c1); }