Redirection in a view after command execution

Hi,
I have a portlet that has four “command buttons” and one “portlet simple link” (this link has also Porlet parameters)
I would like invoke the “portlet simple link” after one command execution.
How I can do this?

Thanks
Bye
Fabio

Hello

Try this:


String urlString = "http://softwareag.com";
getFacesContext().getExternalContext().redirect(urlString);

Regards.

Hi,
I tryed to put this code in one action and call this action but i have this error:

java.lang.IllegalStateException: [POP.007.0060] The sendRedirect method can not be invoked after any of the following methods of the ActionResponse interface has been called: setPortletMode, setWindowState, setRenderParameter, setRenderParameters

My requirement is to redirect in another view (portlet) of my project.

Thanks
Bye
Fabio

I think redirect method works only with command buttons, not with async ones

Ok the redirection works with command button but I must redirect into a portlet view having some parameters and above I must redirect after one action execution.

The existing simple portlet link that I put into view has this destination url: /Visualizzazione/default.view. But if I set the string url like this in a redirection action I have an error.

Hello:

You can create a page with your portlet and assign it to an alias.

Log into MWS as sysadmin, go to fabrik task and create a new page. Edit the page. Drap and drop your portlet into the page. In page properties, set the alias.

If your alias is named MyPage, your redirect may look like this:


getFacesContext().getExternalContext().redirect("/MyPage"); 

or


getFacesContext().getExternalContext().redirect("http://mws:port/MyPage"); 

Also, you may include your parameters in the url.

Hope this help. (sorry by my english).

Regargs.

@Fabio, if you have already constructed where your link should go using the ‘Extended Portlet URL’ control, then you should be able to get that control and retrieve the url to redirect to from it.

For example, something like this:

	/**
	 * Getter method for the control with id='defaultForm:extendedPortletUrl'
	 */
	public com.webmethods.caf.faces.component.portleturl.ExtendedPortletUrl getExtendedPortletUrl()  {
		return (com.webmethods.caf.faces.component.portleturl.ExtendedPortletUrl) findComponentInRoot("defaultForm:extendedPortletUrl");
	}
	
	public String testAction() {
		try {
			com.webmethods.caf.portlet.IPortletURL portletUrl = getExtendedPortletUrl().getPortletUrl();
			getFacesContext().getExternalContext().redirect(portletUrl.toString());
			return OUTCOME_OK;
		} catch (Throwable t) {
			error(t);
			return OUTCOME_ERROR;
		}
	}

Or, alternatively, you could just construct the url directly from the java code (see the javadocs), like this.


	public String testAction2() {
		try {
			com.webmethods.caf.portlet.IPortletURL renderUrl = createRenderUrl();
			//TODO: add/update the url here via the java APIs
			
			getFacesContext().getExternalContext().redirect(renderUrl.toString());
			return OUTCOME_OK;
		} catch (Throwable t) {
			error(t);
			return OUTCOME_ERROR;
		}		
	}

Hi,
thank for replies. I’ve implemented the first Eric’s solution and it works fine but I had to change the type of button with command button instead async command button.

Thanks a lot
Bye
Fabio