You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2004/02/04 21:05:35 UTC
DO NOT REPLY [Bug 26671] New: -
indexed properties can be only used with forms in the session scope
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26671>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26671
indexed properties can be only used with forms in the session scope
Summary: indexed properties can be only used with forms in the
session scope
Product: Struts
Version: 1.1 Final
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: Controller
AssignedTo: struts-dev@jakarta.apache.org
ReportedBy: olgt@yahoo.com
If an action form has a indexed property defined as ArrayList elements = null
and consists of instances of MyClass (that has some properties on its own) then
in order for struts to fill the html property elements[x].bb with the value
from the request, attribute aa should not be null. But elements will be null if
1. the form is in the request scope
2. and not initialized in the form.
While initializing the form nested property can be done in some cases it can
not be done with collections because the number of elements is unknown in
advance. Example:
PrepareListAction – creates a form MyForm instance and initializes the form’s
attribute ArrayList aa with an ArrayList of objects MyClass. It then forwards
the control to the ShowList.jsp which displays the elements using indexed
property of the html:text tags which will result in html elements with names
like elements[x].bb. The ShowList.jsp then submits the data to the
SaveListAction.
If the MyForm is defined in the session scope, then the collection initialized
in the PrepareListAction remains in the scope and everything works fine. But if
the form bean defined in the request scope, then the NullPointerException is
thrown when request is parsed and an attempt is made by struts to assign the
value to the element of the collection instance variable. Collection can not be
just initialized in the form because the number of the elements is unknown.
Note. ArrayList aa = new ArrayList() does not make any difference as it causes
java array indexed exception when struts try to assign the value to the element
with a given index to an empty collection.
How difficult would it be to initialize the indexed properties with the right
number of elements that is known from the request ?
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org