Re: Struggling with select/options

2001-03-05 Thread Eric Rasmussen



where 'temp_collection' is the type of class referenced by the 'name'
attribute of the html:select, 'id' is the value returned by the getId()
method (to be entered into the 'value' field of the option), and 'name' is
the value returned by the getName() method (to be the text dispayed by the
option).

So, if your collection (added to the request object by the controller class)
is of type com.whatever.TestClass objects, and TestClass has the methods
getId() and getName(), the following jsp code would (should) produce the
following html code:
jsp code:


[text label:]




html code:
[text label:]

[name of first
TestClass object]
[ ... ]
[name of last
TestClass object]


Hope this helps,
- eric

- Original Message -
From: "Martin J. La Jeunesse" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 26, 2001 5:42 PM
Subject: Struggling with select/options


> The examples I've seen using  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? 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. 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  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
>
>
>
>




Struggling with select/options

2001-03-03 Thread Martin J. La Jeunesse

The examples I've seen using  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? 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. 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 


RE: Struggling with select/options

2001-02-27 Thread Martin J. La Jeunesse

Jean-Noel, merci beaucoup.
Although using the collection mode of options, rather than name made, I'm
accomplishing what I wanted to do.
thanks again

> -Original Message-
> From: Jean-Noël Ribette [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 27, 2001 7:43 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Struggling with select/options
>
>
> > Did you put an int in your collection ? Did you try with a Integer ?
>
> Not in the collection of course but check you don't have an
> int which should
> be an Integer or a String somewhere.
>




Re: Struggling with select/options

2001-02-27 Thread Jean-Noël Ribette

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

Not in the collection of course but check you don't have an int which should
be an Integer or a String somewhere.




Re: Struggling with select/options

2001-02-27 Thread Jean-Noël Ribette


- 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  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  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




Struggling with select/options

2001-02-27 Thread Martin J. La Jeunesse

The examples I've seen using  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? 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. 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