-
1. Re: Ajax Request duplicating parameters
stefan_tausendpfund Jun 22, 2010 4:36 PM (in response to mudi30)Hello,
are you using the <redirect/> option in the navigation rule?
regards
Stefan
-
2. Re: Ajax Request duplicating parameters
mudi30 Jun 23, 2010 3:11 AM (in response to stefan_tausendpfund)Hi,
No i am not using redirect and i do not want to use redirect. I have tested with redirect but then nothing works. The button is not navigable any more.
It is a bridge problem because the ajax request is a resource request and the bridge is duplicating the param key names every time.
Please help me to find the correct solution!
Thanks
ali
-
3. Re: Ajax Request duplicating parameters
oterral Oct 4, 2010 9:44 AM (in response to mudi30)Actually I've exactly the same probleme with my portlet . I use liferay 6.0.4 , richfaces 3.3.3.FINAL ,Jboss portlet bridge 2.0.0.Final, JSF 1.2.15 and facetes 1.1.15 . You can see th error with a simple example like this :
<a4j:commandButton id="button" value="refresh Text" reRender="button">
<f:param value="param1value" name="param1"/>
<f:param value="param2value" name="param2"/>
<f:param value="param3value" name="param3"/>
<f:param value="param4value" name="param4"/>
<f:param value="param5value" name="param5"/>
</a4j:commandButton>On each reRender of the Button the paramaters who were send in POST on th first request ,are duplicate on the second request as GET parameter and concatenate with liferay namespace and the actionURL parmaeter generate by the a4j:commandbutton.
I'm not sure I'm very clear so have a look to the generate javascript of the a4j:commandbutton :
Before first click on the button:
A4J.AJAX.Submit('__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form',event,{'similarityGroupingId':'__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form:include:button','parameters':{'param1':'param1value','__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form:include:button':'__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form:include:button','param2':'param2value','param3':'param3value','param4':'param4value','param5':'param5value','javax.faces.portletbridge.STATE_ID':'view:_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_'} ,'containerId':'__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot','namespace':'_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_','actionUrl':'http://localhost:8080/web/guest/mapfaces\x2Ddemos?p_p_id=portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L\x26p_p_lifecycle=2\x26p_p_state=normal\x26p_p_mode=view\x26p_p_resource_id=%2Ffaces%2Fexamples%2Findex.xhtml\x26p_p_cacheability=cacheLevelPage\x26p_p_col_id=column\x2D1\x26p_p_col_count=1\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__jsfBridgeViewId=%2Fexamples%2Findex.xhtml'} );return false;
After 3 reRender :
A4J.AJAX.Submit('__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form',event,{'similarityGroupingId':'__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form:include:button','parameters':{'param1':'param1value','__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form:include:button':'__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form:include:button','param2':'param2value','param3':'param3value','param4':'param4value','param5':'param5value','javax.faces.portletbridge.STATE_ID':'view:_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_'} ,'containerId':'__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot','namespace':'_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_','actionUrl':'http://localhost:8080/web/guest/mapfaces\x2Ddemos?p_p_id=portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L\x26p_p_lifecycle=2\x26p_p_state=normal\x26p_p_mode=view\x26p_p_resource_id=%2Ffaces%2Fexamples%2Findex.xhtml\x26p_p_cacheability=cacheLevelPage\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__jsfBridgeViewId=%2Fexamples%2Findex.xhtml\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__jsfBridgeViewId=%2Fexamples%2Findex.xhtml\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L___portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form:include:button=__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_%3A_viewRoot%3Aform%3Ainclude%3Abutton\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_javax.faces.portletbridge.STATE_ID=view%3A_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_AJAXREQUEST=__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_%3A_viewRoot\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L___portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form=__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_%3A_viewRoot%3Aform\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_javax.faces.portletbridge.STATE_ID=view%3A_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param1=param1value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L___portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form:include:button=__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_%3A_viewRoot%3Aform%3Ainclude%3Abutton\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param3=param3value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_javax.faces.ViewState=j_id2\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param2=param2value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param2=param2value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param1=param1value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param4=param4value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param4=param4value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param5=param5value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__jsfBridgeViewId=%2Fexamples%2Findex.xhtml\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param3=param3value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param1=param1value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_javax.faces.portletbridge.STATE_ID=view%3A_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_javax.faces.ViewState=j_id2\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__jsfBridgeViewId=%2Fexamples%2Findex.xhtml\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param2=param2value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param3=param3value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param4=param4value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param5=param5value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_param5=param5value\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L___portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form=__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_%3A_viewRoot%3Aform\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_AJAXREQUEST=__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_%3A_viewRoot\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_AJAXREQUEST=__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_%3A_viewRoot\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L___portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form:include:button=__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_%3A_viewRoot%3Aform%3Ainclude%3Abutton\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L___portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_:_viewRoot:form=__portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_%3A_viewRoot%3Aform\x26_portletmfbasic_WAR_portletmfbasic_INSTANCE_1y0L_javax.faces.ViewState=j_id2'} );return false;
So the actionUrl generated by viewHandler.getActionURL() is too long for the browser rand the request failed.
Please help, I'm desesperate
-
4. Re: Ajax Request duplicating parameters
wesleyhales Oct 4, 2010 12:49 PM (in response to oterral)If you can pinpoint exactly where this is happening, I will try to get a fix in for the next release.
-
5. Re: Ajax Request duplicating parameters
oterral Oct 5, 2010 8:21 AM (in response to wesleyhales)Personnaly , I 've overrided and hacked the org.ajax4jsf.renderkit.AjaxRenderUtils class in Richfaces-impl in my portlet:
I've replaced these lines:
if (ajaxActionURL != null) {
// Setup action URL. For portlet environment, it will be different from
// page.
options.put("actionUrl", ajaxActionURL);
}by:
if (ajaxActionURL != null) {
// Setup action URL. For portlet environment, it will be different from
// page.options.put("actionUrl", removeDuplicateParameter(ajaxActionURL));
}and added the following function:
/**
* Remove duplicate parameter value from an actionUrl.
* Currently we remove only parameter with a duplicate "INSTANCE" word in his name.
* But it seems paramaters mandatory are all "p_p*" liferay specific parameters,
* and 2 parameetrs from PortletBridge : _jsfBridgeViewId and _javax.faces.portletbridge.STATE_ID.
* We need more investigations.
* @param actionUrl
* @return
*/
private static String removeDuplicateParameter(final String actionUrl) {
String[] url = actionUrl.split("\\?");if (url.length == 2) {
//Parse query string and remove duplicate parameter
final String query = url[1];if (query != null && !query.isEmpty()) {
// Stored KVP ina HashMap
final Map<String, String> params = new HashMap<String, String>();for (final String param : query.split("&")) {
final String[] pair = param.split("=");if (pair.length == 2) {
try {
params.put(URLDecoder.decode(pair[0], "UTF-8"), URLDecoder.decode(pair[1], "UTF-8"));} catch (UnsupportedEncodingException ex) {
log.error(ex);
return actionUrl;
}
}
}//Rebuild the new query string
if (!params.isEmpty()) {
final StringBuilder str = new StringBuilder(url[0]).append("?");for (final String key : params.keySet()) {
//Ugly fix to prevent duplicate parameter value in actionUrl. ActionUrl becomes too long when a component is rerendered itself.
if (!key.contains("INSTANCE")
|| ((key.contains("jsfBridgeViewId") || key.contains("javax.faces.portletbridge.STATE_ID"))
&& Utilities.getOccurence(key, "INSTANCE") <= 1)) {
str.append(key).append("=").append(params.get(key)).append("&");
}
}
return str.toString();
}
}
}
return actionUrl;
}This function remove all paramaters containing "INSTANCE", except for "jsfBridgeViewId" and "javax.faces.portletbridge.STATE_ID"
which seems mandatory.
It's a quick and dirty hack but it works.