You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by William Miles <th...@tdcspace.dk> on 2002/12/15 17:12:23 UTC
question
Howdy folks,
I am having some problems and hope somebody can help. Using
struts-example as a starting point, I would like to move the following
decalration out of the jsp page and into the ActionBean(for the sake of
this example, we add it there):
java.util.ArrayList list = new java.util.ArrayList();
list.add(new example.LabelValueBean("one", "1"));
list.add(new example.LabelValueBean("two", "2"));
list.add(new example.LabelValueBean("three", "3"));
list.add(new example.LabelValueBean("four", "4"));
so in my FormBean and DataBean I added the setter and getter methods to
accomodate the above declaration eg:
private ArrayList list = null;
private String select = "one";
public void ArrayList getList(){
return list;
}
public void setList(ArrayList list){
this.list=list;
}
public void String getSelect(){
return select;
}
public void setSelect(String select){
this.select=select;
}
and added the list to the DataBean(which is used to populate the
FormBean) in the ActionBean:
...
data.setList(list);
...
now for the problem, how should i define the <html:select> and
<html:options> tags to get it to display the ArrayList instantiated in
the ActionBean?
<html:select property="select">
<html:options collection="list"
property="value"
labelProperty="label"/>
</html:select>
but this does not work.
Any help will be greatly appreciated.
Thanks
William
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: question
Posted by William Miles <th...@tdcspace.dk>.
Figured it out, I needed to add:
session.setAttribute("list", list);
To my ActionBean
Cheers
William
William Miles wrote:
> Howdy folks,
>
>
> I am having some problems and hope somebody can help. Using
> struts-example as a starting point, I would like to move the following
> decalration out of the jsp page and into the ActionBean(for the sake
> of this example, we add it there):
>
> java.util.ArrayList list = new java.util.ArrayList();
> list.add(new example.LabelValueBean("one", "1"));
> list.add(new example.LabelValueBean("two", "2"));
> list.add(new example.LabelValueBean("three", "3"));
> list.add(new example.LabelValueBean("four", "4"));
>
> so in my FormBean and DataBean I added the setter and getter methods
> to accomodate the above declaration eg:
>
> private ArrayList list = null;
> private String select = "one";
>
> public void ArrayList getList(){
> return list;
> }
>
>
> public void setList(ArrayList list){
> this.list=list;
> }
>
> public void String getSelect(){
> return select;
> }
>
>
> public void setSelect(String select){
> this.select=select;
> }
>
> and added the list to the DataBean(which is used to populate the
> FormBean) in the ActionBean:
> ...
> data.setList(list);
> ...
>
> now for the problem, how should i define the <html:select> and
> <html:options> tags to get it to display the ArrayList instantiated
> in the ActionBean?
>
> <html:select property="select">
> <html:options collection="list"
> property="value"
> labelProperty="label"/>
> </html:select>
>
> but this does not work.
>
> Any help will be greatly appreciated.
>
> Thanks
> William
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>