This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes JavaScript referring to JSF tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript referring to JSF tags" Watch "JavaScript referring to JSF tags" New topic

JavaScript referring to JSF tags

Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
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
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

JSF form elements have a unique ID makeup.

formName:elementName, so....

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

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. ;)

GenRocket - Experts at Building Test Data
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Hi guys,

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

I agree. Here's the link:
subject: JavaScript referring to JSF tags
It's not a secret anymore!