Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts2 have issue to display JPA proxy objects  RSS feed

Posts: 5
  • 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:
<s:iterator status="addressStat" value="account.addresses">
<s:textfield key="account.addresses[%{#addressStat.index}].address1" value="address1" required="true" size="32" maxlength="40"/>

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


It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!