Pedantic clarification inline

Quoting "Craig R. McClanahan" <[EMAIL PROTECTED]>:

> 
> 
> On Sun, 19 Jan 2003, Mark Minnie wrote:
> 
> > Date: Sun, 19 Jan 2003 21:04:55 -0800
> > From: Mark Minnie <[EMAIL PROTECTED]>
> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: DynaActionForm question
> >
> > "Struts in Action" on page 162 reads:
> >
> > "You can use a DynaActionForm anywhere an ActionForm can be used.  You can
> also substitute a DynaActionForm for a conventional ActionForm without
> changing any of the existing Java or JSP code."
> >
> > I changed a ActionForm to a DynaActionForm by using the
> struts-config.xml:
> >
> >     <form-bean name="loginForm"
> type="org.apache.struts.action.DynaActionForm" dynamic="true">
> >        <form-property name="username" type="java.lang.String"/>
> >        <form-property name="password" type="java.lang.String"/>
> >     </form-bean>
> >
> > I thought I would not have to change my existing code in the Action java
> code, but my existing code did not work.  I originally had:
> >
> >         String username = ((LoginForm)form).getUsername();
> >         String password = ((LoginForm)form).getPassword();
> >
> > The LoginForm was the form bean that I had created manually in java.  I
> deleted the LoginForm and replaced the form bean with a DynaActionForm as
> listed above.  Of course, once I no longer have a LoginForm.java file because
> it is a DynaActionForm, this Action java code does not compile.
> >
> > Therefore I see that I have to change my code in going from a manually
> coded form bean to a DynaActionForm.
> >
> > Am I missing something?
> >
> 
> I think there was an implicit assumption in the sentence you quoted, that
> you were using BeanUtils or PropertyUtils to manipulate the properties.
> If your code had actually been:
> 
>   String username = PropertyUtils.getProperty(form, "username");
>   String password = PropertyUtils.getProperty(form, "password");

PropertyUtils.getProperty returns Object
BeanUtils.getProperty returns String

> 
> then you would indeed have had to make no changes when you swtiched from a
> standard ActionForm bean to a DynaActionForm.  If you're planning on
> experimenting with such switching, you might want to think about coding
> defensively like this.
> 
> > TIA
> >
> > Mark
> 
> Craig
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 


-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to