2013/3/26 Markus Demetz <mar...@demetz.eu>:
> Hi,
>
> I don't know if this is the right place to ask, but maybe there is anyone
> who has experienced the same problem.
>
> I'm using Struts2 (latest version), with Hibernate (latest version)
> My database models all have getId().
>
> I have situations, where the getId() method of my model class returns null
> when navigating through OGNL e.g. when
> calling <s:property value="#user.gallery.id"/>.

Have you tried <s:property value="user.gallery.id"/> or <s:property
value="%{user.gallery.id}"/>

> When I call getId() from the method in my action class (e.g. UserListAction
> iterating though users and calling user.getGallery().getId()), it returns
> the id as expected.
> If I do that first in my action class, then also my <s:property.../> renders
> the id as expected; so I thought about a lazy loading issue... all my
> getId() methods are public, NOT final, and the Long id members are
> protected.
>
> I also tried to add a getMyId() method in the model which calls getId() from
> within the same class.
> getMyId() { return getId(); }
>
> This surprisingly works and outputs the correct id when calling <s:property
> value="#user.gallery.myId"/>

You know, HHH uses all that magic with proxies, baytecode manipulation
and so ;-)


Regards
Ł

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

Reply via email to