Its like this, a bean with String array say "numbers". I have a jsp with selectOneMenu tag. Further i have written code for initializing the numbers array as list-entry with values(1,2,3). I am not able to associate this array with my listbox (or selectOneMenu) tag, imean the tag and value. I have tried replacing selectOneMenu with dataTable with its value set as "bean.numbers" var="row" and outputting it in a column using outputText value="#{row}" (it works, that is list-entries value are being set). Instead of dataTable i want to use selectOneMenu, how do I achieve the same?
(Also declare a bean property "number" to store the number to be post)
Hope this works.
Regards Klaus
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
posted
0
Thanks Klaus, i tried it. I dont know where I could initialize the Map. I just declared it and provided corresponding getters and setters. when I run my JSP I get exception,
"javax.servlet.jsp.JspException: Conversion Error setting value ''{0}'' for ''{1}''. "
Klaus Claszen
Greenhorn
Joined: Jun 20, 2007
Posts: 16
posted
0
Maybe the Declaration of your Map (Generics?) does not fit to the configuration of your managed bean (<map-entries>/<key-class>/<value-class>). It would be helpfull if you post some parts of your code (faces-config.xml, Bean and JSP).
Good Luck
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
posted
0
Okay!
Here is portion of bean declation, (it is by name UserBean)
Following is the code in faces-config,
Code in JSP
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
posted
0
For the face-config.xml I dont know if the code before property name would be interest to you, anyways, i snap it right from managed-bean tag itself...
Klaus Claszen
Greenhorn
Joined: Jun 20, 2007
Posts: 16
posted
0
it must be selectItems (with s at the end)
I'm always smiling. To look sad I have to perfom a headstand normally,.....
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
posted
0
...and... and... and....... it worked! !! Thanks a lotttt Klaus. Not so important but still just one query, the list-box always gets filled up in a 3-2-1 fashion, irrespective of order map-entry tags in faces-config, any ideas why? [ June 22, 2007: Message edited by: Akhilesh Trivedi ]
Klaus Claszen
Greenhorn
Joined: Jun 20, 2007
Posts: 16
posted
0
Use a sorted Map to influence the order.
private Map<String, String> numbers = new TreeMap<String, String>();
I do not know (better I do not believe) if the order of the map-entries in faces-config is secure.
Use other Types than String to sort numbers :-)
Have fun!
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: List box initialization through managed bean