You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Steven D. Wilkinson" <st...@acm.org> on 2001/01/12 09:41:32 UTC

problems setting form attributes that are nested attributes

I'm having trouble using nested form attributes with the FORM tags (I know the
HTML tags are replacements, I just wanted to finish my last few pages before
using them.  Unless it fixes this bug, then I'll switch immediately.)

I have traced the code down to the PropertyUtils file.
In the PropertyUtils.setNestedProperty(Object bean, String name, Object value,
boolean convert) method I have the name the value and the bean of the attribute
just fine.  Then the getSimpleProperty(bean,next) returns null for the bean.

Inside getSimpleProperty(Object bean, String name) there is the following
code...
	Method readMethod = descriptor.getReadMethod();
	if (readMethod == null)
	    throw new NoSuchMethodException("Property '" + name +
					    "' has no getter method");

	// Call the property getter and return the value
	Object value = readMethod.invoke(bean, new Object[0]);
	return (value);

The value coming back is null.  Then I get an
java.lang.IllegalArgumentException: Null property value for my value.

1) Why is it getting when it should be setting?
2) Assuming this is wrong and it should be setting... Does it instantiate the
class first or do I have to do that?
(e.g.   OrderInformation shippingOrder = null; is in my Form class.
OrderInformation contains an Address object.  I'm using
shippingOrder.address.address1.  )
String's don't work this way.  Is this a bug or a feature?  I say this because
the attributes on the form are initialized to null and the method was a get... 
Maybe I'm off base... let me know.  
*** Note, the form gets populated just fine when I populate them in the Action
before it goes to the JSP page.  However, when I submit the form it won't store
my updates to the input fields that map to the bean through the nested
parameters because of the error detailed above.


I still have all the debug, I can give further information.
I'm using the nightly source distribution from 01/09/2001.

BTW, I'm really impressed with struts... 
It rocks... Great job everyone... Keep up the good work... Looking forward to
Release 1.0!!!!!!!!!

Thanks in advance, 
Steve

Re: problems setting form attributes that are nested attributes

Posted by "Steven D. Wilkinson" <st...@acm.org>.
Craig,

That worked!!!! Yea!!! Thanks soo much.
I'll convert to the HTML tags from my form tags.  I just wanted to make sure my
logic was right in the Action before I made the switch.

Steve

"Craig R. McClanahan" wrote:
> 
> "Steven D. Wilkinson" wrote:
> 
> > I'm having trouble using nested form attributes with the FORM tags (I know the
> > HTML tags are replacements, I just wanted to finish my last few pages before
> > using them.  Unless it fixes this bug, then I'll switch immediately.)
> >
> > I have traced the code down to the PropertyUtils file.
> > In the PropertyUtils.setNestedProperty(Object bean, String name, Object value,
> > boolean convert) method I have the name the value and the bean of the attribute
> > just fine.  Then the getSimpleProperty(bean,next) returns null for the bean.
> >
> 
> Could you try this with a more recent nightly build (like the one from last
> night)?  I've done some major surgery on this logic, and it works in a completely
> different manner now -- among other things, this method no longer exists -- and
> passes all the tests I've been able to come up with.  I'd appreciate it if you
> could try this in your environment and report back.
> 
> Craig McClanahan

Re: problems setting form attributes that are nested attributes

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Steven D. Wilkinson" wrote:

> I'm having trouble using nested form attributes with the FORM tags (I know the
> HTML tags are replacements, I just wanted to finish my last few pages before
> using them.  Unless it fixes this bug, then I'll switch immediately.)
>
> I have traced the code down to the PropertyUtils file.
> In the PropertyUtils.setNestedProperty(Object bean, String name, Object value,
> boolean convert) method I have the name the value and the bean of the attribute
> just fine.  Then the getSimpleProperty(bean,next) returns null for the bean.
>

Could you try this with a more recent nightly build (like the one from last
night)?  I've done some major surgery on this logic, and it works in a completely
different manner now -- among other things, this method no longer exists -- and
passes all the tests I've been able to come up with.  I'd appreciate it if you
could try this in your environment and report back.

Craig McClanahan