wood burning stoves*
The moose likes Struts and the fly likes Struts2 have issue to display JPA proxy objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 have issue to display JPA proxy objects" Watch "Struts2 have issue to display JPA proxy objects" New topic
Author

Struts2 have issue to display JPA proxy objects

Alex Winner
Greenhorn

Joined: Jun 01, 2011
Posts: 5
I bet this is a Struts2 bug and I did found a work around to share. Just wondering if anyone has same issue before or may be have a better solution:
I am on JPA 2.0 and Struts2 version 2.3.3 running on RAD test environment.

I have an JPA object Account and Address:


So when I read an account information back in my action class, I see the address information is returned (but in proxy mode). So I can see the address1 information. But if I have JSP like (1st option):



It display nothing. But if I have JSP like (2nd option):


It display correct address retreived from database. however, if I used this second option, after I submit the form for update, I CANNOT get updated value in my action class. But the first one does get correct updated address1 after submit for update.

To find out why, I manually create a account and its address object and send to display using the first option, it works. The only different is manually created address object is a local object while address object retrieved from database is a proxy object. So, looks like there is something to do with the proxy object.

I twisted a while and found an work around to have both displaying and updating work is that I have to use both as following:
code=java]
<s:iterator status="addressStat" value="account.addresses">
<s:textfield key="account.addresses[%{#addressStat.index}].address1" value="address1" required="true" size="32" maxlength="40"/>
</s:iterator>
[/code]

While this sounds funny, it works. If you have any better solution please share.

Thanks,

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 have issue to display JPA proxy objects
 
Similar Threads
Struts2 nested iterators with listboxes
Struts2 - <s:iterator> in two-Dimensional Array.
@Generatedvalue and MySQL
Merging problem - id is generated instead of cusotm id.
EJB3/JPA @OneToOne