Search in sources :

Example 51 with FormKey

use of org.jaffa.presentation.portlet.FormKey in project jaffa-framework by jaffa-projects.

the class FinderAction method do_Search_Clicked.

/**
 * Invokes the doValidate() method and then the displayResults() method on the component.
 * @return The FormKey for the Results screen.
 */
public FormKey do_Search_Clicked() {
    FormKey fk = null;
    FinderForm myForm = (FinderForm) form;
    FinderComponent2 myComp = (FinderComponent2) myForm.getComponent();
    if (myForm.doValidate(request)) {
        try {
            myComp.performInquiry();
            fk = myComp.getResultsFormKey(true);
            if (FinderComponent2.EXPORT_TYPE_XML.equals(myComp.getExportType())) {
                Object dto = myComp.getFinderOutDto();
                if (dto == null)
                    dto = "";
                else
                    dto = dto.toString();
                request.setAttribute(FinderComponent2.ATTRIBUTE_EXPORT_TYPE_XML, dto);
            } else
                request.removeAttribute(FinderComponent2.ATTRIBUTE_EXPORT_TYPE_XML);
        } catch (ApplicationExceptions e) {
            if (log.isDebugEnabled())
                log.debug("Search Failed");
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
        } catch (FrameworkException e) {
            log.error(null, e);
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
        }
    }
    try {
        if (fk == null)
            fk = myComp.displayCriteria();
    } catch (ApplicationExceptions e) {
        if (log.isDebugEnabled())
            log.debug("Search Failed");
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
    } catch (FrameworkException e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
    }
    if (fk == null)
        fk = myComp.getCriteriaFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) FormKey(org.jaffa.presentation.portlet.FormKey)

Example 52 with FormKey

use of org.jaffa.presentation.portlet.FormKey in project jaffa-framework by jaffa-projects.

the class FinderAction method do_SaveQuery_Clicked.

public FormKey do_SaveQuery_Clicked() {
    FormKey fk = null;
    FinderForm myForm = (FinderForm) form;
    FinderComponent2 myComp = (FinderComponent2) myForm.getComponent();
    if (myForm.doValidate(request) && myForm.doValidateForSaveQuery(request)) {
        try {
            myComp.saveQuery();
            fk = myComp.displayCriteria();
        } catch (ApplicationException e) {
            if (log.isDebugEnabled())
                log.debug("ModifySearch Failed");
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
        } catch (ApplicationExceptions e) {
            if (log.isDebugEnabled())
                log.debug("ModifySearch Failed");
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
        } catch (FrameworkException e) {
            log.error(null, e);
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
        }
    }
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getCriteriaFormKey();
    return fk;
}
Also used : ApplicationException(org.jaffa.exceptions.ApplicationException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) FormKey(org.jaffa.presentation.portlet.FormKey)

Example 53 with FormKey

use of org.jaffa.presentation.portlet.FormKey in project jaffa-framework by jaffa-projects.

the class LookupAction method do_MultiSelect_Clicked.

/**
 * This will generate the MultiSelectLookupEvent object comprising the DTOs for the selected rows.
 * It will then invoke the performMultiSelectLookup() method on the component.
 * @return The FormKey for the calling screen.
 */
public FormKey do_MultiSelect_Clicked() {
    FormKey fk = null;
    LookupForm myForm = (LookupForm) form;
    LookupComponent2 myComp = (LookupComponent2) myForm.getComponent();
    try {
        // Create a collection of 'selectedRows'
        // It will assume that each row in the GridModel in the form has a CheckBoxModel keyed by LookupComponent2.MULTI_SELECT_CHECKBOX
        // Additionally, it'll assume that the FinderOutDto returned by the component has the method: 'public SomeDtoClass getRows(int i)'
        Collection selectedRows = new LinkedList();
        GridModel model = myForm.getRowsWM();
        Object finderOutDto = myComp.getFinderOutDto();
        if (finderOutDto != null && model != null && model.getRows() != null) {
            Class finderOutDtoClass = finderOutDto.getClass();
            Method method = finderOutDtoClass.getMethod("getRows", new Class[] { Integer.TYPE });
            for (Iterator itr = model.getRows().iterator(); itr.hasNext(); ) {
                GridModelRow row = (GridModelRow) itr.next();
                CheckBoxModel checkBoxModel = (CheckBoxModel) row.get(LookupComponent2.MULTI_SELECT_CHECKBOX);
                if (checkBoxModel != null && checkBoxModel.getState()) {
                    Object selectedRow = method.invoke(finderOutDto, new Object[] { new Integer(row.getRowId()) });
                    selectedRows.add(selectedRow);
                }
            }
        }
        MultiSelectLookupEvent event = new MultiSelectLookupEvent(myComp, selectedRows.toArray());
        fk = myComp.performMultiSelectLookup(request, event);
    } catch (ApplicationExceptions e) {
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
    } catch (Exception e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
    }
    if (fk == null)
        fk = myComp.getResultsFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) Method(java.lang.reflect.Method) FormKey(org.jaffa.presentation.portlet.FormKey) CheckBoxModel(org.jaffa.presentation.portlet.widgets.model.CheckBoxModel) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 54 with FormKey

use of org.jaffa.presentation.portlet.FormKey in project jaffa-framework by jaffa-projects.

the class MaintAction method do_Finish_Clicked.

/**
 * Invokes the create() or update() method on the component, depending on the mode. It then quits the component.
 * @return The FormKey for the calling screen. A null will be returned, if no calling screen was specified.
 */
public FormKey do_Finish_Clicked() {
    MaintForm myForm = (MaintForm) form;
    MaintComponent2 myComp = (MaintComponent2) myForm.getComponent();
    FormKey fk = do_Save_Clicked();
    if (myForm.hasErrors(request))
        return fk;
    else
        return myComp.quitAndReturnToCallingScreen();
}
Also used : FormKey(org.jaffa.presentation.portlet.FormKey)

Example 55 with FormKey

use of org.jaffa.presentation.portlet.FormKey in project jaffa-framework by jaffa-projects.

the class UserTimeEntryViewerAction method do_Update_Clicked.

// .//GEN-END:_do_Close_Clicked_2_be
// .//GEN-BEGIN:_do_Update_Clicked_1_be
/**
 * Invokes the updateObject() method on the component.
 * @return The FormKey for the Update screen.
 */
public FormKey do_Update_Clicked() {
    FormKey fk = null;
    // .//GEN-END:_do_Update_Clicked_1_be
    // Add custom code before processing the action //GEN-FIRST:_do_Update_Clicked_1
    // .//GEN-LAST:_do_Update_Clicked_1
    // .//GEN-BEGIN:_do_Update_Clicked_2_be
    UserTimeEntryViewerForm myForm = (UserTimeEntryViewerForm) form;
    UserTimeEntryViewerComponent myComp = (UserTimeEntryViewerComponent) myForm.getComponent();
    try {
        // .//GEN-END:_do_Update_Clicked_2_be
        // Add custom code before invoking the component //GEN-FIRST:_do_Update_Clicked_2
        // .//GEN-LAST:_do_Update_Clicked_2
        // .//GEN-BEGIN:_do_Update_Clicked_3_be
        fk = myComp.updateObject();
    } catch (ApplicationExceptions e) {
        if (log.isDebugEnabled())
            log.debug("Update Failed");
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
    } catch (FrameworkException e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
    }
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getViewerFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) FormKey(org.jaffa.presentation.portlet.FormKey)

Aggregations

FormKey (org.jaffa.presentation.portlet.FormKey)231 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)205 FrameworkException (org.jaffa.exceptions.FrameworkException)205 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)106 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)104 ApplicationException (org.jaffa.exceptions.ApplicationException)4 CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)4 File (java.io.File)3 IOException (java.io.IOException)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 Method (java.lang.reflect.Method)2 Iterator (java.util.Iterator)2 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)2 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)2 Component (org.jaffa.presentation.portlet.component.Component)2 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 AccessControlException (java.security.AccessControlException)1