aspose file tools
The moose likes JSF and the fly likes dynamic creation of id attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "dynamic creation of id attribute" Watch "dynamic creation of id attribute" New topic
Author

dynamic creation of id attribute

Yvette Gonzalez
Greenhorn

Joined: Jan 14, 2002
Posts: 9
Hi All - I am a JSF newbie. I have a datatable form with each row containing a drop-down selectonemenu and a inputtextbox. I would like to use javascript (or anything!) to have the drop-down populate the textbox. I wanted to assign the id's of the components using the rowindex of the datamodel for the datatable but id won't let me. What am I missing? Thanks!
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
JSF already does it. You don´t need to do it. Just assign a fixed ID to h:form, h:dataTable, h:anyInputComponent and -if any- the f:subview so that JSF won´t autogenerate ID´s for you so that you have consistent element ID´s in the generated HTML output at end.


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
Yvette Gonzalez
Greenhorn

Joined: Jan 14, 2002
Posts: 9
Thanks but won't I have a table full of drop-down with the same id if I assign an id once in the datatable and it iterates over a datamodel? How can I reference it in the Javascrpit?

I apologize for my ignorance!! Thank you so much!!
Yvette Gonzalez
Greenhorn

Joined: Jan 14, 2002
Posts: 9
By the way - your blog is wonderful and a lifesaver!! I was hoping you would reply! Thanks!
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Check the generated HTML output, make use of the 'this' reference in Javascript and a shot of logical thinking

Example:



Yvette Gonzalez
Greenhorn

Joined: Jan 14, 2002
Posts: 9
Thanks Bauke! I took a shot of logical thinking and now all is working!
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You´re welcome.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: dynamic creation of id attribute
 
Similar Threads
Help Needed: Search/Filter on a Datatable for displaying records.
Drop Downs
Send Ajax request to refresh dataTable
ValueChangeListeners in DataTable
DataTable with DataScroller issue