[Opensource] Using Expresso workflow and Actionforms and the like

larry hamel expresso at codeguild.com
Wed Nov 26 12:44:10 PST 2003


Max,

I usually leave the "default" form in place.  setFormCache() is used to allow repopulating a web page's input fields from the last attempt values.  e.g., after error, don't make 'em type everything in again.  see usage in SimpleReg.

the workflow stuff is relatively new--not much community experience, though I keep planning to try it.  I'd recommend avoiding it if you are just starting out.

the opensource email list is slower than forum posting.  the emailer on jcorporate has a lot of email to send, but you can check the forum web site for answers to your questions anytime.

larry

At 01:19 PM 11/25/2003, you wrote:
>Hi,
>
>I'm really floundering with Expresso at present. I've only been using 
>the framework and struts for about 3 weeks now and just can't get up to 
>speed quickly. Every time I try to do something, the documentation is so 
>scarce and tricky to find it takes days to complete something that 
>should take an hour or two at most.
>
>So far I have the following Expresso bits working:
>- My whole database is set up as DBObjects and I can search, sort, etc 
>on my objects
>- I have some basic JSP's using expresso-struts tags working.
>- I can use DBMaint on all my tables.
>- Login and Registration. I have my own registration objects defined and 
>functioning. I've extended all the standard login and registration 
>objects.
>- I have struts tiles set up and have seperate controllers behind each 
>tile (really neat that tiles stuff).
>- I have a job object defined and it does a day end on my database 
>correctly. I have a problem add()'ing the job to my Schema but that is a 
>different story.
>
>Now that I'm getting away from the standard DBMaint kinda programming 
>the wheels are falling off.
>
>Right now I'm trying to get workflow up and running. I'm trying the 
>wizard style addStatePairing() flavor. I suspect there are other flavors 
>of this as well???
>
>>From monitoring the Forums, FAQ's and searching the archives of this 
>list, it doesn't appear that anyone is actually using this workflow. 
>I've seen some discussion about DefaultForms but don't have a clue how 
>these actually fit into the scheme of things as the Javadoc and other 
>docs are silent on the subject.
>
>Anyway, I have the following states/screens, 1) search a dbobject, 2) 
>select a record from the search results, 3) select a record from a 2nd 
>dbobject and 4) do all sorts of db operation using these two records.
>
>I've created a bean extended from ControllerForm and set that up in the 
>struts-config.xml file as a form bean. This bean keeps all the data that 
>I collect along the way through these states. Not that I really 
>understand what form beans are or how they are used at the lower levels.
>
><form-beans>
>  <form-bean name="sellSubscription" 
>   type="com. ... .SellSubscriptionForm"/>
></form-beans>
>
>
>I've also have: 
><action path="/tacwebsite/SellSubscriptions" 
>type="com. ... .SellSubscriptionsController" name="sellSubscription" 
>scope="session" validate="false"></action>
>in struts-config.xml
>
>I'm also using the Expresso default view handler to get this working 
>quickly. (Can I even use it here?).
>
>My prompt handlers looks like:
>
>public void perform(StateForm sf, ControllerRequest request, 
>      ControllerResponse response) throws
>      ControllerException, NonHandleableException 
>{
>  super.perform(sf, request, response);
>
>  SellSubscriptionForm form = (SellSubscriptionForm) sf;
>
>  Output o = new Output("title", "Search for member");
>  response.add(o);
>
>  Input i = new Input("firstname");
>  i.setLabel("First name");
>  i.setType("text");
>  i.setMaxLength(10);
>  i.setDisplayLength(10);
>  response.add(i);
>
>  i = new Input("surname");
>  i.setLabel("Surname");
>  i.setType("text");
>  i.setMaxLength(10);
>  i.setDisplayLength(10);
>  response.add(i);
>
>  i = new Input("businessname");
>  i.setLabel("Business name");
>  i.setType("text");
>  i.setMaxLength(10);
>  i.setDisplayLength(10);
>  response.add(i);
>}
>
>
>One of my state/profile handlers looks like:
>
>public void perform(StateForm sf, ControllerRequest request, 
>      ControllerResponse response) throws
>      ControllerException, NonHandleableException {
>
>  super.perform(sf, request, response);
>  SellSubscriptionForm form = (SellSubscriptionForm) sf;
>
>  // at this point I assume that the magic beneath would have populated
>  // my form bean with the relevant values??? Perhaps the default view
>  // handler can't do this??? Perhaps I have some magic code to write
>  // in a jsp??? 
>  // So instead I do (big hack I suspect):
>
>  if (form.getSearchFirstname() == null) {
>    String firstName = request.getParameter("firstname");
>    String surname = request.getParameter("surname");
>    String businessName = request.getParameter("businessname");
>
>    form.setSearchFirstName(firstName);
>    form.setSearchSurname(surname);
>    form.setSearchBusinessName(businessName);
>  }
>}
>
>At the end of the wizard, all the handlers are called again for 
>validation and I then needed to put in a check to prevent my form values 
>from getting overwritten, hence the ugly if () hack.
>
>This all now works and I can navigate using the next and prev tranitions 
>back and forth between my states, and at my last state all the correct 
>data arrives for final processing.
>
>At first my form bean was getting cleared every time I hit a new prompt 
>state and after I changed the scope from 'request' to 'session' in the 
>struts action definition, my form data was not cleared anymore.
>
>So my questions are:
>1) What am I doing wrong here?
>2) Should I even be using the workflow as no-one else seems to be doing 
>so?
>3) What is DefaultForm and should I be using it instead?
>4) Some other snippet of code I saw was calling super.setFormCache() 
>after calling super.perform(...) in the states. What does this do? 
>Javadoc is completely empty here. For me it simply threw an exception so 
>I took it out.
>5) How does a StateForm relate to a struts ActionForm? Not that I know 
>what an ActionForm is.
>6) Has anyone actually got some real documentation on this topic? I've 
>looked at the workflow section in the user docs and it's pretty arcane. 
>I eventually found the original submitters post in the archives and his 
>post had some sample code attached, which I modelled my code on. Is this 
>code still valid? Is it worth putting into the Expresso Developer Guide?
>7) Does anyone have an actual working example for this topic? There is 
>mention of people using DefaultForms and ActionForms in the lists, but 
>seldom StateForms/ControllerForms. Can someone please send me some code 
>to look at.
>8) Perhaps I'm out of my league here and should not even be attempting 
>to use Expresso. If this is the case would someone please tell me so.
>
>I know this is a lot of questions but I'm afraid that will always be the 
>case until someone documents this stuff understandably. I would 
>volunteer to make some additions to the DG, but after all the 
>misunderstandings I've had along the way I'm pretty sure I'm still 
>coding everything using worst practices.
>
>Help please,
>Frustrated,
>Max
>
>_______________________________________________
>Opensource mailing list
>Opensource at jcorporate.com
>http://mail.jcorporate.com/mailman/listinfo/opensource
>Archives: http://mail.jcorporate.com/pipermail/opensource/




More information about the Opensource mailing list