It seems to me that this code is already *relying* on another framework in
order to be "more portable to another MVC framework". ActionEvent,
TilesEvent, TaskBean, BUtil, etc. are not Struts classes. Pulling in another
framework just to be able to use DynaActionForm seems like the antithesis of
KISS for the particular question posed...

--
Martin Cooper


> -----Original Message-----
> From: V. Cekvenich [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 30, 2002 5:17 PM
> To: [EMAIL PROTECTED]
> Subject: Re: okay, one more time for the slow people...
> 
> 
> The other way is:
> public Object onDisplayZoomExec(ActionEvent ae) throws Exception
> {
> String id = ae.getReq().getParameter(ID); // the PK is?
> long ia = BUtil.longString(id);
>               
> TasksBean frm  = (TasksBean) ((TilesEvent)ae).getFormBean();
>               
> setBBean( frm );
> getBBean().findSingle(ia); // hard code for now
>               
> ae.getReq().setAttribute(FORMBEAN, getBBean());
> 
> return ((TilesEvent)ae).getMapping().findForward("Zoom");
> }
> 
> 
> KISS, the code does not need UML or even comments or design.
> Keep it simple, complex != good or fast
> This code is also more portable to another MVC framework, ex. 
> JSF (one 
> reason is that controlers is an interface, in this exmple at the tile 
> level, so each tile has it's own events)
> Note use of event object, and auto dispatching of events. This gets 
> consumed by the JSTL tags. Also the bean, which you can't see 
> here calls 
> DAO .retrieve() in its findX ().
> (code from the Struts basicPortal on sf.net)
> 
> .V
> (Struts mentor 
> http://www.mail-archive.com/mvc-programmers%40basebeans.com/ms
g00242.html
> )
> 
> 
> 
> Eddie Bush wrote:
> > - Declare your form to be of type DynaActionForm in struts-config
> > - Declare your properties to be of whatever type they need to be
> > - Preface the page call with an action which will cast the "form" 
> > argument to be a DynaActionForm
> > - call form.set("property", value) as needed
> > - forward to the page that will use the form
> > 
> > Chapter 5 pg 20 of Chuck's book covers this quite well. 
> (That may not be 
> > exact, but it's close)
> > 
> > I'm not going to claim it's "the official way" - but it's 
> often done 
> > this way, for sure.  Follow Chuck's example.  Remember that 
> (unless you 
> > have extenuating circumstances - most of the time 
> pre-population does 
> > not qualify) you should never have to create a form 
> yourself.  Expect it 
> > to be there.  If it's not, double-check your config to 
> ensure you told 
> > Struts to make sure it was there.  If you have done that 
> and it didn't 
> > let it NPE and then file a bug report.
> > 
> > Vincent Stoessel wrote:
> > 
> >> How do you use the DyanActionForm in the action classes.
> >> I saw 2 different examples in the archive, neither of 
> which worked for
> >> me.
> >>
> >>     DynaActionFormClass dafc = 
> >> DynaActionFormClass.getDynaActionFormClass("AddUserForm");
> >>     DynaActionForm myForm = dafc.newInstance();
> >>
> >>
> >> gives me this compile error:
> >>
> >> AddUserAction.java [48:1] incompatible types
> >> found   : org.apache.commons.beanutils.DynaBean
> >> required: org.apache.struts.action.DynaActionForm
> >>
> >> line 48 : DynaActionForm myForm = dafc.newInstance();
> >>
> >>
> >> What is the official way?
> >> Thanks.
> > 
> > 
> > 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 
> 


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

Reply via email to