Announcement Announcement Module
Collapse
No announcement yet.
portlet:renderURL to MVC Controller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • portlet:renderURL to MVC Controller

    I'm abit confuse how to direct an anchor tag to a Spring MVC controller
    Do I handle the request in the handleRenderRequestInternal method? and how do I redirect to another different controller from a current controller?

    Greatly appreciate for any inputs.

    LoginController.java
    Code:
    public class LoginController extends SimpleFormController
    {
    	
    	@Override
    	protected ModelAndView handleRenderRequestInternal(RenderRequest request,
    			RenderResponse response) throws Exception {
    		if ("logout".equals(request.getParameter("action")))
    		{
    			// how to redirect to LogoutController from here
    		}
    		
    		return super.handleRenderRequestInternal(request, response);
    	}
    }
    login.jsp
    Code:
    <portlet:renderURL var="renderAction">
    	<portlet:param name="action" value="logout" />
    </portlet:renderURL>
    <a href="${renderAction}"><spring:message code="logout.button"/></a>
    login-portlet.xml
    Code:
    <!-- Parameter Handler Mappings -->
    <bean id="logoutController" class="com.portlets.login.controller.LogoutController"/>
    <bean id="loginController" class="com.portlets.login.controller.LoginController">
    	<property name="commandName" value="webUser"/>
    	<property name="commandClass" value="com.portlets.login.model.WebUser"/>
    	<property name="formView" value="login.view"/>
    	<property name="successView" value="login.view"/>
    </bean>
    <bean id="parameterHandlerMapping" class="org.springframework.web.portlet.handler.ParameterHandlerMapping">
    	<property name="parameterMap">
    		<map>
    			<entry key="login" value-ref="loginController" />
    			<entry key="logout" value-ref="logoutController" />
    		</map>
    	</property>
    </bean>

  • #2
    Originally posted by Coffeejoy View Post
    I'm abit confuse how to direct an anchor tag to a Spring MVC controller
    Do I handle the request in the handleRenderRequestInternal method? and how do I redirect to another different controller from a current controller?
    The method you use to override to handle the request depends on the type of Spring controller you are using. The handleRenderRequestInternal method shouldn't generally be overriden (except AbstractController I think), there will usually be more specific method(s) that you override to hook into the particular controller's workflow. The javadoc for each controller shows the workflow and hooks for the controller.

    There is a recent discussion on redirecting between portlet controllers in http://forum.springframework.org/showthread.php?t=58357. Note you can only redirect between controllers when moving between the action and render phases of the portlet processing. Redirects to EXTERNAL urls are also only possible from the action phase using the portlet api.

    Hope this helps,

    Chris

    Comment

    Working...
    X