You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andrew Penrose <An...@ward.ie> on 2007/04/23 20:00:09 UTC

Type Conversion Issue

Hi Guys,

I have an ArrayList of say Car models which we are displaying on a page.
The status field of the model sets the default value of a select
dropdown using a <s:select> tag on the page. When I go to update the
status we can't seem to get type conversion working.....the id of the
collection object returned is always null...and when we try the below
with %{car.id}) it gives us a null error on the setProperty for status.

<s:select list="#{'ok':'ok',
'cancelled':'cancelled','complete':'complete'}"
                                      name="carList(%{car.id}).status"
                                      value="%{status}"/>

Our bean has the following with apprropriate getters and setters:
.
.
@Entity
@Table(name = "tblCar")
public class Car extends BaseObject implements Serializable {

    protected long id=-1; protected String status;.
.
.


Our Action class has a list called carList:

.
.
public class MyCarAction extends BaseAction {

    private List <Car>carList = new ArrayList();

    public List<Car> getCarList() {
        return this.carList;
    } 

   public void setCarList(List<Car> carList) {
        this.carList = carList;
    }

.
.

Our conversion file MyCarAction-conversion.properties contains:

 
KeyProperty_carList=id
Element_carList=CreateIfNull_carList=true

 

Our iterator in jsp page is:

 
<s:iterator value="carList" id="carBean">

                    <tr>
                       <td><s:property value="dateApplied"/></td>
                        <td><s:property value="job.jobTitle"/></td>
                        <td>
                            <s:select list="#{'Submitted':'Submitted',
'Reply Received':'Reply
Received','Interview':'Interview','Closed':'Closed'}"
 
name="carList(%{carBean.id}).status"
                                      value="%{status}"/>
                       </td>
                   </tr>
</s:iterator>

 

Any help appreciated,

                                                            

 

Yours Sincerely,

 

Andrew