tks very much, it works after change var to id.
Also, have further question need to bother you similar to it
same bean class
public class Bed {
private String bed_id;
public String getBed_id() {return bed_id;}
public void setBed_id(String bed_id) { this.bed_id=bed_id; }
}
same action class
...
private ArrayList<Bed> beds;
public String execute() throws Exception {
....
beds=service.Beds();
return SUCCESS;
}
public void setBeds(ArrayList<Bed> beds){ this.beds = beds; }
public ArrayList<Bed> getBeds() { return beds; }
almost same jsp file
<s:iterator value="beds" status="st" >
<s:property value="bed_id"/>
</s:iterator>
<s:select label="Bed ID" name="bed_id" headerKey="1" headerValue="Please
Select Bed#" list="beds"/> /* the problem */
the output is
1 2 3 4
...@188d92e
...@16a5bcb
b...@1b08cf3
....@1f5d699
my question is that why "s:select list" print object but value, is because i
defined ArrayList<Bed> ?
what is the correct way to fetch value out as <s:iterator><s:property
value="bed_id"/> did
tks in advance again
--- On Sat, 4/11/09, Wes Wannemacher <[email protected]> wrote:
From: Wes Wannemacher <[email protected]>
Subject: Re: <s:checkboxlist or <s:checkbox
To: "john lee" <[email protected]>
Date: Saturday, April 11, 2009, 11:53 AM
Try to use "id" attribute instead of "var"
-W
On 4/11/09, john lee <[email protected]> wrote:
>
> tks for both of u try to help me
>
> <s:iterator value="beds" status="st" >
> <s:property value="bed_id"/>
> </s:iterator>
>
> the above works, and print the value of bed_id
>
> but, the following still not works
>
> <s:iterator value="beds" status="st" var="curBed">
> <s:checkbox name="%{'bed[' + (st.count-1) + ']'}"
> alue="#curBed.bed_id"></s:checkbox>
> </s:iterator>
>
> and running result complain the "var" tag
>
> please advise, tks in advance
>
> john
>
> --- On Fri, 4/10/09, Dave Newton <[email protected]> wrote:
>
>
> From: Dave Newton <[email protected]>
> Subject: Re: <s:checkboxlist or <s:checkbox
> To: "Struts Users Mailing List" <[email protected]>
> Date: Friday, April 10, 2009, 6:28 PM
>
>
> Wes Wannemacher wrote:
>> Second, when you are using the iterator and creating single checkboxes,
>> you need to make the names unique. You are simply creating a new checkbox
>> with the name "beds" over and over again.
>
> Putting in an index only matters if order is important (and you don't trust
> the browser to submit in order); if a page has multiple variables of the
> same name their values will be put into an array or collection action
> property.
>
> For a checkbox w/ a true/false value probably need either an index or to use
> a map-based property.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
>
>
--
Sent from my mobile device
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher