Vijay Ramachandran wrote:
> Hi Anissa,
>
> Thanks for the earlier pointer. I have something up and running. One
> question :
>
> What is the equivalent for a list box ?
If you are using the woodstock components, it will be <sun:listbox>
>
> In html, I will do the following :
>
> <select id="usecquestion" value="#{pageSession.usecquestion}">
> <option itemValue="1">Mother's maiden name</option>
> <option value="2">Last 4 digits of you social security
> number</option>
> <option value="3">City where you were born</option>
> <option value="4">Your favorite restaurant</option>
> <option value="5">City where you met your spouse</option>
> </select>
>
>
> How do I do the same in the JSFTemplating environment ? One way is to
> put the above piece of code within in <f:verbatim> but will that allow
> us export values to the handlers ?
There are couple samples of this in the Admin Console code. Just search
for <sun:listbox> under admin-gui/src/docroot
For your above sample, it will be something like:
<sun:listbox id="usequestion"
immediate="#{true}"
items="#{availableQuestions}"
multiple="#{false}"
rows="$int{6}"
selected="#{usequestion}"
>
listbox is a little tricky, you have to use a handler to create the
Option to specify that as the items.
We have a utility method to create the Options in GuiUtil.java, it
looks like:
public static Option[] getSunOptions(Collection<String> c) {
Option[] sunOptions = (c != null ? new Option[c.size()]:null);
int index=0;
for(String str:c) {
sunOptions[index++] = new Option(str, str);
}
return sunOptions;
}
So, you will need to write a handler that returns the sunOptions to be
used as the 'items' for the list box.
When the page submit, you can call a handler that takes in
#{usequestion} to see what value the user selected.
The handler input for this will be String[].
@HandlerInput(name="usequestion", type=String[].class )
Let me know if you have any other questions and free feel to post
questions to the dev_at_jsftemplating.dev.java.net, the alias is very
helpful.
Anissa
> Please let me know
>
> Thanks
>
> Vijay
>