struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nate Bowler" <bow...@attask.com>
Subject RE: ActionForm mapped property submit/populate error
Date Mon, 07 Jul 2003 21:38:05 GMT
Thanks for the reply, but I am getting the same error using the <nested>
syntax as well. This is the error:

java.lang.IllegalArgumentException: No bean specified
	at
org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptor(PropertyUti
ls.java:837)
	at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:934)
	at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)

I have had no problem populating using either the <nested> or the mapped
property syntax. The problem I am having is submitting the form after it has
been populated.

The ActionForm has been reinitialized and there is no place to put this
data. A couple of notes:

- I have implemented reset() to recreate the collection class (Map map = new
HashMap()).
- It is a request scope ActionForm.

Why can't Struts set the mapped properties by itself after the form submit?

Nate

-----Original Message-----
From: Sandeep Takhar [mailto:sandeep_takhar@yahoo.com]
Sent: Monday, July 07, 2003 11:35 AM
To: Struts Users Mailing List
Subject: Re: ActionForm mapped property submit/populate error


A very common problem and you can spend too much time
on these issues.

Personally - I would use the nested tags.

When using them - don't worry about generating the
nested property syntax.  Just use them intuitively in
the easiest fashion possible.  This includes mapped
properties.

For indexed properties you will need

Object getObject(int index)

and setObject(int index, Object o)

and for mapped properties you need

Map getMap(String key)
setMap(String key, Object value)

on the action forms.

then just use this for indexed:

<nested:iterate property="collection" id="someId">
  <nested:text property="name"/>
</nested:iterate>

This will populate and load from the name property of
the object that is in the collection.  The collection
is stored in an attribute called "collection" in some
scope (in the above example).

for mapped

<nested:iterate property="myFormsMap">
  <nested:property="name"/>
<nested:iterate>

This will load and populate the name property of
whatever object is in the map.

that's it - it is that easy.

Here is another reference:

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg71256.html

sandeep
--- Nate Bowler <bowler@attask.com> wrote:
> I'm sure this is a common question for Struts
> newcomers dealing with
> mapped and indexed properties, but I can't find a
> good solution.
>
> To sum it up quickly, I can read values from an
> ActionForm with the
> following syntax in a JSP tag "rows(1).val", but
> when I submit, I
> get the following exception. Ideas?:
>
> java.lang.IllegalArgumentException: No bean
> specified
> 	at
>
org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptor
> (PropertyUtils.java:837)
> 	at
> org.apache.commons.beanutils.BeanUtils.setProperty
> (BeanUtils.java:934)
> 	at org.apache.commons.beanutils.BeanUtils.populate
> (BeanUtils.java:808)
>
>
> Here are more details:
>
> I've got an ActionForm subclass with the following
> methods:
>
> public Map getMap();
> public void setMap(Map map);
>
> public MyRow getRows(String idx);
> public void setRows(String idx, MyRow val);
>
> I prepopulate the form in an "open" action and
> everything displays
> beautifully. However, when I submit, the bean is
> "lost" and
>
> BeanUtils can't seem to "repopulate" it.
>
> What am I missing here?
>
> - The reset() method is implemented and it
> reinitializes everything.
> - It is a request scope form.
>
> What is the "best practice" for this type of use
> case?
>
> Nate
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
>


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com


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


Mime
View raw message