KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ThrowawayBean.java,v 1.5 2003/10/27 11:00:41 thusted Exp $
3  * $Source: /cvsroot/mav/maverick/src/java/org/infohazard/maverick/ctl/ThrowawayBean.java,v $
4  */

5
6 package org.infohazard.maverick.ctl;
7
8 import org.apache.commons.beanutils.BeanUtils;
9
10 /**
11  * Note: While not formally deprecated, use of this class is
12  * discouraged. You should use ThrowawayBean2 instead.
13  *
14  * ThrowawayBean is a throwaway controller which populates its
15  * bean properties using the Apache BeanUtils. Note that the
16  * default implementation of model() returns "this".
17  */

18 public class ThrowawayBean extends Throwaway
19 {
20     /**
21      * This is the method you should override to implement application logic.
22      * Default implementation just returns "success".
23      */

24     protected String JavaDoc perform() throws Exception JavaDoc
25     {
26         return SUCCESS;
27     }
28
29     /**
30      * <p>Default implementation returns "this". This is the typical use case
31      * of html form processing; the controller itself will have setters and
32      * getters for the various fields. See the FriendBook sample for several
33      * examples of this idiom.</p>
34      *
35      * <p>It's certainly not necessary to use the controller-as-model pattern.
36      * You can return specific objects to custom-tailor the "shape" of the
37      * model.</p>
38      */

39     public Object JavaDoc model()
40     {
41         return this;
42     }
43
44     /**
45      */

46     protected final String JavaDoc rawPerform() throws Exception JavaDoc
47     {
48         BeanUtils.populate(this, this.getRequest().getParameterMap());
49         BeanUtils.populate(this, this.getCtx().getControllerParams());
50
51         return this.perform();
52     }
53 }
Popular Tags