Tutorial :Richfaces component id in form - css



Question:

I have a component inside a form:

<a:form id="myform">     <a:somecomponent id="comp">  </a:form>  

and a huge css file, which attaches some style to the component with id "comp".

However, this does not work, as in the rendered html page, the components name becomes "myform:comp".

How can I prevent this? Using myform:comp in css does not seem to work :-(


Solution:1

You have to add prependId="false" to form tag.

<a:form id="myform" prependId="false">     <a:somecomponent id="comp">  </a:form>  


Solution:2

You just need to use the richfaces functions detailed here. #{rich:clientId(‘comp’)} can be used in this case.

Edit: also see this answer


Solution:3

The best solution I found up till now is not to use the id, but the style class, and replace all of the occurences of #comp in the css file with .comp:

<a:form id="myform">     <a:somecomponent styleClass="comp">  </a:form>  

However, I don't consider this as a 'clean' solution...


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »