This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting the Values of Dynamically Rendered TextFields  RSS feed

 
Phoenix Kilimba
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sirs/Madams,
I have a Visual Web JSF page which dynamically displays textfields for capturing and setting the values of a backing beans attribute. However, I am confused as to how to capture the data as I cannot refer to the textfields by name (e.g. textField.getValue()) as they are dynamically rendered. How can I go about getting the user input in the textfields?

Thanks in advance,
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each textfield needs a unque, identifying id in order for you to obtain the value. Are all textfields being given the same id?

Within JSF, you'll see something called the 'clientId' which is generated through the FacesContext. This clientId can be used to assign a unique id to dynamically generated fields. However, depending on how dynamic your fields are, you may need to write a custom tag to both generate the textfields and assign a unique id to each of them. Then, when the form is submitted, the custom tag can extract the field name in the decode method, and extract the appropriate data.

It gets complicated with dynamic fields.

Is there another approach that might deal with this scneario better? I hope someone else might have an answer.

-Cameron McKenzie
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!