KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > info > AttributeSetInstance


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.erpCommon.info;
20
21 import org.openbravo.base.secureApp.*;
22 import org.openbravo.xmlEngine.XmlDocument;
23 import org.openbravo.erpCommon.utility.Utility;
24 import java.io.*;
25 import javax.servlet.*;
26 import javax.servlet.http.*;
27 import org.openbravo.utils.Replace;
28
29 import org.openbravo.erpCommon.utility.SequenceIdData;
30
31 // imports for transactions
32
import org.openbravo.database.ConnectionProvider;
33 import java.sql.Connection JavaDoc;
34
35
36 public class AttributeSetInstance extends HttpSecureAppServlet {
37
38
39   public void init (ServletConfig config) {
40     super.init(config);
41     boolHist = false;
42   }
43
44   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
45     VariablesSecureApp vars = new VariablesSecureApp(request);
46
47     if (vars.commandIn("DEFAULT")) {
48       String JavaDoc strNameValue = vars.getRequestGlobalVariable("inpKeyValue", "AttributeSetInstance.instance");
49       String JavaDoc strProduct = vars.getRequestGlobalVariable("inpProduct", "AttributeSetInstance.product");
50       String JavaDoc strWindow = vars.getRequestGlobalVariable("inpwindowId", "AttributeSetInstance.windowId");
51       String JavaDoc strLocator = vars.getRequestGlobalVariable("inpLocatorId", "AttributeSetInstance.locatorId");
52       String JavaDoc strAttributeSet="";
53       String JavaDoc strProductInstance="";
54       if (strNameValue.equals("") || strNameValue.equals("0")) {
55         vars.setSessionValue("AttributeSetInstance.instance", "");
56         AttributeSetInstanceData[] data = AttributeSetInstanceData.selectProductAttr(this, strProduct);
57         if (data!=null && data.length>0 && !data[0].mAttributesetId.equals("")) {
58           strAttributeSet = data[0].mAttributesetId;
59           strProductInstance = data[0].mAttributesetinstanceId;
60         }
61       } else {
62         strAttributeSet = AttributeSetInstanceData.selectAttributeSet(this, strNameValue);
63       }
64       vars.setSessionValue("AttributeSetInstance.attribute", strAttributeSet);
65       vars.setSessionValue("AttributeSetInstance.productInstance", strProductInstance);
66       if (strAttributeSet.equals("") || strAttributeSet.equals("0")) advisePopUp(response, "Info", Utility.messageBD(this, "PAttributeNoSelection", vars.getLanguage()));
67       else printPageFS(response, vars);
68     } else if (vars.commandIn("FRAME1")) {
69       String JavaDoc strNameValue = vars.getGlobalVariable("inpInstance", "AttributeSetInstance.instance", "");
70       String JavaDoc strAttributeSet = vars.getGlobalVariable("inpAttribute", "AttributeSetInstance.attribute");
71       String JavaDoc strProductInstance = vars.getGlobalVariable("inpProductInstance", "AttributeSetInstance.productInstance", "");
72       String JavaDoc strWindowId = vars.getGlobalVariable("inpwindowId", "AttributeSetInstance.windowId", "");
73       String JavaDoc strLocator = vars.getGlobalVariable("inpLocatorId", "AttributeSetInstance.locatorId", "");
74       String JavaDoc strProduct = vars.getGlobalVariable("inpProduct", "AttributeSetInstance.product", "");
75       String JavaDoc strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId);
76       if (log4j.isDebugEnabled()) log4j.debug("strNameValue: " + strNameValue);
77       if (!strAttributeSet.equals("")) printPageFrame1(response, vars, strNameValue, strAttributeSet, strProductInstance, strWindowId, strLocator, strIsSOTrx, strProduct);
78       else advisePopUp(response, "Info", Utility.messageBD(this, "PAttributeNoSelection", vars.getLanguage()));
79     } else if (vars.commandIn("FRAME2")) {
80       printPageFrame2(response, vars);
81     } else if (vars.commandIn("SAVE")) {
82       String JavaDoc strAttributeSet = vars.getRequiredStringParameter("inpAttribute");
83       String JavaDoc strInstance = vars.getStringParameter("inpInstance");
84       String JavaDoc strWindowId = vars.getStringParameter("inpwindowId");
85       String JavaDoc strProduct = vars.getRequestGlobalVariable("inpProduct", "AttributeSetInstance.product");
86       String JavaDoc strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId);
87       String JavaDoc strMessage = writeFields(this, vars, AttributeSetInstanceData.select(this, strAttributeSet), strAttributeSet, strInstance, strWindowId, strIsSOTrx, strProduct);
88       vars.setSessionValue("AttributeSetInstance.attribute", strAttributeSet);
89       vars.setSessionValue("AttributeSetInstance.message", strMessage);
90       response.sendRedirect(strDireccion + request.getServletPath() + "?Command=FRAME1");
91     } else pageErrorPopUp(response);
92   }
93
94   String JavaDoc getDescription(VariablesSecureApp vars, AttributeSetInstanceData[] data, String JavaDoc strIsSOTrx) {
95     if (data==null || data.length==0) return "";
96     String JavaDoc description="";
97     try {
98       //AttributeSet header
99
String JavaDoc serno = "", lot="", guaranteedate="", lockDescription="", description_first="";
100       if (data[0].islot.equals("Y")) {
101         lot = vars.getStringParameter("inplot");
102         if (!data[0].mLotctlId.equals("") && strIsSOTrx.equals("N")) {
103           return "";
104         }
105         description_first += (description_first.equals("")?"":"_") + "L" + lot;
106       }
107       if (data[0].isserno.equals("Y")) {
108         serno = vars.getStringParameter("inpserno");
109         if (!data[0].mSernoctlId.equals("") && strIsSOTrx.equals("N")) {
110           return "";
111         }
112         description_first += (description_first.equals("")?"":"_") + "#" + serno;
113       }
114       if (data[0].isguaranteedate.equals("Y")) {
115         guaranteedate = vars.getStringParameter("inpguaranteedate");
116         description_first += (description_first.equals("")?"":"_") + guaranteedate;
117       }
118       if (data[0].islockable.equals("Y")) {
119         lockDescription = vars.getStringParameter("inplockDescription");
120         description_first += (description_first.equals("")?"":"_") + lockDescription;
121       }
122
123       if (!data[0].elementname.equals("")) {
124         for (int i=0;i<data.length;i++) {
125           String JavaDoc strValue = "";
126           if (data[i].ismandatory.equals("Y")) strValue = vars.getRequiredStringParameter("inp" + replace(data[i].elementname));
127           else strValue = vars.getStringParameter("inp" + replace(data[i].elementname));
128           String JavaDoc strDescValue = strValue;
129           if (data[i].islist.equals("Y")) strDescValue = AttributeSetInstanceData.selectAttributeValue(this, strValue);
130           description += (description.equals("")?"":"_") + strDescValue;
131         }
132       }
133       if (!description_first.equals("")) description += (description.equals("")?"":"_") + description_first;
134     } catch (ServletException e) {
135       return "";
136     }
137     return description;
138   }
139
140   String JavaDoc writeFields(ConnectionProvider cp, VariablesSecureApp vars, AttributeSetInstanceData[] data, String JavaDoc strAttributeSet, String JavaDoc strInstance, String JavaDoc strWindow, String JavaDoc strIsSOTrx, String JavaDoc strProduct) throws ServletException {
141     String JavaDoc strMessage = "OK";
142     String JavaDoc strNewInstance="";
143     if (data==null || data.length==0) return Utility.messageBD(this, "FindZeroRecords", vars.getLanguage());
144
145     boolean isinstance = !AttributeSetInstanceData.isInstanceAttribute(this, strAttributeSet).equals("0");
146     String JavaDoc strDescription = getDescription(vars, data, strIsSOTrx);
147     String JavaDoc strLocator = vars.getStringParameter("inpLocatorId");
148     String JavaDoc strExistingInstance = "";
149     Connection JavaDoc conn = null;
150     try {
151       conn = cp.getTransactionConnection();
152       String JavaDoc serno = "", lot="", guaranteedate="", locked="", lockDescription="", description="", description_first="";
153       if (data[0].islot.equals("Y")) {
154         lot = vars.getStringParameter("inplot");
155         if (!data[0].mLotctlId.equals("") && strIsSOTrx.equals("N")) {
156           lot = AttributeSetInstanceData.selectNextLot(this, data[0].mLotctlId);
157           AttributeSetInstanceData.updateLotSequence(conn, this, vars.getUser(), data[0].mLotctlId);
158         }
159         description_first += (description_first.equals("")?"":"_") + "L" + lot;
160       }
161       if (data[0].isserno.equals("Y")) {
162         serno = vars.getStringParameter("inpserno");
163         if (!data[0].mSernoctlId.equals("") && strIsSOTrx.equals("N")) {
164           serno = AttributeSetInstanceData.selectNextSerNo(conn, this, data[0].mSernoctlId);
165           AttributeSetInstanceData.updateSerNoSequence(conn, this, vars.getUser(), data[0].mSernoctlId);
166         }
167         description_first += (description_first.equals("")?"":"_") + "#" + serno;
168       }
169       if (data[0].isguaranteedate.equals("Y")) {
170         guaranteedate = vars.getStringParameter("inpguaranteedate");
171         description_first += (description_first.equals("")?"":"_") + guaranteedate;
172       }
173       if (data[0].islockable.equals("Y")) {
174         locked = vars.getStringParameter("inpislocked", "N");
175         lockDescription = vars.getStringParameter("inplockDescription");
176         description_first += (description_first.equals("")?"":"_") + lockDescription;
177       }
178       if (!isinstance) {
179         strNewInstance = AttributeSetInstanceData.hasIdentical(this, strDescription,data[0].mAttributesetId);
180       }
181       boolean hasToUpdate = false;
182       if ((!strInstance.equals("")) && (isinstance)) {//Si if it's existant and requestable, it edits it
183
hasToUpdate = true;
184         if (AttributeSetInstanceData.updateHeader(conn, this, vars.getUser(), data[0].mAttributesetId, serno, lot, guaranteedate, data[0].mLotctlId, locked, lockDescription, strInstance) == 0) {
185           AttributeSetInstanceData.insertHeader(conn, this, strInstance, vars.getClient(), vars.getOrg(), vars.getUser(), data[0].mAttributesetId, serno, lot, guaranteedate, data[0].mLotctlId, locked, lockDescription);
186         }
187       } else if ((isinstance) || (strNewInstance.equals(""))) { //New or editable,if it's requestable or doesn't exist the identic, then it inserts a new one
188
hasToUpdate = true;
189         strNewInstance = SequenceIdData.getSequence(this, "M_AttributeSetInstance", vars.getClient());
190         AttributeSetInstanceData.insertHeader(conn, this, strNewInstance, vars.getClient(), vars.getOrg(), vars.getUser(), data[0].mAttributesetId, serno, lot, guaranteedate, data[0].mLotctlId, locked, lockDescription);
191       }
192       if (hasToUpdate) {
193         if (!data[0].elementname.equals("")) {
194           for (int i=0;i<data.length;i++) {
195             String JavaDoc strValue = "";
196             if (data[i].ismandatory.equals("Y")) strValue = vars.getRequiredStringParameter("inp" + replace(data[i].elementname));
197             else strValue = vars.getStringParameter("inp" + replace(data[i].elementname));
198             String JavaDoc strDescValue = strValue;
199             if (data[i].islist.equals("Y")) strDescValue = AttributeSetInstanceData.selectAttributeValue(this, strValue);
200             if (!strNewInstance.equals("")) {
201               if (AttributeSetInstanceData.update(conn, this, vars.getUser(), (data[i].islist.equals("Y")?strValue:""), strDescValue, strNewInstance, data[i].mAttributeId) == 0) {
202                 AttributeSetInstanceData.insert(conn, this, strNewInstance, data[i].mAttributeId, vars.getClient(), vars.getOrg(), vars.getUser(), (data[i].islist.equals("Y")?strValue:""), strDescValue);
203               }
204             } else {
205               if (AttributeSetInstanceData.update(conn, this, vars.getUser(), (data[i].islist.equals("Y")?strValue:""), strDescValue, strInstance, data[i].mAttributeId) == 0) {
206                 AttributeSetInstanceData.insert(conn, this, strInstance, data[i].mAttributeId, vars.getClient(), vars.getOrg(), vars.getUser(), (data[i].islist.equals("Y")?strValue:""), strDescValue);
207               }
208             }
209             description += (description.equals("")?"":"_") + strDescValue;
210           }
211         }
212         if (!description_first.equals("")) description += (description.equals("")?"":"_") + description_first;
213         AttributeSetInstanceData.updateHeaderDescription(conn, this, vars.getUser(), description, (strNewInstance.equals("")?strInstance:strNewInstance));
214       }
215       releaseCommitConnection(conn);
216       vars.setSessionValue("AttributeSetInstance.instance", (strNewInstance.equals("")?strInstance:strNewInstance));
217     } catch(Exception JavaDoc e) {
218       try {
219         releaseRollbackConnection(conn);
220       } catch (Exception JavaDoc ignored) {}
221       strMessage = Utility.messageBD(this, "ProcessFailed", vars.getLanguage());
222       log4j.error("Rollback in transaction: " + e);
223     }
224     return strMessage;
225   }
226
227   void printPageFS(HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException {
228     if (log4j.isDebugEnabled()) log4j.debug("Output: Frame Set del buscador de atributos");
229     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/info/AttributeSetInstance_FS").createXmlDocument();
230
231     response.setContentType("text/html; charset=UTF-8");
232     PrintWriter out = response.getWriter();
233     out.println(xmlDocument.print());
234     out.close();
235   }
236
237   void printPageFrame1(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strInstance, String JavaDoc strAttributeSet, String JavaDoc strProductInstance, String JavaDoc strWindowId, String JavaDoc strLocator, String JavaDoc strIsSOTrx, String JavaDoc strProduct) throws IOException, ServletException {
238     if (log4j.isDebugEnabled()) log4j.debug("Output: Frame 1 of the attributes seeker");
239     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/info/AttributeSetInstance_F1").createXmlDocument();
240
241     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
242     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
243     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
244     xmlDocument.setParameter("attribute", strAttributeSet);
245     xmlDocument.setParameter("windowId", strWindowId);
246     xmlDocument.setParameter("locatorId", strLocator);
247     String JavaDoc message = vars.getSessionValue("AttributeSetInstance.message");
248     vars.removeSessionValue("AttributeSetInstance.message");
249     if (!message.equals("")) {
250       if (!message.equals("OK")) message = "alert('" + message + "');";
251       else message = "printMessage('');";
252     }
253     xmlDocument.setParameter("body", message);
254     if (strInstance.equals("") && AttributeSetInstanceData.isInstanceAttribute(this, strAttributeSet).equals("0")) strInstance = strProductInstance;
255
256     xmlDocument.setParameter("instance", strInstance);
257     xmlDocument.setParameter("product", strProduct);
258     String JavaDoc strName = Utility.messageBD(this, "Description", vars.getLanguage());
259     xmlDocument.setParameter("nameDescription", strName.equals("")?"Description":strName);
260     xmlDocument.setParameter("description", AttributeSetInstanceData.selectDescription(this, (strInstance.equals("")?strProductInstance:strInstance)));
261     AttributeSetInstanceData[] data = AttributeSetInstanceData.select(this, strAttributeSet);
262     xmlDocument.setParameter("data", generateHtml(vars, data, AttributeSetInstanceData.selectInstance(this, (strInstance.equals("")?strProductInstance:strInstance)), strInstance, strIsSOTrx));
263     xmlDocument.setParameter("script", generateScript(vars, data));
264     response.setContentType("text/html; charset=UTF-8");
265     PrintWriter out = response.getWriter();
266     out.println(xmlDocument.print());
267     out.close();
268   }
269
270   String JavaDoc instanceValue(AttributeSetInstanceData[] instanceData, String JavaDoc strAttributeId, boolean isList) {
271     if (instanceData==null || instanceData.length==0) return "";
272     for (int i=0;i<instanceData.length;i++) {
273       if (instanceData[i].mAttributeId.equals(strAttributeId)) {
274         if (isList) return instanceData[i].mAttributevalueId;
275         else return instanceData[i].value;
276       }
277     }
278     return "";
279   }
280
281   String JavaDoc generateScript(VariablesSecureApp vars, AttributeSetInstanceData[] fields) throws IOException, ServletException {
282     if (fields==null || fields.length==0) return "";
283     StringBuffer JavaDoc strHtml = new StringBuffer JavaDoc();
284     strHtml.append("function onloadFunctions() {\n");
285     if (!fields[0].elementname.equals("")) {
286       for (int i=0;i<fields.length;i++) {
287         if (fields[i].islist.equals("Y")) strHtml.append(" new TypeAheadCombo(\"").append(replace(fields[i].elementname)).append("\");\n");
288       }
289     }
290     strHtml.append(" return true;\n");
291     strHtml.append("}\n");
292     return strHtml.toString();
293   }
294
295   String JavaDoc generateHtml(VariablesSecureApp vars, AttributeSetInstanceData[] fields, AttributeSetInstanceData[] instanceData, String JavaDoc strAttributeInstance, String JavaDoc strIsSOTrx) throws IOException, ServletException {
296     if (fields==null || fields.length==0) return "";
297     StringBuffer JavaDoc strHtml = new StringBuffer JavaDoc();
298     boolean isInstance=false;
299     if (!fields[0].elementname.equals("")) {
300       for (int i=0;i<fields.length;i++) {
301         if (fields[i].isinstanceattribute.equals("Y")) isInstance=true;
302         strHtml.append("<tr><td class=\"TitleCell\"><span class=\"LabelText\">");
303         String JavaDoc strName = Utility.messageBD(this, fields[i].elementname, vars.getLanguage());
304         strHtml.append(strName.equals("")?fields[i].elementname:strName);
305         strHtml.append("</span></td>\n");
306         strHtml.append("<td class=\"LabelText\">");
307         String JavaDoc strValue = instanceValue(instanceData, fields[i].mAttributeId, fields[i].islist.equals("Y"));
308         if (fields[i].islist.equals("Y")) {
309           strHtml.append("<select ");
310           strHtml.append("name=\"inp" + replace(fields[i].elementname) + "\" ");
311           strHtml.append("class=\"Combo");
312           if (fields[i].ismandatory.equals("Y")) strHtml.append("Key");
313           strHtml.append(" Combo_OneCell_width\" ");
314           strHtml.append(" id=\"").append(replace(fields[i].elementname)).append("\">");
315           AttributeSetInstanceData[] data = AttributeSetInstanceData.selectList(this, fields[i].mAttributeId);
316           if (!fields[i].ismandatory.equals("Y")) strHtml.append("<option value=\"\"></option>\n");
317           for (int j=0;j<data.length;j++) {
318             strHtml.append("<option value=\"");
319             strHtml.append(data[j].value);
320             strHtml.append("\" ");
321             if (data[j].value.equalsIgnoreCase(strValue)) strHtml.append("selected");
322             strHtml.append(">");
323             strHtml.append(data[j].name);
324             strHtml.append("</option>\n");
325           }
326           strHtml.append("</select>");
327         } else {
328           strHtml.append("<textarea ");
329           strHtml.append("name=\"inp" + replace(fields[i].elementname) + "\" ");
330           strHtml.append("class=\"dojoValidateValid TextArea_OneCell_width TextArea_OneCell_height");
331           if (fields[i].ismandatory.equals("Y")) strHtml.append(" required");
332           strHtml.append("\"");
333           strHtml.append(">");
334           strHtml.append(strValue);
335           strHtml.append("</textarea>");
336         }
337         strHtml.append("</td></tr>\n");
338       }
339     }
340     if (fields[0].islot.equals("Y")) {
341       isInstance=true;
342       strHtml.append("<tr><td class=\"TitleCell\"><span class=\"LabelText\">");
343       String JavaDoc strName = Utility.messageBD(this, "Lot", vars.getLanguage());
344       strHtml.append(strName.equals("")?"Lot":strName);
345       strHtml.append("</span></td>\n");
346       strHtml.append("<td ");
347       strHtml.append("class=\"TextBox_ContentCell\"><input type=\"text\" ");
348       strHtml.append("name=\"inplot\" ");
349       strHtml.append("maxlength=\"20\" ");
350       strHtml.append("class=\"dojoValidateValid TextBox_OneCell_width");
351       //strHtml.append("onkeydown=\"auto_completar_numero(this, true, true);return true;\" ");
352
if (!fields[0].mLotctlId.equals("") && strIsSOTrx.equals("N")) {
353         strHtml.append(" readonly\" readonly=true ");
354       } else {
355         strHtml.append("\" ");
356       }
357       if (strAttributeInstance.equals("") && strIsSOTrx.equals("N")) strHtml.append("value=\"" + AttributeSetInstanceData.selectNextLot(this, fields[0].mLotctlId) + "\" ");
358       else strHtml.append("value=\"" + ((instanceData!=null && instanceData.length>0)?instanceData[0].lot:"") + "\" ");
359       strHtml.append("></td></tr>\n");
360     }
361     if (fields[0].isserno.equals("Y")) {
362       isInstance=true;
363       strHtml.append("<tr><td class=\"TitleCell\"><span class=\"LabelText\">");
364       String JavaDoc strName = Utility.messageBD(this, "SerNo", vars.getLanguage());
365       strHtml.append(strName.equals("")?"SerNo":strName);
366       strHtml.append("</span></td>\n");
367       strHtml.append("<td class=\"TextBox_ContentCell\"><input type=\"text\" ");
368       strHtml.append("name=\"inpserno\" ");
369       strHtml.append("maxlength=\"20\" ");
370       strHtml.append("class=\"dojoValidateValid TextBox_OneCell_width");
371       //strHtml.append("onkeydown=\"auto_completar_numero(this, true, true);return true;\" ");
372
if (!fields[0].mSernoctlId.equals("") && strIsSOTrx.equals("N")) {
373         strHtml.append(" readonly\" readonly=true ");
374       } else {
375         strHtml.append("\" ");
376       }
377       if (strAttributeInstance.equals("") && strIsSOTrx.equals("N")) strHtml.append("value=\"" + AttributeSetInstanceData.selectNextSerNo(this, fields[0].mSernoctlId) + "\" ");
378       else strHtml.append("value=\"" + ((instanceData!=null && instanceData.length>0)?instanceData[0].serno:"") + "\" ");
379       strHtml.append("></td></tr>\n");
380     }
381     if (fields[0].isguaranteedate.equals("Y")) {
382       isInstance=true;
383       strHtml.append("<tr><td class=\"TitleCell\"><span class=\"LabelText\">");
384       String JavaDoc strName = Utility.messageBD(this, "GuaranteeDate", vars.getLanguage());
385       strHtml.append(strName.equals("")?"GuaranteeDate":strName);
386       strHtml.append("</span></td>\n");
387       strHtml.append("<TD class=\"TextBox_btn_ContentCell\">");
388       strHtml.append("<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" summary=\"\" style=\"padding-top: 0px;\">");
389       strHtml.append("<TR>");
390       strHtml.append("<TD class=\"TextBox_ContentCell\">");
391       strHtml.append("<INPUT dojotype=\"openbravo:DateTextbox\" displayformat=\"xx\" saveformat=\"yy\" class=\"TextBox_btn_OneCell_width\" type=\"text\" name=\"inpDateFrom\" id=\"paramDateFrom\" size=\"10\" maxlength=\"10\" value=\"\" onkeyup=\"auto_complete_date(this.textbox);return true;\"></INPUT><SCRIPT>djConfig.searchIds.push(\"paramDateFrom\");</SCRIPT>");
392       strHtml.append("</TD>");
393       strHtml.append("<TD class=\"FieldButton_ContentCell\">");
394       strHtml.append("<a class=\"FieldButtonLink\" HREF=\"#\"");
395       strHtml.append("onfocus=\"this.className='FieldButtonLink_hover'; window.status='Show calendar'; return true;\"");
396       strHtml.append("onblur=\"this.className='FieldButtonLink'; window.status=''; return true;\"");
397       strHtml.append("onkeypress=\"this.className='FieldButtonLink_active'; return true;\"");
398       strHtml.append("onkeyup=\"this.className='FieldButtonLink_hover'; return true;\"");
399       strHtml.append("onClick=\"showCalendar('frmMain.");
400       strHtml.append("inpguaranteedate', ");
401       strHtml.append("document.frmMain.inpguaranteedate.value, false, '%d-%m-%Y');return false;\">");
402       strHtml.append("<table class=\"FieldButton\"");
403       strHtml.append("onmousedown=\"this.className='FieldButton_active'; return true;\"");
404       strHtml.append("onmouseup=\"this.className='FieldButton'; return true;\"");
405       strHtml.append("onmouseover=\"this.className='FieldButton_hover'; window.status='Show calendar'; return true;\"");
406       strHtml.append("onmouseout=\"this.className='FieldButton'; window.status=''; return true;\">");
407       strHtml.append("<tr>");
408       strHtml.append("<td class=\"FieldButton_bg\">");
409       strHtml.append("<img alt=\"Calendar\" class=\"FieldButton_Icon FieldButton_Icon_Calendar\" title=\"Calendar\" SRC=\"").append(strReplaceWith).append("/images/blank.gif\" border=\"0\"\"/>");
410       strHtml.append("</td>");
411       strHtml.append("</tr>");
412       strHtml.append("</table>");
413       strHtml.append("</a>");
414       strHtml.append("</TD>");
415       strHtml.append("</TR>");
416       strHtml.append("</TABLE>");
417       strHtml.append("</TD>");
418       strHtml.append("</TR>");
419     }
420     if (fields[0].islockable.equals("Y")) {
421       isInstance=true;
422       strHtml.append("<tr><td class=\"TitleCell\"><span class=\"LabelText\">");
423       String JavaDoc strName = Utility.messageBD(this, "IsLocked", vars.getLanguage());
424       strHtml.append(strName.equals("")?"IsLocked":strName);
425       strHtml.append("</span></td>\n");
426       strHtml.append("<td class=\"Radio_Check_ContentCell\"><input type=\"checkbox\" ");
427       strHtml.append("name=\"inpislocked\" ");
428       strHtml.append("value=\"Y\" ");
429       if (instanceData!=null && instanceData.length>0 && instanceData[0].islocked.equals("Y")) strHtml.append("checked ");
430       strHtml.append("></td></tr>\n");
431       strHtml.append("<tr><td class=\"TitleCell\"><span class=\"LabelText\">");
432       strName = Utility.messageBD(this, "LockDescription", vars.getLanguage());
433       strHtml.append(strName.equals("")?"LockDescription":strName);
434       strHtml.append("</span></td>\n");
435       strHtml.append("<td>");
436       strHtml.append("<textarea ");
437       strHtml.append("name=\"inplockDescription\" ");
438       strHtml.append("class=\"dojoValidateValid TextArea_OneCell_width TextArea_OneCell_height");
439       strHtml.append("\">");
440       if (instanceData!=null && instanceData.length>0) strHtml.append(instanceData[0].lockDescription);
441       strHtml.append("</textarea>");
442       strHtml.append("</td></tr>\n");
443     }
444     return strHtml.toString();
445   }
446
447   String JavaDoc replace(String JavaDoc strIni) {
448     //delete characters: " ","&",","
449
return Replace.replace(Replace.replace(Replace.replace(Replace.replace(Replace.replace(Replace.replace(strIni, "#", "")," ",""),"&",""),",",""),"(",""),")","");
450   }
451
452   void printPageFrame2(HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException {
453     if (log4j.isDebugEnabled()) log4j.debug("Output: Frame 3 of the attributes seeker");
454     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/info/AttributeSetInstance_F2").createXmlDocument();
455     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
456     response.setContentType("text/html; charset=UTF-8");
457     PrintWriter out = response.getWriter();
458     out.println(xmlDocument.print());
459     out.close();
460   }
461
462   public String JavaDoc getServletInfo() {
463     return "Servlet that presents attributes seeker";
464   } // end of getServletInfo() method
465
}
466
467
Popular Tags