File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Map Properties" Watch "Map Properties" New topic

Map Properties

Sahil Sharma
Ranch Hand

Joined: Aug 27, 2003
Posts: 152

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( org.apache.commons.beanutils.BeanUtilsBean.getNestedProperty( org.apache.commons.beanutils.BeanUtilsBean.getProperty( org.apache.commons.beanutils.BeanUtils.getProperty( org.apache.struts.taglib.html.BaseHandlerTag.lookupProperty( org.apache.struts.taglib.html.RadioTag.currentValue(

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

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:

- 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 ]

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

I agree. Here's the link:
subject: Map Properties
jQuery in Action, 3rd edition