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

Adding a value to the current list in a dropdown JSF1.2

 
Akash Sharma
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi, I am new to JSF1.2 and enjoying learning the framework. Today while studying I stumbled upon an Idea and will be very amused to know if that's possible.

Suppose I have a list of values in a drop-down which I am fetching from DB, is it possible to give a link next to the drop-down if the user wants to add a value to the current list and as soon as he adds the value the new value starts reflecting in the drop-down immediately.

If someone can guide me towards the approach to achieve this I will feel very elated and motivated.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I highly recommend moving up to JSF 2.0. There are significant advantages and it isn't that hard.

I'm not sure if I truly understood what you are suggesting, but it is a common practice to cascade dropdown lists, as for example, country, state, city. There are some interesting ways to do this in JSF.
 
Akash Sharma
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your prompt reply. I'll try to make myself more clear this time.

Suppose I have a drop-down list for a field ,say, country and currently it has 2 values India and Australia. Suppose the user wants to add another country to the current list say England.
What I am thinking is can there be a link provided next to the drop-down list of countries, and when user clicks on the link he/she gets say a pop-up window to add any country to the current list of values.
When the user adds the new country it immediately starts to display in the list of countries.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. I think I've got that.

Let's start off with the initial list:


If you attach an AJAX onchange event to this control, it will fire an event when the list selection is changed. If the value of the selection equals the "Add a Country" value, your AJAX handler can be part of a process that displays the dialog you want (details will vary, depending on framework and implementation). If the dialog adds a SelectItem to the initial list for the new country, then triggers a re-render event on that control, the updated list will be made available on the client.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic