• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic input TextField when "add" button clicked

 
Nikita Sinha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone help me on my problem?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marco Noronha
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic