Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Map Properties

 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when the page is being displayed.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanku Merrill. That was the problem. It has been solved now.
Thanks a ton!
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though old post found it useful in solving the issue that I was having
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic