I use IPortletURL Java Object to redirect and call a Action in target portlet,but failed...

I use IPortletURL Java Object to redirect and call a Action in target portlet,but failed.
Please help me to analysis the trouble…

in the souce porlet binding the following action to a command button control

public void htmlCommandButton_action() throws Exception{
		
		IPortletURL refreshUrl = createActionUrl();
		
		refreshUrl.clearParameters();
		refreshUrl.clearState();

		refreshUrl.setPortlet("/meta/default/link_portlet___targetpage/0000010988");
		refreshUrl.setTargetAction("dammit");
		
		Debug.info("redirectURL : " + refreshUrl.toString());
		getFacesContext().getExternalContext().redirect(refreshUrl.toString());

	}

the dammit action is in the target portlet


       @PortletAction
	public void dammit()
	{
		Debug.info("dammit");
	}

but but when I click the Command Button , the page was not redirect,but the target action was be executed.

I check the message in full_log
[2013-04-27 23:52:18 CST (Framework:INFO) [RID:201] - redirectURL : /meta/default/link_portlet___sourcepage/0000010984?wmp_tc=10988&wmp_rt=action&wmp_ax=KkLTrr31MH4oUXW6Qhp5DYlDIWQ%3d&wmp_ta=dammit
2013-04-27 23:52:18 CST (Framework:INFO) [RID:202] - Processing request [1j9cmt549q386:Administrator] http://localhost:8585/meta/default/link_portlet___sourcepage/0000010984 (GET)
2013-04-27 23:52:18 CST (Framework:INFO) [RID:202] - dammit ]
it shows that the target Action was be called successfull,but the page was still stay in source portlet,redirect failed!

To solve the problem,I modify the code


public void htmlCommandButton_action() throws Exception{
		
		IPortletURL refreshUrl = createActionUrl();
		
		refreshUrl.clearParameters();
		refreshUrl.clearState();

		//refreshUrl.setPortlet("/meta/default/link_portlet___targetpage/0000010988");
		refreshUrl.setBaseURL("/meta/default/link_portlet___targetpage/0000010988");
		refreshUrl.setTargetAction("dammit");
		
		Debug.info("redirectURL : " + refreshUrl.toString());
		getFacesContext().getExternalContext().redirect(refreshUrl.toString());

	}

when i click the command button , the portlet redirect to the target portlet Successfully,but the action on target portlet called failed.

i check the full_log
[2013-04-28 00:14:16 CST (Framework:INFO) [RID:207] - redirectURL : /meta/default/link_portlet___targetpage/0000010988?wmp_tc=10984&wmp_rt=action&wmp_ax=KkLTrr31MH4oUXW6Qhp5DYlDIWQ%3d&wmp_ta=dammit
2013-04-28 00:14:16 CST (Framework:INFO) [RID:208] - Processing request [1j9cmt549q386:Administrator] http://localhost:8585/meta/default/link_portlet___targetpage/0000010988 (GET)
2013-04-28 00:14:16 CST (jsf:INFO) [RID:208] - [POP.016.0048] ???: ????dammit ]
the Chinese means invalid target Action
Let’s analysis together,and help me to solve the problem
thanks very much!

link_Portlet.zip (12.8 KB)

Please add another portlet url as a child. The parent url specifies the baseurl (if different from the current page/folder). The child url(s) are for each target portlet. Each child url may have 0-n parameters. Only one child url may specify an ‘action’.

For example:


IPortletURL refreshUrl = createActionUrl();
		
refreshUrl.clearParameters();
refreshUrl.clearState();

IPortletURL targetPortletUrl = refreshUrl.addPortletURL("/meta/default/link_portlet___targetpage/0000010988");
targetPortletUrl.setTargetAction("dammit");
		
Debug.info("redirectURL : " + refreshUrl.toString());
getFacesContext().getExternalContext().redirect(refreshUrl.toString());

thanks for Eric Norman’s advice
I update the code like Eric Norman said,but it’s still didn’t work,


/**
	 * Action Event Handler for the control with id='htmlCommandButton'
	 */
	public void htmlCommandButton_action() throws Exception{
		IPortletURL refreshUrl = createActionUrl();  
        
		refreshUrl.clearParameters();  
		refreshUrl.clearState();
		
		IPortletURL targetPortletUrl = refreshUrl.addPortletURL("/meta/default/link_portlet___targetpage/0000010988");  
		targetPortletUrl.setTargetAction("dammit");  
		          
		Debug.info("redirectURL : " + refreshUrl.toString());  
		getFacesContext().getExternalContext().redirect(refreshUrl.toString()); 

	}

but when I click the command button ,the page was still not redirect,
I chek to full_log,
[2013-05-02 11:17:55 CST (Framework:INFO) [RID:89] - Processing request [1abpnkp3shyi5:Administrator] http://localhost:8585/meta/default/link_portlet___sourcepage/0000010984 (POST)
2013-05-02 11:17:55 CST (Framework:INFO) [RID:89] - redirectURL : /meta/default/link_portlet___sourcepage/0000010984?wmp_tc=10984&wmp_rt=action&wmp10988.wmp_ax=MygirwaNx2I3R2R7tRq9tHk707s%3d&wmp10988.wmp_ta=dammit
2013-05-02 11:17:56 CST (Framework:INFO) [RID:90] - Processing request [1abpnkp3shyi5:Administrator] http://localhost:8585/meta/default/link_portlet___sourcepage/0000010984 (GET)
2013-05-02 11:17:56 CST (Framework:INFO) [RID:91] - Processing request [1abpnkp3shyi5:Administrator] http://localhost:8585/meta/default/link_portlet___sourcepage/0000010984 (GET)
2013-05-02 11:17:56 CST (Framework:INFO) [RID:92] - Processing request [1abpnkp3shyi5:Administrator] http://localhost:8585/ (GET) ]

please tell me how to change the code to redirect from Portlet to another Portlet,and call the target action!

Sorry, my example was wrong. I forgot that the target action could only be set on the base portlet url. When using the ‘* Portlet URL’ UI controls it handles this automatically by moving the values to the right places.

So, to change to a new page and run an action on a portlet on the page the java code would have to look something like this:


	public void htmlCommandButton_action() throws Exception{
		IPortletURL refreshUrl = createActionUrl();  
        
		refreshUrl.clearParameters();  
		refreshUrl.clearState();
		
		//navigate to the page that has the target portlet on it.
		refreshUrl.setBaseURL("/portlet/link_portlet___targetpage");
		
		//set the portlet that is the target of the action
		refreshUrl.setPortlet("/portlet/link_portlet___targetpage");
		refreshUrl.setTargetAction("dammit");

		//redirect..
		Debug.info("redirectURL : " + refreshUrl.toString());
		getFacesContext().getExternalContext().redirect(refreshUrl.toString()); 

	}

thank you very much!
I ask the same question on empower,but they said my environment is broken,That sounds too funny,hahah