001: // .//GEN-BEGIN:_1_be
002: package org.jaffa.applications.test.modules.material.components.itemfinder.ui;
003:
004: import org.apache.log4j.Logger;
005: import org.jaffa.presentation.portlet.FormBase;
006: import org.jaffa.presentation.portlet.widgets.model.GridModel;
007: import org.jaffa.presentation.portlet.widgets.model.GridModelRow;
008: import org.jaffa.presentation.portlet.widgets.model.CheckBoxModel;
009: import org.jaffa.presentation.portlet.widgets.controller.UserGridController;
010: import org.jaffa.components.finder.IFinderListener;
011: import java.util.EventObject;
012: import org.jaffa.applications.test.modules.material.components.itemfinder.dto.ItemFinderOutDto;
013: import org.jaffa.applications.test.modules.material.components.itemfinder.dto.ItemFinderOutRowDto;
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 Results jsp of the ItemFinder.
021: */
022: public class ItemFinderResultsForm extends FormBase {
023: /** The name constant used for determining the corresponding jsp through the struts-config file.
024: */
025: public static final String NAME = "material_itemFinderResults";
026:
027: private static final Logger log = Logger
028: .getLogger(ItemFinderResultsForm.class);
029: private GridModel w_rows = null;
030: private boolean m_moreRecordsExist = false;
031:
032: /** Getter for property rows. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
033: * This gets the current data from the component.
034: * @return Value of property qty.
035: */
036: public GridModel getRowsWM() {
037: if (w_rows == null) {
038: w_rows = (GridModel) getWidgetCache().getModel("rows");
039: if (w_rows == null) {
040: w_rows = new GridModel();
041: getWidgetCache().addModel("rows", w_rows);
042: populateRows();
043: }
044: }
045: return w_rows;
046: }
047:
048: /** Setter for property rows. This is invoked by the servlet, when a post is done on the Results screen.
049: * It sets the selected rows on the model.
050: * @param value New value of property qty.
051: */
052: public void setRowsWV(String value) {
053: UserGridController.updateModel(value, getRowsWM(), this );
054: }
055:
056: /** Getter for property moreRecordsExist.
057: * @return Value of property moreRecordsExist.
058: */
059: public boolean getMoreRecordsExist() {
060: return m_moreRecordsExist;
061: }
062:
063: /** Setter for property moreRecordsExist.
064: * @param moreRecordsExist New value of property moreRecordsExist.
065: */
066: public void setMoreRecordsExist(boolean moreRecordsExist) {
067: m_moreRecordsExist = moreRecordsExist;
068: }
069:
070: // .//GEN-END:_2_be
071: // .//GEN-BEGIN:_populateRows_1_be
072: private void populateRows() {
073: GridModel rows = getRowsWM();
074: rows.clearRows();
075: ItemFinderOutDto outputDto = ((ItemFinderComponent) getComponent())
076: .getItemFinderOutDto();
077: if (outputDto != null) {
078: GridModelRow row;
079: for (int i = 0; i < outputDto.getRowsCount(); i++) {
080: ItemFinderOutRowDto rowDto = outputDto.getRows(i);
081: row = rows.newRow();
082: row.addElement("segregationCode", rowDto
083: .getSegregationCode());
084: row.addElement("itemId", rowDto.getItemId());
085: row.addElement("partNo", rowDto.getPartNo());
086: row.addElement("serial", rowDto.getSerial());
087: row.addElement("qty", rowDto.getQty());
088: // .//GEN-END:_populateRows_1_be
089: // Add custom code for the row //GEN-FIRST:_populateRows_1
090:
091: // .//GEN-LAST:_populateRows_1
092: // .//GEN-BEGIN:_populateRows_2_be
093: }
094: }
095: }
096:
097: // .//GEN-END:_populateRows_2_be
098: // .//GEN-BEGIN:_determineMoreRecordsExist_1_be
099: private void determineMoreRecordsExist() {
100: ItemFinderOutDto outputDto = ((ItemFinderComponent) getComponent())
101: .getItemFinderOutDto();
102: if (outputDto != null
103: && outputDto.getMoreRecordsExist() != null
104: && outputDto.getMoreRecordsExist().booleanValue())
105: m_moreRecordsExist = true;
106: else
107: m_moreRecordsExist = false;
108: }
109:
110: // .//GEN-END:_determineMoreRecordsExist_1_be
111: // .//GEN-BEGIN:_initForm_1_be
112: /** This registers a listener with the Component. */
113: public void initForm() {
114: super .initForm();
115: determineMoreRecordsExist();
116:
117: ((ItemFinderComponent) getComponent())
118: .setFinderListener(new IFinderListener() {
119: public void inquiryDone(EventObject eventObject) {
120: // .//GEN-END:_initForm_1_be
121: // Add custom code //GEN-FIRST:_initForm_1
122:
123: // .//GEN-LAST:_initForm_1
124: // .//GEN-BEGIN:_initForm_2_be
125: populateRows();
126: determineMoreRecordsExist();
127: }
128: });
129: // .//GEN-END:_initForm_2_be
130: // Add custom code //GEN-FIRST:_initForm_2
131:
132: // .//GEN-LAST:_initForm_2
133: // .//GEN-BEGIN:_initForm_3_be
134: }
135: // .//GEN-END:_initForm_3_be
136: // All the custom code goes here //GEN-FIRST:_custom
137:
138: // .//GEN-LAST:_custom
139: }
|