001: // .//GEN-BEGIN:_1_be
002: package org.jaffa.applications.test.modules.material.components.itemfinder.ui;
003:
004: import java.util.*;
005: import org.apache.log4j.Logger;
006: import org.apache.struts.action.ActionErrors;
007: import org.jaffa.presentation.portlet.ActionBase;
008: import org.jaffa.presentation.portlet.FormKey;
009: import org.jaffa.exceptions.FrameworkException;
010: import org.jaffa.exceptions.ApplicationExceptions;
011: import org.jaffa.exceptions.ApplicationException;
012: import org.jaffa.components.finder.*;
013: import org.jaffa.applications.test.modules.material.components.itemfinder.dto.ItemFinderInDto;
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 Action class for handling events related to the Criteria screen.
021: */
022: public class ItemFinderCriteriaAction extends ActionBase {
023: private static final Logger log = Logger
024: .getLogger(ItemFinderCriteriaAction.class);
025:
026: // .//GEN-END:_2_be
027: // .//GEN-BEGIN:_do_Search_Clicked_1_be
028: /** Creates a criteria object and invokes the displayResults() method on the component.
029: * @return The FormKey for the Results screen.
030: */
031: public FormKey do_Search_Clicked() {
032: FormKey fk = null;
033: // .//GEN-END:_do_Search_Clicked_1_be
034: // Add custom code before processing the action //GEN-FIRST:_do_Search_Clicked_1
035:
036: // .//GEN-LAST:_do_Search_Clicked_1
037: // .//GEN-BEGIN:_do_Search_Clicked_2_be
038: ItemFinderCriteriaForm myForm = (ItemFinderCriteriaForm) form;
039: ItemFinderComponent myComp = (ItemFinderComponent) myForm
040: .getComponent();
041:
042: if (myForm.doValidate(request)) {
043: try {
044: // .//GEN-END:_do_Search_Clicked_2_be
045: // Add custom code before invoking the component //GEN-FIRST:_do_Search_Clicked_2
046:
047: // .//GEN-LAST:_do_Search_Clicked_2
048: // .//GEN-BEGIN:_do_Search_Clicked_3_be
049: fk = myComp.displayResults();
050: if (FinderComponent.EXPORT_TYPE_XML.equals(myComp
051: .getExportType())) {
052: Object dto = myComp.getItemFinderOutDto();
053: if (dto == null)
054: dto = "";
055: else
056: dto = dto.toString();
057: request.setAttribute(
058: FinderComponent.ATTRIBUTE_EXPORT_TYPE_XML,
059: dto);
060: } else
061: request
062: .removeAttribute(FinderComponent.ATTRIBUTE_EXPORT_TYPE_XML);
063: } catch (ApplicationExceptions e) {
064: log.error(null, e);
065: myForm
066: .raiseError(request, ActionErrors.GLOBAL_ERROR,
067: e);
068: } catch (FrameworkException e) {
069: log.error(null, e);
070: myForm.raiseError(request, ActionErrors.GLOBAL_ERROR,
071: "error.framework.general");
072: }
073: }
074: // .//GEN-END:_do_Search_Clicked_3_be
075: // Add custom code after returning from the component //GEN-FIRST:_do_Search_Clicked_3
076:
077: // .//GEN-LAST:_do_Search_Clicked_3
078: // .//GEN-BEGIN:_do_Search_Clicked_4_be
079: // Direct User back to current form
080: if (fk == null)
081: fk = new FormKey(myForm.NAME, myComp.getComponentId());
082: return fk;
083: }
084:
085: // .//GEN-END:_do_Search_Clicked_4_be
086: // .//GEN-BEGIN:_do_Close_Clicked_1_be
087: /** Quits the component and returns the FormKey for the calling screen.
088: * @return The FormKey for the caling screen. A null will be returned, if no calling screen was specified.
089: */
090: public FormKey do_Close_Clicked() {
091: // .//GEN-END:_do_Close_Clicked_1_be
092: // Add custom code before processing the action //GEN-FIRST:_do_Close_Clicked_1
093:
094: // .//GEN-LAST:_do_Close_Clicked_1
095: // .//GEN-BEGIN:_do_Close_Clicked_2_be
096: return ((ItemFinderCriteriaForm) form).getComponent()
097: .quitAndReturnToCallingScreen();
098: }
099: // .//GEN-END:_do_Close_Clicked_2_be
100: // All the custom code goes here //GEN-FIRST:_custom
101:
102: // .//GEN-LAST:_custom
103: }
|