• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is it possible to have a selectManyListBox within <ui:repeat> ?

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I have a selectManyListBox within a <ui:repeat> or that is completely wrong ? I can displayed the values properly , however I cant retrieve the selected items in my list.

An error is displayed "myform:j_idt117:0:j_idt119:0:_t121: Validation Error: Value is not valid"

 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recommend using the h:dataTable tag whenever you want to repeat UI elements in a tabular format (including single-column tables). ui:repeat is best left for less-structured elements.

You will find debugging a lot easier if you include your own "id=" attributes on the various XML elements. Otherwise JSF will automatically generate IDs, and when errors display, those IDs can be hard to resolve back to find the offending component.

When you have a collection of SelectItems, it's a lot simpler to simply use the "f:selectItems" tag than to manually code individual selectItems.

And finally, the answer you've been waiting for: The validation error comes when the list selection(s) reference values that aren't in the selectItem collection.
 
michael nik
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your answers are really helpful.

Now, I tried to do it using data tables or using selectManyListBox and both of the cases are displaying properly in the browser. My problem is when the user submits the selected items then I cant take the user's inputs, they do not save in my arrayList.

When I tried to put id's, each iteration build a new selectManyListBox with the same id but with different values, i receive an error message that Component ID myform:myKey has already been found in the view.

I tried to solve it by putting an increment variable in id="count" and from java e.g count++ but logically it does not work. Is this the reason that I cannot take the user's inputs ?

Another remarkable thing that I noticed is that: by using a selectManyListbox tag within a data table I can only retrieve user's input if the selected items belong to the last selectManyListbox that is created.


Do you have any suggestions?
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to understand about how a DataModel works. And, for that matter, how Inversion of Control works. In IoC, you don't "retrieve" values, the values are set for you automatically in the Model by the Controller (JSF).

You defined the receiving property of your selectManyListBox as a property of myBean. Consider: you have ONE myBean and MULTIPLE selectManyListBoxes. Can you be surprised if only one of them sets the value?

What you need is a separate receiving property for each of the selectManyListBox controls. That would be a property in the row model object (tt) in the DataModel. In other words:


When you do it that way, you can obtain the value of the selections in the 5th row (from 0, of course, so it's really row 6) of the model using straight POJO:


That's assuming that you defined a class TTYype for holding instances of row model objects and that TTType has a property named "selectedItems" to match the selectManyCheckBox.
 
michael nik
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, I understood my mistake I did using a property of selectManyListBox as a property of my Bean and I changed as you recommended me. However, I have some difficulties to understand how the dataModel is adjusted in my project. Before, I had an ArrayList of ArrayList<String>

tt was an ArrayList<String> and now I changed it to a DataModel. Also it had a property name {t} .

However what do you mean by and especially with ?

Please give me some tips since I am a bit confused, e.g from your last sentence, which type should be the property named "selectedItems" now to match the selectManyCheckBox?
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I don't guarantee that I got everything exactly right here, but thats the general shape of it.
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Please give me some tips since I am a bit confused, e.g from your last sentence, which type should be the property named "selectedItems" now to match the selectManyCheckBox?



 
michael nik
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim Holloway for your help, finally it works.
 
reply
    Bookmark Topic Watch Topic
  • New Topic