Here is how I deal with UISelect components and populating them with a database.
Now to discuss that second method. What happens when the page is posted back for whatever reason, validation error etc, is I have to know which value the select menu should be sitting on. So I have to get the value I stored in the bean and lookup that up in the database. Not a big deal really, just extra code. Here is the JSP section.
So you see, when the page is submitted I store the value in newIssueForm.visit.currentIssue.issueType.id where issueType is JavaBean IssueType and has a property called id. The selectItems calls the getTypeList method shown above to populate the list with all the values I need.
Now, I show all this to ask if this is the best way. Is there a cleaner, smoother, easier way to do this or am I going about it about the best way possible?
Ok, I was trying to get the JSP as simple as possible, so I was able to get rid of the value attribute. But at a cost.
Taking a bit from my code above, if I leave everything as is, I get an error that the value of selectOneMenu (whatever is chosen) is not a String and does not have a converter. Well, it's not a String, it's an Integer. Oddly, if I keep the value attribute with the getters and setters for it, I don't get this error. But with just the binding attribute I get this error. So I modified my code a bit to compinsate..
And everything works. Anyone know of a way to make a converter that works with this scenerio?