File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Dynamic input TextField when Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Dynamic input TextField when "add" button clicked" Watch "Dynamic input TextField when "add" button clicked" New topic
Author

Dynamic input TextField when "add" button clicked

Nikita Sinha
Greenhorn

Joined: Jul 17, 2012
Posts: 2
Hi,

Can someone guide me to tutorial or material which shows how to include a dynamic input Text field in jsf 2 xhtml when "add" button is clicked?..... number of textfield can vary from 0 - any(1/3/11/20.......) I am thinking to use hashmap to collect data from view but main point is how can i create dynamic UIcomponent?

Please guide me to some proper turtorial or some material

Thanks in advance
Nikita Sinha
Greenhorn

Joined: Jul 17, 2012
Posts: 2
can anyone help me on my problem?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16054
    
  21

Nikita Sinha wrote:can anyone help me on my problem?


No until you can explain it more clearly.

Am I understanding that you want to keep an array of textfield controls on your page and be able to add another control each time a button is clicked?

One of the simplest ways to do that is to define a dataTable with a row definition containing a textinput control. To add more controls, add more rows to the DataModel that backs the dataTable. JSF will do the rest automatically and you won't have to mess around with UIComponents at all.


Customer surveys are for companies who didn't pay proper attention to begin with.
Marco Noronha
Ranch Hand

Joined: Oct 30, 2012
Posts: 50
Tim Holloway wrote:One of the simplest ways to do that is to define a dataTable with a row definition containing a textinput control. To add more controls, add more rows to the DataModel that backs the dataTable. JSF will do the rest automatically and you won't have to mess around with UIComponents at all.


Do you have an example of what your saying?

I´m trying to build a fake dynamic form.

I mean, I change the rendered value and update the form component with ajax.
But not working. Can you help me out?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic input TextField when "add" button clicked