Announcement Announcement Module
Collapse
No announcement yet.
Portlets + Webflow: Redirect to home page on event? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Portlets + Webflow: Redirect to home page on event?

    Hi,

    I'm currently prototyping an application using WebFlow (2.3.0) in a Portlet (LifeRay 6.04) environment. I would like to redirect the user to the home page on a "cancel" event.

    This is my relevant flow configuration:
    Code:
    	<view-state id="cancel" view="externalRedirect:/" />
    	
    	<global-transitions> 
    		<transition on="cancel" to="cancel" />
    	</global-transitions>
    What I'm getting with that configuration is an exception:

    Code:
    20:26:26,250 ERROR [jsp:154] java.lang.IllegalStateException: A redirect is not allowed because the current PortletRequest is not a ActionRequest
    Is there a way to achieve this?

    thanks,
    del

  • #2
    The reason ist that the Portlet specification does only allow redirects during an action request.

    regards,
    Florian

    Comment


    • #3
      I understand that now, however, how do I make turn a request into an ActionRequest.

      I tried creating an action (LoginAction), where I verify if the Principal is null and then try the following: context.getExternalContext().requestExternalRedire ct("/login/");

      I thought that calling a method inside an action-state or <on-start>, would make it an ActionRequest, but I'm still getting:

      Code:
      Caused by: java.lang.IllegalStateException: A redirect is not allowed because the current PortletRequest is not a ActionRequest
      This is my code:
      Code:
      public class LoginAction {
      	private Log logger = LogFactory.getFactory().getInstance(LoginAction.class);
      	
      	public void execute(RequestContext context) {
      		logger.info("====== Calling LoginAction.execute() ======");
              if(context.getExternalContext().getCurrentUser() == null)
              	context.getExternalContext().requestExternalRedirect("/c/login/");
          }
      	
      }
      And this is my current flow definition (the part related to the method:
      HTML Code:
      <on-start>
              <evaluate expression="loginAction.execute(flowRequestContext)" />
      </on-start>
      So, how do I turn that request into an ActionRequest?

      Comment


      • #4
        Hi,

        Sorry for my late respone.
        It is not possible to turn a render-request into an action-request.
        You have to rethink your case.

        We solved this issue differently:
        We made it with the help of Spring Security.
        Make a filter that checks if the user is logged in, when not display an error (e.g. "you are not logged in").
        The user must login through the portal. He/She cannot login through the application.

        Another solution could be to make this with a decision state in webflow. If the user is logged in he can enter the default page, if he/she is not logged in he gets the login-page.

        Regards,
        Florian

        Comment

        Working...
        X