KickJava   Java API By Example, From Geeks To Geeks.

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


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
23 public class WADPAttribute extends WADSearch {
24
25   public WADPAttribute() {
26   }
27
28   public WADPAttribute(Properties prop) {
29     setInfo(prop);
30     initialize();
31   }
32
33   public void initialize() {
34     addImport("searchs", "../../../../../web/js/searchs.js");
35     generateJSCode();
36     this.button = new WADFieldButton(this.imageName, getData("ColumnName"), getData("ColumnNameInp"), this.searchName, this.command);
37     this.isFieldEditable = false;
38   }
39
40   private void generateJSCode() {
41     StringBuffer JavaDoc validation = new StringBuffer JavaDoc();
42     if (getData("IsMandatory").equals("Y")) {
43       validation.append(" if (inputValue(frm.inp").append(getData("ColumnNameInp")).append(")==null || inputValue(frm.inp").append(getData("ColumnNameInp")).append(")==\"\") {\n");
44       if (getData("IsDisplayed").equals("Y")) validation.append(" frm.inp").append(getData("ColumnNameInp")).append("_R.focus();\n");
45       validation.append(" mensaje(1);\n");
46       validation.append(" return false;\n");
47       validation.append(" }\n");
48     }
49     setValidation(validation.toString());
50     setCalloutJS();
51     {
52       StringBuffer JavaDoc text = new StringBuffer JavaDoc();
53       text.append("function debugSearch(key, text, keyField) {\n");
54       text.append(" return true;\n");
55       text.append("}");
56       addJSCode("debugSearch", text.toString());
57     }
58     if (!getData("IsReadOnly").equals("Y") && !getData("IsReadOnlyTab").equals("Y")) {
59       StringBuffer JavaDoc commandScript = new StringBuffer JavaDoc();
60       StringBuffer JavaDoc text = new StringBuffer JavaDoc();
61       commandScript.append("openPAttribute(null, null, '../info/AttributeSetInstance_FS.html', ");
62       commandScript.append("null, true, 'frmMain', 'inp").append(getData("ColumnNameInp")).append("', ");
63       commandScript.append("'inp").append(getData("ColumnNameInp")).append("_R', ");
64       commandScript.append("inputValue(document.frmMain.inp").append(getData("ColumnNameInp")).append("_R), ");
65       commandScript.append("'inpIDValue', inputValue(document.frmMain.inp").append(getData("ColumnNameInp")).append("), ");
66       commandScript.append("'WindowID', inputValue(document.frmMain.inpwindowId), ");
67       commandScript.append("'inpKeyValue', inputValue(document.frmMain.inp").append(getData("ColumnNameInp")).append("), ");
68       commandScript.append("'inpwindowId', inputValue(document.frmMain.inpwindowId), ");
69       commandScript.append("'inpProduct', inputValue(document.frmMain.inpmProductId)");
70       text.append(commandScript).append(", 'Command', 'KEY'");
71       commandScript.append(");");
72       text.append(");");
73       setOnLoad("arrTeclas[arrTeclas.length] = new Teclas(\"ENTER\", \"" + text.toString() + "\", \"inp" + getData("ColumnNameInp") + "_R\", \"null\");");
74       this.imageName = "AttributeSetInstance";
75       this.searchName = getData("Name");
76       this.command = commandScript.toString();
77     }
78   }
79 }
80
Popular Tags