Archive for January, 2009

Using two Eager fetch in Appfuse + Struts 2 + Hibernate

Wednesday, January 28th, 2009

Apparently Hibernate does not support fetching two Bags Eagerly at the same time.

See problem here http://forum.hibernate.org/viewtopic.php?p=2310316&

I found a solution to the problem, described here in two blog entries

http://jroller.com/eyallupu/entry/hibernate_exception_simultaneously_fetch_multiple

http://jroller.com/eyallupu/entry/solving_simultaneously_fetch_multiple_bags

Appfuse create a custom page to edit users

Tuesday, January 27th, 2009

I am working on a site based on Appfuse + Struts 2 and I needed to create a custom page allowing the logged in user to change add information to his profile.

I decided to base my extension on the already existent User model object in Appfuse, copy pasted the default editProfile.jsp under a new name. Then I added few new fields there and also to the standard user object.

However I noticed a problem that my new jsp page was not getting the logged in user from the UserAction.edit method which I specified in the struts.xml, as it was also for the editProfile.jsp page. Instead I always got a new empty User object.

Looking into the code for the UserAction.edit method I saw that there is a boolean variable at the top of the method that checks wheter the query string included the editProfile string.

Thus there are two solutions to this problem. Let the name of the new .jsp include the string editProfile or simply copy the method into a new action method and hardcode the boolean value to true there. Also the new copied method can ofcourse been simplified.

The easiest way ofcourse is to have the page include the string editProfile.