Forums de discussion

Multiple portlets on one portal page

PortletFaces Community Member, modifié il y a 12 années.

Multiple portlets on one portal page

Regular Member Publications: 199 Date d'inscription: 03/04/12 Publications récentes
Hi,
I have one issue when I have multiple portlets on single portal page. All the RIA features (javascript functions)stops working.

After analysis, i found that the form name for both the portlets is same hence javascript functions are not able to indentify the correct field.

for e.g.

in ExternalContextImple's preInitializeObjects method:


responseNamespace = portletResponse.getNamespace();

int hashCode = responseNamespace.hashCode();

if (hashCode < 0) {
hashCode = hashCode * -1;
}

String namespaceHashCode = Integer.toString(hashCode);

if (namespaceHashCode.length() > 4) {
namespaceHashCode = namespaceHashCode.substring(0, 4);
}

if (namespaceHashCode.length() < responseNamespace.length()) {

// Note that unless we prepend the hash namespace with some string, IE might encounter JavaScript problems
// with ICEfaces. http://issues.liferay.com/browse/FACES-12
responseNamespace = NAMESPACE_PREFIX + namespaceHashCode;
}

Here we get the hashcode for the namespace prefix and then takes substring till 4 position. Sometimes these 4 digits are same and hence the view source of the page renderes like this:

<form id="A1085:mf" name="A1085:mf" method="post"

<form id="A1085:mf" name="A1085:mf" method="post"

form name are same hence such calls fails:

jQuery(document.getElementById("A1085:mf:j_idt10:autoCompleteInput"))
.csJsfAutoComplete({startChar:0,autoCompleteArrow:true,reRender:"A1085:mf:firstCountry"})



How do you handle the scenarios where you have multiple portlets on one page.
Thanks for providing this information.
thumbnail
Neil Griffin, modifié il y a 12 années.

RE: Multiple portlets on one portal page

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
This should have been fixed in
http://issues.liferay.com/browse/FACES-67

Are you using a version of the bridge older than 2.0.0-BETA4?
PortletFaces Community Member, modifié il y a 12 années.

RE: Multiple portlets on one portal page

Regular Member Publications: 199 Date d'inscription: 03/04/12 Publications récentes
yes, I am still on BETA 3 version.
PortletFaces Community Member, modifié il y a 12 années.

RE: Multiple portlets on one portal page

Regular Member Publications: 199 Date d'inscription: 03/04/12 Publications récentes
Hi Neil,

Here is one suggestion regarding the namespace fix.
Why do we get hashcode for name space.
portletResponse.getNamespace(); returns the instance lable of the portlet which is always unique for a portlet. Two portlets would never have the same instance lable.

Therefor we can use this value without modifying to get the hashcode and look for last 4 digits.

I fixed it at my end by doing this. Do you think its feasible solution or is there any specific reason for getting the hashCode value.

Many thanks for your prompt reply always emoticon
thumbnail
Neil Griffin, modifié il y a 12 années.

RE: Multiple portlets on one portal page

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
From the bridge docs:
"The problem is that since the value returned by getNamespace() can be a lengthy string, the size of the rendered HTML portal page can become unnecessarily large. This can be especially non-performant when using the f:ajax tag in a Facelet view in order to perform partial-updates the browser's DOM."
http://www.liferay.com/community/liferay-projects/liferay-faces/documentation
thumbnail
Neil Griffin, modifié il y a 12 années.

RE: Multiple portlets on one portal page

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
Forgot to mention that the docs also talk about the "org.portletfaces.bridge.optimizePortletNamespace" context parameter that enables you to disable the optimization if you want.
PortletFaces Community Member, modifié il y a 12 années.

RE: Multiple portlets on one portal page

Regular Member Publications: 199 Date d'inscription: 03/04/12 Publications récentes
Thanks Neil.
Yes this could be the possible reason.

Thanks for providing me the link.