wood burning stoves 2.0*
The moose likes JSF and the fly likes How to add new text boxes and check boxes dynamically when clicking on button in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to add new text boxes and check boxes dynamically when clicking on button in JSF" Watch "How to add new text boxes and check boxes dynamically when clicking on button in JSF" New topic
Author

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

raju.gollapalli raju.gollapalli
Greenhorn

Joined: Oct 23, 2007
Posts: 1
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

Joined: Sep 27, 2004
Posts: 114
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

Joined: Feb 05, 2001
Posts: 17257
    
    6

"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.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Nasim Salehi
Greenhorn

Joined: Oct 23, 2007
Posts: 9
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

Joined: Aug 25, 2005
Posts: 536
whats the scope of the managed bean 'InputFieldGeneration' ?

session or request?


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to add new text boxes and check boxes dynamically when clicking on button in JSF