How do I refer to JSF components in jquery, as I dont know the id(s) prepended to the id of component I want to refer ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can give all
NamingContainercomponents in the view such as<h:form>,<h:dataTable>,<ui:repeat>,<my:composite>a fixed ID so that the HTML-generated client ID is safely predictable. If you’re uncertain, just open the page in webbrowser, rightclick and do View Source. If you see an autogenerated ID likej_id123in the client ID chain, then you need to give exactly that component a fixed ID.Alternatively, you can use
#{component.clientId}to let EL print the component’s client ID to the generated HTML output. You can use component’sbindingattribute to bind the component to the view. Something like this:This only requires that the script is part of the view file.
As another alternative, you could give the element in question a classname:
As again another alternative, you could just pass the HTML DOM element itself into the function: