No subject


Tue Feb 3 02:35:55 PST 2004


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




More information about the Opensource mailing list