This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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).
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 ]