struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Mawata <chris_mawata_str...@mathcove.net>
Subject Re: Field Name Collision?
Date Tue, 26 Apr 2011 20:58:15 GMT
That is how OGNL works --  the Model object is higher and has a property 
of the name userId so it is the first match.
Chris

On 4/26/2011 3:52 PM, Eric Lentz wrote:
> - Struts 2.2.1
> - Tomcat 6.0
> - JDK 1.5.0_22
> - Code example of the problem: http://pastebin.com/eyyJaBg4
> - Description:
> I have two fields in my action class: user and userId. The user variable
> is of type User, which also contains a userId. In both cases userId is of
> type String.
>
> While implementing SessionAware and ModelDriven...
>
> Happy path:
> If I pass a parameter in the URL as follows:
> http://localhost:8080/Context/test-list.action?user.userId=foo
>
> Then user.userId = "foo" when it gets to the action.
>
> Not-so-happy path:
> If I pass a parameter in the URL as follows:
> http://localhost:8080/Context/test-list.action?userId=foo
>
> Then user.userId = "foo" when it gets to the action.
>
> Note that in both cases, "foo" was assigned to user.userId, though I used
> different keys in the URL each time!
>
> - Work-around:
> If I change either one of the names to something that is unique to the
> other, then it works as one would expect.
>
> Am I doing something wrong?
>
> - Eric


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


Mime
View raw message