----- Original Message -----
From: Martin J. La Jeunesse <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 27, 2001 1:57 PM
Subject: Struggling with select/options


> The examples I've seen using <html:options name="someBean"
> property="someProperty" /> all seem to reference a collection defined in
the
> same jsp as the options tag. Could someone provide a rookie with an
example
> where the collection bean is not defined in the same jsp, but rather by,
say
> an action servlet or an application bean?

OK, just have a look at the subscription.jsp page in the example
application, and remove the line 'pageContext.setAttribute("serverTypes",
list);'
Then add the following lines in the method perform of the class
EditSubscriptionAction let's say before forwarding the control:

java.util.ArrayList list = new java.util.ArrayList();
list.add(new org.apache.struts.example.LabelValueBean("IMAP Protocol",
"imap"));
list.add(new org.apache.struts.example.LabelValueBean("POP3 Protocol",
"pop3"));
list.add(new org.apache.struts.example.LabelValueBean("Another Protocol",
"another"));
session.setAttribute("serverTypes", list);

This displays the protocol names and the option values are set to "imap"
"pop3" and "another".

> For example, say I've got a User
> bean with a Vector of ints called Accounts. I'd like to display those
> accounts in a list-box - ultimately I'd like to display an associated name
> and use the int as the option value.

Did you put an int in your collection ? Did you try with a Integer ?

 I know that I can use labelName and
> labelProperty for this, but I haven't gotten the first part working yet.
> I'm able to get <html:options collection= working, but I'm stumped on the
> other options mode. Most of the ways I've tried it result in class cast
> exceptions during the jsp compile.
> thank you,
> Marty La Jeunesse
>
Jean-Noël

Reply via email to