my dog learned polymorphism*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript referring to JSF tags" Watch "JavaScript referring to JSF tags" New topic
Author

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
Regards
Zein
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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


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!



Zein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaScript referring to JSF tags