Redirect user to other page

Hi,

I have an action where I call a webservice and depending on the web service’s output I decide to redirect the user to one of two pages.
I’ve tried the following but I’m getting an error:

getFacesContext().getExternalContext().dispatch(“/secondPage”);

java.lang.IllegalStateException: Must be a RenderRequest
at com.webMethods.caf.faces.portlet.PortletFacesContext$PortletExternalContext.dispatch(PortletFacesContext.java:178)

What am I doing wrong?

Thanks
Bruno

I think you’ll want to use the gotoPage() API from the BasePortletPageBean class. (See http://techcommunity.softwareag.com/ecosystem/documentation/webmethods/wmsuites/wmsuite8-2_fcs/My_webMethods_and_Task_Engine/8-2_CAF_and_MWS_Java_API_Reference/index.html for CAF/MWS JavaDocs)

The javadocs mention that this API must be invoked from an ActionRequest.

Please let me know if this resolves the issue.

Regards,
–mark

Hi,

I’ve tried that but it failed with the error below.
It seems this only works if the the “page” is really another view, which is not the case.

java.lang.RuntimeException: [POP.016.0006] View source is not found: /NTT.view
at com.webMethods.caf.faces.view.xml.XMLViewHandler.getInputSource(XMLViewHandler.java:83)
at com.webMethods.caf.faces.view.xml.XMLViewHandler.createBuilder(XMLViewHandler.java:40)
at com.webMethods.caf.faces.view.BaseViewHandler.createView(BaseViewHandler.java:86)
at com.webMethods.caf.faces.bean.BasePortletPageBean.gotoPage(BasePortletPageBean.java:100)

Thanks
Bruno

Ok, i made an assumption and i should’ve clarified first. Are you trying to redirect the user to a different Portal Page, a different view in the same web application, a different portlet, or something else?

Thanks,
–mark

Hi,

I’m trying to redirect the user into another Portal page, belonging to a different web application.

Cheers,
Bruno

Here’s a good topic on Portlet URLs (http://tech.forums.softwareag.com/viewtopic.php?t=23645&highlight=portlet+url&sid=0e8e128ea29ac03f1be89419cf6d6e7b) which you’ll want to use to generate the URL.

The API to invoke is FacesContext.getExternalContext().redirect(). (See Oracle Java Technologies | Oracle for javadocs)

Additionally, this method (redirect) can’t be invoked from an async command method. It must be invoked from a normal (sync) command.

Regards,
–mark