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 2003/02/12 16:51:37 UTC

DO NOT REPLY [Bug 17002] New: - Problem with index property

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=17002>.
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=17002

Problem with index property

           Summary: Problem with index property
           Product: Struts
           Version: Unknown
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Controller
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: lmisciagna@it.ibm.com


I have changed the PropertyUtils in the public static void setIndexedProperty
(Object bean, String name, int index, Object value)method I have added the 
following code because I have a null pointer exception the array is null.
if (array != null)  // CODE ADDED
if(!array.getClass().isArray()){
  if(array instanceof List) ((List)array).set(index, value);
  else throw new IllegalArgumentException("Property '" + name + "' is not 
indexed");
  } else {Array.set(array, index, value);}

Now I try to explain because I have this exception, I have a Form Bean A with a 
property that is an array in this array are stored the index of selected row in 
the table so when the rows are selected if I go to another form bean B by using 
a forward to another action mapping. Also this new bean has the same property 
of A but the array is not initialized and of couse will have different size. So 
when Struts tries to populate the form bean B found the parm in the request and 
try to initialize the property of B (but in my case is wrong) so it has a null 
pointer exception.
If I add the check if the array is null the problem is solved.

Could you ask me if you want introduce my fix in your code.
The version of Struts tah I use it is that shipped with WSAD v. 5.

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org