001: // .//GEN-BEGIN:_1_be
002: package org.jaffa.applications.test.modules.material.components.itemfinder.ui;
003:
004: import javax.servlet.http.HttpServletRequest;
005: import java.util.*;
006: import org.apache.log4j.Logger;
007: import org.jaffa.metadata.*;
008: import org.jaffa.datatypes.*;
009: import org.jaffa.components.finder.*;
010: import org.jaffa.presentation.portlet.widgets.model.*;
011: import org.jaffa.presentation.portlet.widgets.controller.*;
012: import org.jaffa.util.StringHelper;
013: import org.jaffa.applications.test.modules.material.domain.ItemMeta;
014:
015: // .//GEN-END:_1_be
016: // Add additional imports//GEN-FIRST:_imports
017:
018: // .//GEN-LAST:_imports
019: // .//GEN-BEGIN:_2_be
020: /** The FormBean class to support the Criteria jsp of the ItemFinder.
021: */
022: public class ItemFinderCriteriaForm extends FinderCriteriaForm {
023:
024: /** The name constant used for determining the corresponding jsp through the struts-config file.
025: */
026: public static final String NAME = "material_itemFinderCriteria";
027:
028: private static Logger log = Logger
029: .getLogger(ItemFinderCriteriaForm.class);
030: private EditBoxModel w_segregationCode = null;
031: private DropDownModel w_segregationCodeDd = null;
032: private EditBoxModel w_partNo = null;
033: private DropDownModel w_partNoDd = null;
034: private EditBoxModel w_serial = null;
035: private DropDownModel w_serialDd = null;
036: private EditBoxModel w_qty = null;
037: private DropDownModel w_qtyDd = null;
038:
039: // .//GEN-END:_2_be
040: // .//GEN-BEGIN:segregationCode_1_be
041: /** Getter for property segregationCode.
042: * @return Value of property segregationCode.
043: */
044: public String getSegregationCode() {
045: return ((ItemFinderComponent) getComponent())
046: .getSegregationCode();
047: }
048:
049: /** Setter for property segregationCode.
050: * @param segregationCode New value of property segregationCode.
051: */
052: public void setSegregationCode(String segregationCode) {
053: ((ItemFinderComponent) getComponent())
054: .setSegregationCode(segregationCode);
055: }
056:
057: /** Getter for property segregationCode. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
058: * @return Value of property segregationCode.
059: */
060: public EditBoxModel getSegregationCodeWM() {
061: if (w_segregationCode == null) {
062: w_segregationCode = (EditBoxModel) getWidgetCache()
063: .getModel("segregationCode");
064: if (w_segregationCode == null) {
065: if (getSegregationCode() != null)
066: w_segregationCode = new EditBoxModel(
067: getSegregationCode());
068: else
069: w_segregationCode = new EditBoxModel();
070: w_segregationCode
071: .setStringCase(((StringFieldMetaData) ItemMeta.META_SC)
072: .getCaseType());
073: // .//GEN-END:segregationCode_1_be
074: // Add custom code //GEN-FIRST:segregationCode_1
075:
076: // .//GEN-LAST:segregationCode_1
077: // .//GEN-BEGIN:segregationCode_2_be
078: getWidgetCache().addModel("segregationCode",
079: w_segregationCode);
080: }
081: }
082: return w_segregationCode;
083: }
084:
085: /** Setter for property segregationCode. This is invoked by the servlet, when a post is done on the Criteria screen.
086: * @param value New value of property segregationCode.
087: */
088: public void setSegregationCodeWV(String value) {
089: EditBoxController.updateModel(value, getSegregationCodeWM());
090: }
091:
092: /** Getter for DropDown property segregationCode.
093: * @return Value of property segregationCodeDd.
094: */
095: public String getSegregationCodeDd() {
096: return ((ItemFinderComponent) getComponent())
097: .getSegregationCodeDd();
098: }
099:
100: /** Setter for DropDown property segregationCode.
101: * @param segregationCodeDd New value of property segregationCodeDd.
102: */
103: public void setSegregationCodeDd(String segregationCodeDd) {
104: ((ItemFinderComponent) getComponent())
105: .setSegregationCodeDd(segregationCodeDd);
106: }
107:
108: /** Getter for DropDown property segregationCode. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
109: * @return Value of property segregationCodeDd.
110: */
111: public DropDownModel getSegregationCodeDdWM() {
112: if (w_segregationCodeDd == null) {
113: w_segregationCodeDd = (DropDownModel) getWidgetCache()
114: .getModel("segregationCodeDd");
115: if (w_segregationCodeDd == null) {
116: if (getSegregationCodeDd() != null)
117: w_segregationCodeDd = new DropDownModel(
118: getSegregationCodeDd());
119: else
120: w_segregationCodeDd = new DropDownModel(
121: CriteriaField.RELATIONAL_EQUALS);
122: Map optionsMap = CriteriaDropDownOptions
123: .getAllCriteriaDropDownOptions();
124: Set options = optionsMap.entrySet();
125: for (Iterator i = options.iterator(); i.hasNext();) {
126: Map.Entry option = (Map.Entry) i.next();
127: w_segregationCodeDd.addOption((String) option
128: .getValue(), (String) option.getKey());
129: }
130: getWidgetCache().addModel("segregationCodeDd",
131: w_segregationCodeDd);
132: }
133: }
134: return w_segregationCodeDd;
135: }
136:
137: /** Setter for DropDown property segregationCode. This is invoked by the servlet, when a post is done on the Criteria screen.
138: * @param value New value of property segregationCodeDd.
139: */
140: public void setSegregationCodeDdWV(String value) {
141: DropDownController.updateModel(value, getSegregationCodeDdWM());
142: }
143:
144: // .//GEN-END:segregationCode_2_be
145: // .//GEN-BEGIN:partNo_1_be
146: /** Getter for property partNo.
147: * @return Value of property partNo.
148: */
149: public String getPartNo() {
150: return ((ItemFinderComponent) getComponent()).getPartNo();
151: }
152:
153: /** Setter for property partNo.
154: * @param partNo New value of property partNo.
155: */
156: public void setPartNo(String partNo) {
157: ((ItemFinderComponent) getComponent()).setPartNo(partNo);
158: }
159:
160: /** Getter for property partNo. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
161: * @return Value of property partNo.
162: */
163: public EditBoxModel getPartNoWM() {
164: if (w_partNo == null) {
165: w_partNo = (EditBoxModel) getWidgetCache().getModel(
166: "partNo");
167: if (w_partNo == null) {
168: if (getPartNo() != null)
169: w_partNo = new EditBoxModel(getPartNo());
170: else
171: w_partNo = new EditBoxModel();
172: w_partNo
173: .setStringCase(((StringFieldMetaData) ItemMeta.META_PART)
174: .getCaseType());
175: // .//GEN-END:partNo_1_be
176: // Add custom code //GEN-FIRST:partNo_1
177:
178: // .//GEN-LAST:partNo_1
179: // .//GEN-BEGIN:partNo_2_be
180: getWidgetCache().addModel("partNo", w_partNo);
181: }
182: }
183: return w_partNo;
184: }
185:
186: /** Setter for property partNo. This is invoked by the servlet, when a post is done on the Criteria screen.
187: * @param value New value of property partNo.
188: */
189: public void setPartNoWV(String value) {
190: EditBoxController.updateModel(value, getPartNoWM());
191: }
192:
193: /** Getter for DropDown property partNo.
194: * @return Value of property partNoDd.
195: */
196: public String getPartNoDd() {
197: return ((ItemFinderComponent) getComponent()).getPartNoDd();
198: }
199:
200: /** Setter for DropDown property partNo.
201: * @param partNoDd New value of property partNoDd.
202: */
203: public void setPartNoDd(String partNoDd) {
204: ((ItemFinderComponent) getComponent()).setPartNoDd(partNoDd);
205: }
206:
207: /** Getter for DropDown property partNo. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
208: * @return Value of property partNoDd.
209: */
210: public DropDownModel getPartNoDdWM() {
211: if (w_partNoDd == null) {
212: w_partNoDd = (DropDownModel) getWidgetCache().getModel(
213: "partNoDd");
214: if (w_partNoDd == null) {
215: if (getPartNoDd() != null)
216: w_partNoDd = new DropDownModel(getPartNoDd());
217: else
218: w_partNoDd = new DropDownModel(
219: CriteriaField.RELATIONAL_EQUALS);
220: Map optionsMap = CriteriaDropDownOptions
221: .getAllCriteriaDropDownOptions();
222: Set options = optionsMap.entrySet();
223: for (Iterator i = options.iterator(); i.hasNext();) {
224: Map.Entry option = (Map.Entry) i.next();
225: w_partNoDd.addOption((String) option.getValue(),
226: (String) option.getKey());
227: }
228: getWidgetCache().addModel("partNoDd", w_partNoDd);
229: }
230: }
231: return w_partNoDd;
232: }
233:
234: /** Setter for DropDown property partNo. This is invoked by the servlet, when a post is done on the Criteria screen.
235: * @param value New value of property partNoDd.
236: */
237: public void setPartNoDdWV(String value) {
238: DropDownController.updateModel(value, getPartNoDdWM());
239: }
240:
241: // .//GEN-END:partNo_2_be
242: // .//GEN-BEGIN:serial_1_be
243: /** Getter for property serial.
244: * @return Value of property serial.
245: */
246: public String getSerial() {
247: return ((ItemFinderComponent) getComponent()).getSerial();
248: }
249:
250: /** Setter for property serial.
251: * @param serial New value of property serial.
252: */
253: public void setSerial(String serial) {
254: ((ItemFinderComponent) getComponent()).setSerial(serial);
255: }
256:
257: /** Getter for property serial. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
258: * @return Value of property serial.
259: */
260: public EditBoxModel getSerialWM() {
261: if (w_serial == null) {
262: w_serial = (EditBoxModel) getWidgetCache().getModel(
263: "serial");
264: if (w_serial == null) {
265: if (getSerial() != null)
266: w_serial = new EditBoxModel(getSerial());
267: else
268: w_serial = new EditBoxModel();
269: w_serial
270: .setStringCase(((StringFieldMetaData) ItemMeta.META_SERIAL)
271: .getCaseType());
272: // .//GEN-END:serial_1_be
273: // Add custom code //GEN-FIRST:serial_1
274:
275: // .//GEN-LAST:serial_1
276: // .//GEN-BEGIN:serial_2_be
277: getWidgetCache().addModel("serial", w_serial);
278: }
279: }
280: return w_serial;
281: }
282:
283: /** Setter for property serial. This is invoked by the servlet, when a post is done on the Criteria screen.
284: * @param value New value of property serial.
285: */
286: public void setSerialWV(String value) {
287: EditBoxController.updateModel(value, getSerialWM());
288: }
289:
290: /** Getter for DropDown property serial.
291: * @return Value of property serialDd.
292: */
293: public String getSerialDd() {
294: return ((ItemFinderComponent) getComponent()).getSerialDd();
295: }
296:
297: /** Setter for DropDown property serial.
298: * @param serialDd New value of property serialDd.
299: */
300: public void setSerialDd(String serialDd) {
301: ((ItemFinderComponent) getComponent()).setSerialDd(serialDd);
302: }
303:
304: /** Getter for DropDown property serial. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
305: * @return Value of property serialDd.
306: */
307: public DropDownModel getSerialDdWM() {
308: if (w_serialDd == null) {
309: w_serialDd = (DropDownModel) getWidgetCache().getModel(
310: "serialDd");
311: if (w_serialDd == null) {
312: if (getSerialDd() != null)
313: w_serialDd = new DropDownModel(getSerialDd());
314: else
315: w_serialDd = new DropDownModel(
316: CriteriaField.RELATIONAL_EQUALS);
317: Map optionsMap = CriteriaDropDownOptions
318: .getAllCriteriaDropDownOptions();
319: Set options = optionsMap.entrySet();
320: for (Iterator i = options.iterator(); i.hasNext();) {
321: Map.Entry option = (Map.Entry) i.next();
322: w_serialDd.addOption((String) option.getValue(),
323: (String) option.getKey());
324: }
325: getWidgetCache().addModel("serialDd", w_serialDd);
326: }
327: }
328: return w_serialDd;
329: }
330:
331: /** Setter for DropDown property serial. This is invoked by the servlet, when a post is done on the Criteria screen.
332: * @param value New value of property serialDd.
333: */
334: public void setSerialDdWV(String value) {
335: DropDownController.updateModel(value, getSerialDdWM());
336: }
337:
338: // .//GEN-END:serial_2_be
339: // .//GEN-BEGIN:qty_1_be
340: /** Getter for property qty.
341: * @return Value of property qty.
342: */
343: public String getQty() {
344: return ((ItemFinderComponent) getComponent()).getQty();
345: }
346:
347: /** Setter for property qty.
348: * @param qty New value of property qty.
349: */
350: public void setQty(String qty) {
351: ((ItemFinderComponent) getComponent()).setQty(qty);
352: }
353:
354: /** Getter for property qty. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
355: * @return Value of property qty.
356: */
357: public EditBoxModel getQtyWM() {
358: if (w_qty == null) {
359: w_qty = (EditBoxModel) getWidgetCache().getModel("qty");
360: if (w_qty == null) {
361: if (getQty() != null)
362: w_qty = new EditBoxModel(getQty());
363: else
364: w_qty = new EditBoxModel();
365: // .//GEN-END:qty_1_be
366: // Add custom code //GEN-FIRST:qty_1
367:
368: // .//GEN-LAST:qty_1
369: // .//GEN-BEGIN:qty_2_be
370: getWidgetCache().addModel("qty", w_qty);
371: }
372: }
373: return w_qty;
374: }
375:
376: /** Setter for property qty. This is invoked by the servlet, when a post is done on the Criteria screen.
377: * @param value New value of property qty.
378: */
379: public void setQtyWV(String value) {
380: EditBoxController.updateModel(value, getQtyWM());
381: }
382:
383: /** Getter for DropDown property qty.
384: * @return Value of property qtyDd.
385: */
386: public String getQtyDd() {
387: return ((ItemFinderComponent) getComponent()).getQtyDd();
388: }
389:
390: /** Setter for DropDown property qty.
391: * @param qtyDd New value of property qtyDd.
392: */
393: public void setQtyDd(String qtyDd) {
394: ((ItemFinderComponent) getComponent()).setQtyDd(qtyDd);
395: }
396:
397: /** Getter for DropDown property qty. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
398: * @return Value of property qtyDd.
399: */
400: public DropDownModel getQtyDdWM() {
401: if (w_qtyDd == null) {
402: w_qtyDd = (DropDownModel) getWidgetCache()
403: .getModel("qtyDd");
404: if (w_qtyDd == null) {
405: if (getQtyDd() != null)
406: w_qtyDd = new DropDownModel(getQtyDd());
407: else
408: w_qtyDd = new DropDownModel(
409: CriteriaField.RELATIONAL_EQUALS);
410: Map optionsMap = CriteriaDropDownOptions
411: .getNumericalCriteriaDropDownOptions();
412: Set options = optionsMap.entrySet();
413: for (Iterator i = options.iterator(); i.hasNext();) {
414: Map.Entry option = (Map.Entry) i.next();
415: w_qtyDd.addOption((String) option.getValue(),
416: (String) option.getKey());
417: }
418: getWidgetCache().addModel("qtyDd", w_qtyDd);
419: }
420: }
421: return w_qtyDd;
422: }
423:
424: /** Setter for DropDown property qty. This is invoked by the servlet, when a post is done on the Criteria screen.
425: * @param value New value of property qtyDd.
426: */
427: public void setQtyDdWV(String value) {
428: DropDownController.updateModel(value, getQtyDdWM());
429: }
430:
431: // .//GEN-END:qty_2_be
432: // .//GEN-BEGIN:_doValidate_1_be
433: /** This method should be invoked to ensure a valid state of the FormBean. It will validate the data in the models and set the corresponding properties.
434: * Errors will be raised in the FormBean, if any validation fails.
435: * @param request The request stream
436: * @return A true indicates validations went through successfully. */
437: public boolean doValidate(HttpServletRequest request) {
438: boolean valid = super .doValidate(request);
439: String value = null;
440: StringBuffer buf = null;
441:
442: value = getSegregationCodeWM().getValue();
443: if (value != null && value.trim().length() == 0)
444: value = null;
445: setSegregationCode(value);
446: setSegregationCodeDd(getSegregationCodeDdWM().getValue());
447:
448: value = getPartNoWM().getValue();
449: if (value != null && value.trim().length() == 0)
450: value = null;
451: setPartNo(value);
452: setPartNoDd(getPartNoDdWM().getValue());
453:
454: value = getSerialWM().getValue();
455: if (value != null && value.trim().length() == 0)
456: value = null;
457: setSerial(value);
458: setSerialDd(getSerialDdWM().getValue());
459:
460: value = getQtyWM().getValue();
461: if (value != null && value.trim().length() == 0)
462: value = null;
463: setQty(value);
464: setQtyDd(getQtyDdWM().getValue());
465:
466: // .//GEN-END:_doValidate_1_be
467: // Add custom code //GEN-FIRST:_doValidate_1
468:
469: // .//GEN-LAST:_doValidate_1
470: // .//GEN-BEGIN:_doValidate_2_be
471: return valid;
472: }
473: // .//GEN-END:_doValidate_2_be
474: // All the custom code goes here //GEN-FIRST:_custom
475:
476: // .//GEN-LAST:_custom
477: }
|