You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Struts2 Fan <st...@gmail.com> on 2007/04/27 08:01:01 UTC

[S2] Type Conversion Problem in documentation

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.
-- 
View this message in context: http://www.nabble.com/-S2--Type-Conversion-Problem-in-documentation-tf3655875.html#a10213635
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Type Conversion Problem in documentation

Posted by Laurie Harper <la...@holoweb.net>.
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