To get a HTML component in javascript, normally we use getElementById('componentId'),
But there are 2 constraints to get PrimeFaces component.
1. the id defined in component tag is not the actual element id in HTML.
to resolve this issue, we can use the javascript API provided by PrimeFaces to retrieve the actual HTML element id.
#{p:component('componentId')}
2. quote in the above API breaks the quote in getElementById
to resolve this problem, the quote in PF's API need to be replaced.
Done!!
But there are 2 constraints to get PrimeFaces component.
1. the id defined in component tag is not the actual element id in HTML.
to resolve this issue, we can use the javascript API provided by PrimeFaces to retrieve the actual HTML element id.
#{p:component('componentId')}
2. quote in the above API breaks the quote in getElementById
to resolve this problem, the quote in PF's API need to be replaced.
document.getElementById('#{p:component("componentId")}')
Done!!