File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 have issue to display JPA proxy objects

 
Alex Winner
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic