KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infohazard > maverick > ctl > ThrowawayBean2


1 /*
2  * $Id: ThrowawayBean2.java,v 1.3 2003/02/19 22:50:47 lhoriman Exp $
3  * $Source: /cvsroot/mav/maverick/src/java/org/infohazard/maverick/ctl/ThrowawayBean2.java,v $
4  */

5
6 package org.infohazard.maverick.ctl;
7
8 import org.apache.commons.beanutils.BeanUtils;
9
10 /**
11  * <p>ThrowawayBean2 is a throwaway controller which populates its
12  * bean properties using the Apache BeanUtils. Note that unless
13  * you set the model yourself, the default will be "this".</p>
14  
15  * <p>This is the typical use case
16  * of html form processing; the controller itself will have setters and
17  * getters for the various fields. See the FriendBook sample for several
18  * examples of this idiom.</p>
19  *
20  * <p>It's certainly not necessary to use the controller-as-model pattern.
21  * You can set specific objects to custom-tailor the "shape" of the
22  * model.</p>
23  */

24 public class ThrowawayBean2 extends Throwaway2
25 {
26     /**
27      * This is the method you should override to implement application logic.
28      * Default implementation just returns "success".
29      */

30     protected String JavaDoc perform() throws Exception JavaDoc
31     {
32         return SUCCESS;
33     }
34
35     /**
36      */

37     protected final String JavaDoc go() throws Exception JavaDoc
38     {
39         BeanUtils.populate(this, this.getCtx().getRequest().getParameterMap());
40         BeanUtils.populate(this, this.getCtx().getControllerParams());
41
42         this.getCtx().setModel(this);
43         
44         return this.perform();
45     }
46 }
Popular Tags