aspose file tools*
The moose likes Struts and the fly likes Map Properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Map Properties" Watch "Map Properties" New topic
Author

Map Properties

Sahil Sharma
Ranch Hand

Joined: Aug 27, 2003
Posts: 152
Hi

In my ActionForm i have a property, named attributes of type HashMap. The hashmap internally contains number of values objects. Those value objects actually contains what all type of UI element will be displayed on my JSP. Basically, we are dynamically generating our UI elements.

But the problem i am facing right now is when i put my form in session scope then everything works fine. I am able to access that hashmap attributes and also loop through the same. But, when i change the scope from 'session' to 'request' then i am not able to access that hashmap attributes and it throws me an error. See Below:

org.apache.commons.beanutils.NestedNullException: Null property value for 'attributes(urgency)'at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:669)at org.apache.commons.beanutils.BeanUtilsBean.getNestedProperty(BeanUtilsBean.java:698)at org.apache.commons.beanutils.BeanUtilsBean.getProperty(BeanUtilsBean.java:723)at org.apache.commons.beanutils.BeanUtils.getProperty(BeanUtils.java:265)at org.apache.struts.taglib.html.BaseHandlerTag.lookupProperty(BaseHandlerTag.java:949)at org.apache.struts.taglib.html.RadioTag.currentValue(RadioTag.java:198)

Can please someone tell me why i am not able to access the property in request scope.

Thanks
~Vineet
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Does this error occur when the page is being displayed or when the page is submitted? If it is when your page is submitted than it is a straight forward problem. A new instance of your form was created and all your properties are null (or whatever you initialize them to).

This like has some information on lazy loading of lists:
http://wiki.apache.org/struts/StrutsCatalogLazyList

- Brent
Sahil Sharma
Ranch Hand

Joined: Aug 27, 2003
Posts: 152
when the page is being displayed.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The most likely cause of this problem is that the action that prepares for the display of this JSP and the action that processes a submit of this JSP do not specify the same scope. Make sure that in the action mapping for both actions, a scope of request is specified.

It is also possible that you may be manually putting a populated ActionForm bean into session scope, but then trying to retrieve it from request scope.

This problem would also occur if you specified redirect="true" in the forward that forwards to this JSP.

Even if you get past this problem when the page is dispalyed, you're going to have the same problem when the page is submitted, so you still need to read the link that Brent gave you. An ActionForm in request scope gets re-instantiated when a form is submitted. That means you have to take steps to rebuild your map structure as well.
[ November 01, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Sahil Sharma
Ranch Hand

Joined: Aug 27, 2003
Posts: 152
thanku Merrill. That was the problem. It has been solved now.
Thanks a ton!
Santosh Ramachandrula
Ranch Hand

Joined: Apr 04, 2004
Posts: 252
Though old post found it useful in solving the issue that I was having


Thanks,
Santosh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Map Properties