On Fri, 19 Nov 2004 13:44:47 -0700, BaTien Duong
<[EMAIL PROTECTED]> wrote:
> Greetings:
> 
> I want to prototype commons-chain in shale. I saw 2 apps: agility and
> mailreader. I was able to build commons-chain.jar using ant. I modify
> maven project.xml of the 2 apps and run maven default successfully. But
> there is no war file of the above apps. Look like it has not done anything.
> 

I didn't build that part of the commons-chain repository, so I'll have
to take a look ... it'll probably be over the weekend.

> Could someone show me how to build the 2 apps using commons-chain?
> Craig, do you have any preliminary instruction on the commons-chain in
> Shale?

Let's assume that you have defined the business logic for a particular
form submit as a chain named "foo" in the default catalog.  JSF will
call the action method for your submit button after validations have
been successful, and after all the model values have been updated into
your ViewController bean.  So, what you need to do for chain is build
up a Context object, and either include the ViewController bean itself
(so your business logic can pull stuff out, but that makes it
dependent on the ViewController APIs), or pass the data on in some
other fashion like a Map.  So, this is only one way to do it:

(1) Create a context to use:

    Context context = new FacesWebContext(FacesContext.getCurrentInstance());

(2) Pass in the input field values from your ViewController (this is
sorta cheating):

    context.put("viewController", this);

(3) Get an instance of the command and execute it:

    Command command = CatalogFactory.getInstance().getCommand("foo");
    command.execute(context);

(4) Pull out the logical outcome to be used for navigation and return it:
    (Assumes your business logic stored something under this attribute)

    String outcome = (String) context.get("outcome");
    return outcome;

For your business logic, you'll want to model it as either a single
Command, or as a Chain -- if you want to make the business logic
independent of web tier APIs you'd take the input context argument as
a Context and treat it like a Map to get and put stuff. 
Alternatively, you can cast it to FacesWebContext if you wanted
typesafe access to all the extra attributes that defines.

To configure your catalog of available commands and chains, you can
use the org.apache.commons.chain.web.ChainListener class (a
ServletContextListener) to set everything up from XML descriptions,
although this is not required.  That's what my examples (and the one
in struts-chain) use.

> 
> Thanks
> 
> BaTien
> DBGROUPS

Craig

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

Reply via email to