struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boyalla, Raveendra" <>
Subject RE: DynaActionForm and Nested property
Date Fri, 05 Jul 2002 16:07:52 GMT

this is my form bean.

<form-bean      name="addPCCompanyForm"
		<form-property name="pcCompany"

and in JSP 

<html:text property="pcCompany.companyName" size="30" maxlength="30"/> 

Error I got

java.lang.IllegalArgumentException: Null property value for 'pcCompany'
	at org.apache.struts.util.RequestUtils.lookup(

It seems I need to initialize form-bean   property pcCompany to new

Please help me out so that I can change all my form beans to DynaActionForm
having nested properties.

Thanks in advance.

Raveendra Boyalla

-----Original Message-----
From: Craig R. McClanahan []
Sent: Thursday, July 04, 2002 1:30 PM
To: Struts Users Mailing List
Subject: Re: should I use form bean and javabean for the same data?

On Thu, 4 Jul 2002, Jim Clayson wrote:

> Date: Thu, 4 Jul 2002 17:58:03 +0100
> From: Jim Clayson <>
> Reply-To: Struts Users Mailing List <>
> To: "''" <>
> Subject: should I use form bean and javabean for the same data?
> Hi,
> I read somewhere on this list sometime ago that one should bear in mind
> struts form beans should be considered to be part of the view in your
> run-of-the-mill MVC struts app and that they should only be used for
> prepopulating a form and/or reporting surface level validation errors.
> Does this mean that I shouldn't ever be setting the values on the form
> inside my action class or wherever I perform my business logic? If this is
> true (and please could someone confirm this), should I be using a vanilla
> javabean to model the data for use outside of the view?

It's hard to be very descriptive without a particular example, but in
general I would say that model-tier data is generally exposed to the view
tier as JavaBeans.  If you are using some of the popular design patterns
for multi-tier applications (such as those in "Core J2EE Patterns" by
Alur/Crupi/Malks), this object will typically be a Data Access Object, or
a Value Object, or (a more current term) Data Transfer Object.

It's ok to expose model data directly to the view tier for display-only
use, by saving it in a request or session attribute where the view page
can get to it.  For the incoming data that modifies things, I generally
set up my applications like this:

* "Setup" action creates and prepopulates the form bean, as well
  as setting up any other beans that are needed for the display.
  It then forwards to the "input form" page.

* The "input form" page as an <html:form> tag pointing at the
  "Process" action, with input fields that match the properties
  of the corresponding form bean.  In most cases, the properties
  of the form bean will be strings.

* The form bean has a validate() method to check for things like
  required fields and conversion errors (such as entering "1a3"
  into a field destined to be an integer).  If any errors are found,
  Struts redisplays the "input form" page for you, with the exact
  values that the user entered (even if they were wrong).  Note that
  we have *not* corrupted any model tier objects with invalid data.

* The "Process" action is called only after validation is successful.
  It can perform any additional checks it needs, and then interacts
  with the business objects to perform whatever updates are needed.
  (In trivially simple Struts apps, the business logic is sometimes
  embedded in the Action -- it's better to segregate this logic into
  separate business objects, though).

* At this point, the form bean gets thrown away, because it has
  completed its purpose.  For request-scope form beans, this happens
  automatically when the request completes.  For session-scope form
  beans, you have to deliberately remove the coresponding session

> Maybe I'm missing something here.
> Any assistance will be much appreciated.
> Jim


> __________________________________________________________
> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"
> Jim Clayson
> Infogain Limited
> tel: 01628 580600
> fax: 01628 580610
> email: <>
> web: <>
> Disclaimer:  Neither this e-mail nor any attachment places any legal or
> contractual obligations on Infogain Limited. Any reproduction, disclosure
> dissemination beyond the intended addressees is strictly prohibited save
> the legitimate business purposes of Infogain Limited and its clients or
> partners.
> __________________________________________________________

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message