You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dennis <de...@iswsolutions.com> on 2001/04/12 00:03:00 UTC
with indexed property problem
Hi,
I'm having trouble getting an html:select tag to properly set an indexed
bean property. The tag I'm using looks like:
<html:select property="values[0]">
My Action form includes the following:
protected String[] mValues;
public void setValues(int index, String value) {
if (mValues == null) {
mValues = new String[10];
}
mValues[index] = value;
}
public String getValues(int index) {
return mValues[index];
}
public String[] getValues() {
return mValues;
}
public void setValues(String[] vals) {
mValues = vals;
}
The attempt to set the values[0] property fails in the SelectTag
doStartTag() method with an InvocationTargetException, which results in the
following JspException:
Root cause:
javax.servlet.jsp.JspException: Getter for property values[0] threw
exception: java.lang.NullPointerException:
at org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:301)
I've successfully used the same form, and set the indexed properties using
<html:hidden>, but cannot get the html:select to work. Any thoughts?
Thanks,
Dennis
RE: with indexed property problem
Posted by Dennis <de...@iswsolutions.com>.
I found my problem - sorry for the bother. I had an unitialized array in
there that was getting returned to the SelectTag. Thanks anyway..
Dennis
-----Original Message-----
From: Dennis [mailto:dennis@iswsolutions.com]
Sent: Wednesday, April 11, 2001 4:03 PM
To: struts-user@jakarta.apache.org
Subject: <html:select> with indexed property problem
Hi,
I'm having trouble getting an html:select tag to properly set an indexed
bean property. The tag I'm using looks like:
<html:select property="values[0]">
My Action form includes the following:
protected String[] mValues;
public void setValues(int index, String value) {
if (mValues == null) {
mValues = new String[10];
}
mValues[index] = value;
}
public String getValues(int index) {
return mValues[index];
}
public String[] getValues() {
return mValues;
}
public void setValues(String[] vals) {
mValues = vals;
}
The attempt to set the values[0] property fails in the SelectTag
doStartTag() method with an InvocationTargetException, which results in the
following JspException:
Root cause:
javax.servlet.jsp.JspException: Getter for property values[0] threw
exception: java.lang.NullPointerException:
at org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:301)
I've successfully used the same form, and set the indexed properties using
<html:hidden>, but cannot get the html:select to work. Any thoughts?
Thanks,
Dennis