Results 1 to 2 of 2

Thread: portlet:renderURL to MVC Controller

  1. #1
    Join Date
    Aug 2008
    Posts
    16

    Default 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. #2
    Join Date
    Oct 2006
    Posts
    228

    Default

    Quote 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •