KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > icefaces > samples > showcase > layoutPanels > tabSetPanel > StaticTabSetBean


1 /*
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * "The contents of this file are subject to the Mozilla Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11  * License for the specific language governing rights and limitations under
12  * the License.
13  *
14  * The Original Code is ICEfaces 1.5 open source software code, released
15  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
16  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
17  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
18  *
19  * Contributor(s): _____________________.
20  *
21  * Alternatively, the contents of this file may be used under the terms of
22  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
23  * License), in which case the provisions of the LGPL License are
24  * applicable instead of those above. If you wish to allow use of your
25  * version of this file only under the terms of the LGPL License and not to
26  * allow others to use your version of this file under the MPL, indicate
27  * your decision by deleting the provisions above and replace them with
28  * the notice and other provisions required by the LGPL License. If you do
29  * not delete the provisions above, a recipient may use your version of
30  * this file under either the MPL or the LGPL License."
31  *
32  */

33 package com.icesoft.icefaces.samples.showcase.layoutPanels.tabSetPanel;
34
35 import com.icesoft.faces.component.paneltabset.PanelTabSet;
36 import com.icesoft.faces.component.paneltabset.TabChangeEvent;
37 import com.icesoft.faces.component.paneltabset.TabChangeListener;
38 import javax.faces.component.UIInput;
39 import javax.faces.component.html.HtmlSelectOneRadio;
40 import javax.faces.event.AbortProcessingException;
41 import javax.faces.event.ValueChangeEvent;
42
43 /**
44  * The StaticTabSetBean class is a backing bean for the TabbedPane showcase
45  * demonstration and is used to store the various states of the the
46  * ice:panelTabSet component. These states are visibility, tab selection and
47  * tab placement.
48  *
49  * @since 0.3.0
50  */

51 public class StaticTabSetBean implements TabChangeListener{
52     
53     /**
54      * The demo contains three tabs and thus we need three variables to store
55      * their respective rendered states.
56      */

57     private boolean tabbedPane1Visible;
58     private boolean tabbedPane2Visible;
59     private boolean tabbedPane3Visible;
60     private HtmlSelectOneRadio selectedTabObject;
61     
62     /**
63      * Tabbed placement, possible values are "top" and "bottom", the default is
64      * "bottom".
65      */

66     private String JavaDoc tabPlacement = "bottom";
67
68     // default tab focus.
69
private String JavaDoc selectedTabFocus = "1";
70
71     /**
72      * Binding used by example to listen
73      */

74     private PanelTabSet tabSet;
75     
76     /**
77      * Return the visibility of tab panel 1.
78      *
79      * @return true if tab is visible; false, otherwise.
80      */

81     public boolean isTabbedPane1Visible() {
82         return tabbedPane1Visible;
83     }
84
85     /**
86      * Sets the tabbed pane visibility
87      *
88      * @param tabbedPane1Visible true to make the panel visible; false,
89      * otherwise.
90      */

91     public void setTabbedPane1Visible(boolean tabbedPane1Visible) {
92         this.tabbedPane1Visible = tabbedPane1Visible;
93     }
94
95     /**
96      * Return the visibility of tab panel 2.
97      *
98      * @return true if tab is visible; false, otherwise.
99      */

100     public boolean isTabbedPane2Visible() {
101         return tabbedPane2Visible;
102     }
103
104     /**
105      * Sets the tabbed pane visibility
106      *
107      * @param tabbedPane2Visible true to make the panel visible; false,
108      * otherwise.
109      */

110     public void setTabbedPane2Visible(boolean tabbedPane2Visible) {
111         this.tabbedPane2Visible = tabbedPane2Visible;
112     }
113
114     /**
115      * Return the visibility of tab panel 3.
116      *
117      * @return true if tab is visible; false, otherwise.
118      */

119     public boolean isTabbedPane3Visible() {
120         return tabbedPane3Visible;
121     }
122
123     /**
124      * Sets the tabbed pane visibility
125      *
126      * @param tabbedPane3Visible true to make the panel visible; false,
127      * otherwise.
128      */

129     public void setTabbedPane3Visible(boolean tabbedPane3Visible) {
130         this.tabbedPane3Visible = tabbedPane3Visible;
131     }
132     
133     /**
134      * Gets the tabbed pane object bound to this bean.
135      *
136      * @return bound tabbed pane.
137      */

138     public PanelTabSet getTabSet() {
139         return tabSet;
140     }
141     
142     /**
143      * Set a tabbed pane object which will be bound to this object
144      *
145      * @param tabSet new PanelTabSet object.
146      */

147     public void setTabSet(PanelTabSet tabSet) {
148         this.tabSet = tabSet;
149     }
150     
151     /**
152      * Called when the tab pane focus is to be changed.
153      *
154      * @param event new value is the new selected tab index.
155      */

156     public void selectTabFocus(ValueChangeEvent event) {
157         int index = Integer.parseInt((String JavaDoc) event.getNewValue());
158         tabSet.setSelectedIndex(index);
159     }
160     
161     /**
162      * Called when a tab is selected.
163      *
164      * @param event value is the selected tab.
165      */

166     public void selectTab(ValueChangeEvent event) {
167         UIInput component = (UIInput) event.getComponent();
168         int index = 1;
169         try {
170             index = Integer.parseInt(component.getValue().toString());
171         } catch (NumberFormatException JavaDoc e) {
172             e.printStackTrace();
173         } catch (NullPointerException JavaDoc e) {
174             e.printStackTrace();
175         }
176         tabSet.setSelectedIndex(index);
177     }
178     
179     /**
180      * Gets the tab placement, either top or bottom.
181      *
182      * @return top if the tab is on the top of the component, bottom if the tab
183      * is on the bottom of the component.
184      */

185     public String JavaDoc getTabPlacement() {
186         return tabPlacement;
187     }
188
189     /**
190      * Sets the tab placement.
191      *
192      * @param tabPlacement two options top or bottom.
193      */

194     public void setTabPlacement(String JavaDoc tabPlacement) {
195         this.tabPlacement = tabPlacement;
196     }
197
198     /**
199      * Method is called when there has been a request to change the tab
200      * placement.
201      *
202      * @param event contains new tab placement data.
203      */

204     public void selectTabPlacement(ValueChangeEvent event) {
205         tabPlacement = (String JavaDoc) event.getNewValue();
206     }
207     
208      /**
209      * Called when the table binding's tab focus changes.
210      *
211      * @param tabChangeEvent used to set the tab focus.
212      * @throws AbortProcessingException An exception that may be thrown by event
213       * listeners to terminate the processing of the current event.
214      */

215     public void processTabChange(TabChangeEvent tabChangeEvent)
216             throws AbortProcessingException {
217         setSelectedTabFocus(String.valueOf(tabChangeEvent.getNewTabIndex()));
218         if (selectedTabObject != null) {
219             selectedTabObject.setSubmittedValue(selectedTabFocus);
220         }
221     }
222     
223     /**
224      * Gets the currently selected tab.
225      *
226      * @return selectedTabFocus of the currently selected tab.
227      */

228     public String JavaDoc getSelectedTabFocus() {
229         return selectedTabFocus;
230     }
231
232     /**
233      * Sets the currently selected tab.
234      *
235      * @param selectedTabFocus new selected tab.
236      */

237     public void setSelectedTabFocus(String JavaDoc selectedTabFocus) {
238         this.selectedTabFocus = selectedTabFocus;
239     }
240     
241     /**
242      * Gets the currently selected tab object.
243      *
244      * @return selectedTabObject of the currently selected tab.
245      */

246     public HtmlSelectOneRadio getBindSelectedTabObject() {
247         return selectedTabObject;
248     }
249     
250     /**
251      * Sets the cuurently selected tab object.
252      *
253      * @param selectedTabObject new HtmlSelectOneRadia object.
254      */

255     public void setBindSelectedTabObject(HtmlSelectOneRadio selectedTabObject) {
256         this.selectedTabObject = selectedTabObject;
257     }
258     
259 }
260
Popular Tags