KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tutorial > components > ArrayViewer


1 // Copyright 2004 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package tutorial.components;
16
17 import net.sf.tapestry.BaseComponent;
18 import net.sf.tapestry.IBinding;
19 import net.sf.tapestry.IRequestCycle;
20 import net.sf.tapestry.components.Foreach;
21
22 /**
23  * Simple ArrayViewer object, for the Component chapter of the Tutorial
24  * @author neil clayton
25  */

26 public class ArrayViewer extends BaseComponent {
27     /**
28      * Return the bound heading if there is one, else return a static default heading
29      */

30     public String JavaDoc getHeading() {
31         IBinding binding = (IBinding)getBinding("heading");
32         if(binding.getObject() != null) {
33             return binding.getObject().toString();
34         }
35         return heading;
36     }
37
38     /**
39      * Sets the heading.
40      * @param heading The heading to set
41      */

42     public void setHeading(String JavaDoc heading) {
43         this.heading = heading;
44     }
45
46     /**
47      * @see net.sf.tapestry.AbstractComponent#cleanupAfterRender(IRequestCycle)
48      */

49     protected void cleanupAfterRender(IRequestCycle cycle) {
50         source = null;
51         heading = "Array Viewer";
52         super.cleanupAfterRender(cycle);
53     }
54
55     /**
56      * Returns the source.
57      * @return Object
58      */

59     public Object JavaDoc getSource() {
60         return source;
61     }
62
63     /**
64      * Sets the source.
65      * @param source The source to set
66      */

67     public void setSource(Object JavaDoc source) {
68         this.source = source;
69     }
70
71     private String JavaDoc heading = "Array Viewer";
72     private Object JavaDoc source;
73 }
74
Popular Tags