001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)SelectConfigureDataset.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package charting.configure;
030:
031: import org.openesb.tools.charting.persist.ChartApplicationBeansContainer;
032: import org.openesb.tools.charting.persist.DataBean;
033: import org.openesb.tools.extchart.jfchart.Chart;
034: import org.openesb.tools.extchart.jfchart.data.DataAccess;
035: import org.openesb.tools.extchart.jfchart.data.SampleDemoDataAccess;
036: import org.openesb.tools.extchart.property.JFChartConstants;
037: import com.sun.rave.web.ui.appbase.AbstractPageBean;
038: import com.sun.web.ui.component.Body;
039: import com.sun.web.ui.component.Button;
040: import com.sun.web.ui.component.DropDown;
041: import com.sun.web.ui.component.Form;
042: import com.sun.web.ui.component.Head;
043: import com.sun.web.ui.component.Html;
044: import com.sun.web.ui.component.Label;
045: import com.sun.web.ui.component.Link;
046: import com.sun.web.ui.component.Page;
047: import com.sun.web.ui.component.TextArea;
048: import com.sun.web.ui.component.TextField;
049: import com.sun.web.ui.model.Option;
050: import com.sun.web.ui.model.SingleSelectOptionsList;
051: import java.util.ArrayList;
052: import java.util.Iterator;
053: import java.util.Map;
054: import javax.faces.FacesException;
055: import javax.faces.event.ValueChangeEvent;
056: import java.util.logging.Logger;
057:
058: /**
059: * <p>Page bean that corresponds to a similarly named JSP page. This
060: * class contains component definitions (and initialization code) for
061: * all components that you have defined on this page, as well as
062: * lifecycle methods and event handlers where you may add behavior
063: * to respond to incoming events.</p>
064: */
065: public class SelectConfigureDataset extends AbstractPageBean {
066: // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
067: private int __placeholder;
068:
069: /**
070: * <p>Automatically managed component initialization. <strong>WARNING:</strong>
071: * This method is automatically generated, so any user-specified code inserted
072: * here is subject to being replaced.</p>
073: */
074: private void _init() throws Exception {
075: dropDown4DefaultOptions
076: .setOptions(new com.sun.web.ui.model.Option[] {
077: new com.sun.web.ui.model.Option("item1",
078: "asdasd"),
079: new com.sun.web.ui.model.Option("item2",
080: "asdasdasdsadas"),
081: new com.sun.web.ui.model.Option("item3",
082: "Item 3") });
083: }
084:
085: private Page page1 = new Page();
086:
087: public Page getPage1() {
088: return page1;
089: }
090:
091: public void setPage1(Page p) {
092: this .page1 = p;
093: }
094:
095: private Html html1 = new Html();
096:
097: public Html getHtml1() {
098: return html1;
099: }
100:
101: public void setHtml1(Html h) {
102: this .html1 = h;
103: }
104:
105: private Head head1 = new Head();
106:
107: public Head getHead1() {
108: return head1;
109: }
110:
111: public void setHead1(Head h) {
112: this .head1 = h;
113: }
114:
115: private Link link1 = new Link();
116:
117: public Link getLink1() {
118: return link1;
119: }
120:
121: public void setLink1(Link l) {
122: this .link1 = l;
123: }
124:
125: private Body body1 = new Body();
126:
127: public Body getBody1() {
128: return body1;
129: }
130:
131: public void setBody1(Body b) {
132: this .body1 = b;
133: }
134:
135: private Form form1 = new Form();
136:
137: public Form getForm1() {
138: return form1;
139: }
140:
141: public void setForm1(Form f) {
142: this .form1 = f;
143: }
144:
145: private DropDown dropDown1 = new DropDown();
146:
147: public DropDown getDropDown1() {
148: return dropDown1;
149: }
150:
151: public void setDropDown1(DropDown dd) {
152: this .dropDown1 = dd;
153: }
154:
155: private Label label1 = new Label();
156:
157: public Label getLabel1() {
158: return label1;
159: }
160:
161: public void setLabel1(Label l) {
162: this .label1 = l;
163: }
164:
165: private Button button1 = new Button();
166:
167: public Button getButton1() {
168: return button1;
169: }
170:
171: public void setButton1(Button b) {
172: this .button1 = b;
173: }
174:
175: private Label label3 = new Label();
176:
177: public Label getLabel3() {
178: return label3;
179: }
180:
181: public void setLabel3(Label l) {
182: this .label3 = l;
183: }
184:
185: private DropDown dropDown2 = new DropDown();
186:
187: public DropDown getDropDown2() {
188: return dropDown2;
189: }
190:
191: public void setDropDown2(DropDown dd) {
192: this .dropDown2 = dd;
193: }
194:
195: private DropDown dropDown4 = new DropDown();
196:
197: public DropDown getDropDown4() {
198: return dropDown4;
199: }
200:
201: public void setDropDown4(DropDown dd) {
202: this .dropDown4 = dd;
203: }
204:
205: private SingleSelectOptionsList dropDown4DefaultOptions = new SingleSelectOptionsList();
206:
207: public SingleSelectOptionsList getDropDown4DefaultOptions() {
208: return dropDown4DefaultOptions;
209: }
210:
211: public void setDropDown4DefaultOptions(SingleSelectOptionsList ssol) {
212: this .dropDown4DefaultOptions = ssol;
213: }
214:
215: private Label label2 = new Label();
216:
217: public Label getLabel2() {
218: return label2;
219: }
220:
221: public void setLabel2(Label l) {
222: this .label2 = l;
223: }
224:
225: private TextField textField1 = new TextField();
226:
227: public TextField getTextField1() {
228: return textField1;
229: }
230:
231: public void setTextField1(TextField tf) {
232: this .textField1 = tf;
233: }
234:
235: // </editor-fold>
236:
237: /**
238: * <p>Construct a new Page bean instance.</p>
239: */
240: public SelectConfigureDataset() {
241: }
242:
243: /**
244: * <p>Callback method that is called whenever a page is navigated to,
245: * either directly via a URL, or indirectly via page navigation.
246: * Customize this method to acquire resources that will be needed
247: * for event handlers and lifecycle methods, whether or not this
248: * page is performing post back processing.</p>
249: *
250: * <p>Note that, if the current request is a postback, the property
251: * values of the components do <strong>not</strong> represent any
252: * values submitted with this request. Instead, they represent the
253: * property values that were saved for this view when it was rendered.</p>
254: */
255: public void init() {
256: // Perform initializations inherited from our superclass
257: super .init();
258: // Perform application initialization that must complete
259: // *before* managed components are initialized
260: // TODO - add your own initialiation code here
261:
262: // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
263: // Initialize automatically managed components
264: // *Note* - this logic should NOT be modified
265: try {
266: _init();
267: } catch (Exception e) {
268: log("SelectConfigureDataset Initialization Failure", e);
269: throw e instanceof FacesException ? (FacesException) e
270: : new FacesException(e);
271: }
272:
273: // </editor-fold>
274: // Perform application initialization that must complete
275: // *after* managed components are initialized
276: // TODO - add your own initialization code here
277: }
278:
279: /**
280: * <p>Callback method that is called after the component tree has been
281: * restored, but before any event processing takes place. This method
282: * will <strong>only</strong> be called on a postback request that
283: * is processing a form submit. Customize this method to allocate
284: * resources that will be required in your event handlers.</p>
285: */
286: public void preprocess() {
287: }
288:
289: /**
290: * <p>Callback method that is called just before rendering takes place.
291: * This method will <strong>only</strong> be called for the page that
292: * will actually be rendered (and not, for example, on a page that
293: * handled a postback and then navigated to a different page). Customize
294: * this method to allocate resources that will be required for rendering
295: * this page.</p>
296: */
297: public void prerender() {
298: }
299:
300: /**
301: * <p>Callback method that is called after rendering is completed for
302: * this request, if <code>init()</code> was called (regardless of whether
303: * or not this was the page that was actually rendered). Customize this
304: * method to release resources acquired in the <code>init()</code>,
305: * <code>preprocess()</code>, or <code>prerender()</code> methods (or
306: * acquired during execution of an event handler).</p>
307: */
308: public void destroy() {
309: }
310:
311: private static Logger mLogger = Logger
312: .getLogger("/configure/SelectConfigureDataset.jsp");
313:
314: public void dropDown1_processValueChange(ValueChangeEvent event) {
315: String dbID = (String) this .getDropDown1().getSelected();
316: mLogger.info("The selected value is " + dbID);
317: mLogger.info("The selected value is1 " + event.getNewValue());
318: mLogger.info("The selected value is2 " + event.getOldValue());
319: // TODO: Replace with your code
320: // do nothing.
321:
322: }
323:
324: public SingleSelectOptionsList getChartOptions() {
325: ArrayList al = new ArrayList();
326: String dbID = (String) this .getDropDown1().getSelected();
327: mLogger.info("The id is " + dbID);
328: DataBean dbBean = getChartApplicationBeansContainer()
329: .getDataBeanByID(dbID);
330: String dsType = dbBean.getDataSetType();
331: Map m = Chart.getAllowedChartsForDatasetType(dsType);
332: Option[] options = new Option[m.size()];
333: Iterator iter = m.keySet().iterator();
334: int ind = 0;
335: while (iter.hasNext()) {
336: String key = (String) iter.next();
337: String val = (String) m.get(key);
338: Option opt1 = new Option();
339: opt1.setLabel(val);
340: opt1.setValue(key);
341: options[ind++] = opt1;
342: }
343: SingleSelectOptionsList l = new SingleSelectOptionsList();
344:
345: l.setOptions(options);
346: return l;
347:
348: }
349:
350: SingleSelectOptionsList l = null;
351:
352: public SingleSelectOptionsList getOptions() {
353:
354: //ArrayList al = new ArrayList();
355: if (l == null) {
356: l = new SingleSelectOptionsList();
357: Map m = getChartApplicationBeansContainer()
358: .getAllDataBeans();
359: Option[] options = new Option[m.size()];
360: Iterator iter = m.values().iterator();
361: int ind = 0;
362: String selVal = null;
363: while (iter.hasNext()) {
364: DataBean bean = (DataBean) iter.next();
365: String val = bean.getDisplayName();
366: String key = bean.getID();
367: Option opt1 = new Option();
368: opt1.setLabel(val);
369: opt1.setValue(key);
370: selVal = key;
371: options[ind++] = opt1;
372: }
373:
374: l.setOptions(options);
375: l.setSelectedValue(selVal);
376: }
377: return l;
378: }
379:
380: private ChartApplicationBeansContainer getChartApplicationBeansContainer() {
381: return (ChartApplicationBeansContainer) getBean("ChartApplicationBeansContainer");
382:
383: }
384:
385: public String button1_action() {
386: // TODO: Process the button click action. Return value is a navigation
387: // case name where null will return to the same page.
388: String dbID = (String) this .getDropDown1().getSelected();
389: String cType = (String) this .getDropDown2().getSelected();
390: //String q = (String)this.getTextArea1().getText();
391: DataBean dbBean = getChartApplicationBeansContainer()
392: .getDataBeanByID(dbID);
393: DataAccess da = dbBean.getDataAccessObject();
394: //SQLDataAccess sqlDA = new SQLDataAccess(dsType,q);
395: //SampleDemoDataAccess da = new SampleDemoDataAccess(dsType);
396: getChartApplicationBeansContainer()
397: .getCurrentChartBeanOnEditor().setChartDataBeanID(
398: dbBean.getID());
399: getChartApplicationBeansContainer()
400: .getCurrentChartBeanOnEditor()
401: .setChartPropertiesForDataset(dbBean.getDataSetType(),
402: cType);
403:
404: mLogger.info("Returning success after creating data bean");
405: return "success";
406: }
407:
408: public void textArea1_processValueChange(ValueChangeEvent event) {
409: // TODO: Replace with your code
410:
411: }
412:
413: public void dropDown4_processValueChange(ValueChangeEvent event) {
414: mLogger.info("dropdown 4 pressed");
415: }
416:
417: public void textField1_processValueChange(ValueChangeEvent event) {
418: }
419: }
|