KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > wad > controls > WADYesNo


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18 */

19 package org.openbravo.wad.controls;
20
21 import java.util.*;
22 import org.openbravo.xmlEngine.XmlDocument;
23
24 public class WADYesNo extends WADControl {
25
26   public WADYesNo() {
27   }
28
29   public WADYesNo(Properties prop) {
30     setInfo(prop);
31     initialize();
32   }
33
34   public void initialize() {
35     generateJSCode();
36   }
37
38   private void generateJSCode() {
39     setValidation("");
40     setCalloutJS();
41   }
42
43   public String JavaDoc getType() {
44     return "Radio_Check";
45   }
46
47   public String JavaDoc editMode() {
48     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADYesNo").createXmlDocument();
49
50     xmlDocument.setParameter("columnName", getData("ColumnName"));
51     xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
52
53     if (getData("IsReadOnly").equals("Y") || getData("IsReadOnlyTab").equals("Y") || getData("IsUpdateable").equals("N")) xmlDocument.setParameter("disabled", "Y");
54     else xmlDocument.setParameter("disabled", "N");
55     if (getData("IsMandatory").equals("Y")) xmlDocument.setParameter("required", "true");
56     else xmlDocument.setParameter("required", "false");
57
58     xmlDocument.setParameter("callout", getOnChangeCode());
59
60     return replaceHTML(xmlDocument.print());
61   }
62
63   public String JavaDoc newMode() {
64     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADYesNo").createXmlDocument();
65
66     xmlDocument.setParameter("columnName", getData("ColumnName"));
67     xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
68
69     if (getData("IsReadOnly").equals("Y") || getData("IsReadOnlyTab").equals("Y")) xmlDocument.setParameter("disabled", "Y");
70     else xmlDocument.setParameter("disabled", "N");
71     if (getData("IsMandatory").equals("Y")) xmlDocument.setParameter("required", "true");
72     else xmlDocument.setParameter("required", "false");
73
74     xmlDocument.setParameter("callout", getOnChangeCode());
75
76     return replaceHTML(xmlDocument.print());
77   }
78
79   public String JavaDoc toXml() {
80     StringBuffer JavaDoc text = new StringBuffer JavaDoc();
81     if (getData("IsParameter").equals("Y")) {
82       if (getData("IsDisplayed").equals("N")) {
83         text.append("<PARAMETER id=\"").append(getData("ColumnName")).append("\" name=\"").append(getData("ColumnName")).append("\" attribute=\"value\"/>");
84       } else {
85         text.append("<PARAMETER id=\"").append(getData("ColumnName")).append("\" name=\"").append(getData("ColumnName")).append("\" boolean=\"checked\" withId=\"paramCheck\"/>");
86       }
87     } else {
88       if (getData("IsDisplayed").equals("N")) {
89         text.append("<FIELD id=\"").append(getData("ColumnName")).append("\" attribute=\"value\">");
90         text.append(getData("ColumnName")).append("</FIELD>");
91       } else {
92         text.append("<FIELD id=\"").append(getData("ColumnName")).append("\" boolean=\"checked\" withId=\"paramCheck\">");
93         text.append(getData("ColumnName")).append("</FIELD>");
94       }
95     }
96     return text.toString();
97   }
98
99   public String JavaDoc toJava() {
100     return "";
101   }
102 }
103
Popular Tags