Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript referring to JSF tags

 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I just wanted to know how I could reference a JSF <h:inputText.. or a <h utputText field, enclosed inside a form in my JavaScript.

Roughly I have a JSF page, onclick a JScipt function runs, updating <h:inputText and <h utputText values,

I do it the same way you would refernce a regular html page, but I get the error "document.form.field has no properties"...

Thanks in advance
Regards
Zein
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF form elements have a unique ID makeup.

formName:elementName, so....

<h:form id="loginForm">
<h:inputText id="name".../>
</h:form>

Would yield

<input type="text" id="loginForm:name" .../>

When in doubt, view the rendered source page. It will be all HTML, albeit a convoluted mess. ;)
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Thanks for your response, I've solved the problem.
I use the following code to access the correct field.. it work!



Zein
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic