Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add new text boxes and check boxes dynamically when clicking on button in JSF

 
raju.gollapalli raju.gollapalli
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to add new text boxes and check boxes dynamically when clicking on button in JSF. Example : I have one text box and a ADD button, I want enter data in the text box than click ADD buttion, The entered data should be display next line in editable text and with a check box for select to delete. Can any body help me
 
A. Dusi
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do this in two ways:
1. Initially hide the editable textbox and its checkbox and render them only after you submit the form by your Add button.
2. You can create components in the action method: Use a panelGrid and bind it to your backing bean. Once the Add button is clicked, in your action method, add children to the panelGrid binding component.
Code will be something like this:
In your jsp:


In your backing bean:
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"raju.gollapalli raju.gollapalli",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
 
Nasim Salehi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I've tried to build a jsf page with dynamic UI Input fields in JSF, with a map that values are bound to it (and all of components are added as children to the PanelGrid tag's component).
Any time user clicks on add button 3 new input fields are generated in backing bean and my page rerenders.
The problem is : after rendering I can't see values binding to HtmlInputTexts,in fact the values are empty.
Here's the code:
Backing Bean:

And the jsf page:

Can anybody help me?
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whats the scope of the managed bean 'InputFieldGeneration' ?

session or request?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic