struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: [S2] Type Conversion Problem in documentation
Date Fri, 27 Apr 2007 19:30:00 GMT
Struts2 Fan wrote:
> Hi all,
> 
> I have a problem with this type-conversion thing.
> 
> http://struts.apache.org/2.x/docs/type-conversion.html
> 
> I am trying to dynamically fill a table. I have a bean
> Person and Person has "List<House>".  
> 
> What I did - step by step.
> 
> 1 - I defined "List <House> houseList" in the PersonAction class. (Also
> Getter and Setter Methods)
> 
> 2 - create a file. in the resources directory (the path is the same with the
> PersonAction)
> 
> PersonAction-conversion.properties
> 
> KeyProperty_houseList=id
> Element_houseList=org.tutorial.model.House
> CreateIfNull_houseList=true
> 
> 3 - And in the jsp file I put this as it is said in link above.
> 
> <s:iterator value="houseList" id="house">
>   <s:textfield name="houseList(%{house.id}).name" />
> </s:iterator>
> 
> (House has a String field "name")
> 
> 4 - The values are not shown in the jsp file. So I cannot get them in the
> action too.
> But when I change the name of the <s:textfield> to "name" it writes the
> names on the textboxes. But still I cannot get the list when I press on the
> update button.
> 
> I expect it to fill the houseList when I go back to Action class. Is it
> wrong?
> 
> Can you see what I am doing wrong or something missing?
> 
> Thanks for reading.

I'm just guessing here, but you have a suspicious looking OGNL expression:

    <s:textfield name="houseList(%{house.id}).name" />

I'd start by trying these variations:

    <s:textfield name="%{houseList(house.id).name}" />
    <s:textfield name="%{houseList(#house.id).name}" />
    <s:textfield name="%{#houseList(house.id).name}" />
    <s:textfield name="%{'houseList('+ house.id + ').name'" />

Try breaking that OGNL expression out into a series of s:property tags 
to see which bits of the expression are / are not resolving as you expect.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message