Sunday, October 27, 2013

How to get client id in Liferay PrimeFaces portlet

There is a convenient function in PrimeFaces to get client id of a component.
That is #{p:component('compId')}
The above function returns a full client id, eg. form:compId

But the full client id returned in Liferay portlet is not usable.
because Liferay portal is appending an unique id in front of form to make the client id unique.
eg. A8838:form:compId

Thus, the returned id is not a valid id in PrimeFaces or JSF context.

 JSTL functions could be used to solve this issue.

#{fn:substringAfter(p:component('compId')}

with the above syntax, the returned id will igore the text before the first ":"
Thus, returned id would be form:compId


Done!!

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...