Search in sources :

Example 16 with CheckBoxModel

use of org.jaffa.presentation.portlet.widgets.model.CheckBoxModel in project jaffa-framework by jaffa-projects.

the class FormSelectionMaintenanceComponent method validateFields.

protected void validateFields(GridModelRow row, ApplicationExceptions appExps, boolean showForm) throws ApplicationExceptions, FrameworkException {
    String additionalComponent = null;
    CheckBoxModel checkBoxModel = (CheckBoxModel) row.get("select");
    if ((checkBoxModel != null && checkBoxModel.getState()) || showForm) {
        // Check copies are greater then zero
        EditBoxModel mCopies = (EditBoxModel) row.get("copies");
        if (mCopies != null && !showForm) {
            if (mCopies.getValue() != null && mCopies.getValue().length() > 0) {
                int iCopies = Integer.parseInt(mCopies.getValue());
                if (iCopies < 1) {
                    appExps.add(new FormSelectionException(FormSelectionException.INVALID_COPIES));
                }
            } else {
                appExps.add(new FormSelectionException(FormSelectionException.INVALID_COPIES));
            }
        }
        if (!showForm) {
            // check either printer, email or publish has value
            EditBoxModel mPrinter = (EditBoxModel) row.get("printer");
            EditBoxModel mEmail = (EditBoxModel) row.get("email");
            CheckBoxModel mPublish = (CheckBoxModel) row.get("publish");
            if ((mPrinter.getValue() == null) && (mEmail.getValue() == null) && (mPublish.getState() != true) && !showForm) {
                appExps.add(new FormSelectionException(FormSelectionException.INVALID_OUTPUT_DESTINATION));
            }
        }
        // Validate AdditionalData exist or not
        try {
            FormSelectionMaintenanceOutRowDto rowDto = (FormSelectionMaintenanceOutRowDto) row.get("object");
            additionalComponent = rowDto.getAdditionalDataComponent();
            if (additionalComponent != null) {
                Component comp = (Component) run(additionalComponent);
                BeanUtils.setProperty(comp, getKey1(), getValue1());
                if (getKey2() != null) {
                    BeanUtils.setProperty(comp, getKey2(), getValue2());
                }
                if (getKey3() != null) {
                    BeanUtils.setProperty(comp, getKey3(), getValue3());
                }
                if (getKey4() != null) {
                    BeanUtils.setProperty(comp, getKey4(), getValue4());
                }
                if (getKey5() != null) {
                    BeanUtils.setProperty(comp, getKey5(), getValue5());
                }
                if (getKey6() != null) {
                    BeanUtils.setProperty(comp, getKey6(), getValue6());
                }
                if (comp instanceof IAdditionalData) {
                    ((IAdditionalData) comp).validate();
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Additional Data Interface not implemented ");
                    }
                }
            }
        } catch (SecurityException se) {
            log.error("SecurityException Occurred ", se);
            appExps.add(new FormSelectionException(FormSelectionException.SECURITY_EXCEPTION));
        } catch (IllegalAccessException e) {
            log.error("IllegalAccessException Occurred ", e);
        } catch (InvocationTargetException e) {
            log.error("InvocationTargetException Occurred ", e);
        } catch (IllegalArgumentException e) {
            log.error("IllegalArgumentException Occurred ", e);
        } catch (ApplicationExceptions applicationException) {
            log.debug("Catch : Application Exception from additional data component");
            if (applicationException != null && applicationException.size() > 0) {
                for (Iterator i = applicationException.iterator(); i.hasNext(); ) {
                    ApplicationException appEx = (ApplicationException) i.next();
                    appExps.add(appEx);
                }
            }
        } catch (FrameworkException frameworkException) {
            throw frameworkException;
        }
    }
}
Also used : FormSelectionException(org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) org.jaffa.components.maint(org.jaffa.components.maint) InvocationTargetException(java.lang.reflect.InvocationTargetException) CheckBoxModel(org.jaffa.presentation.portlet.widgets.model.CheckBoxModel) ApplicationException(org.jaffa.exceptions.ApplicationException) FormSelectionMaintenanceOutRowDto(org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto) EditBoxModel(org.jaffa.presentation.portlet.widgets.model.EditBoxModel) Iterator(java.util.Iterator) IAdditionalData(org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalData) Component(org.jaffa.presentation.portlet.component.Component) RiaWrapperComponent(org.jaffa.presentation.portlet.component.RiaWrapperComponent)

Example 17 with CheckBoxModel

use of org.jaffa.presentation.portlet.widgets.model.CheckBoxModel in project jaffa-framework by jaffa-projects.

the class PrinterDefinitionViewerForm method getRemoteWM.

/**
 * Getter for property remote. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
 * @return Value of property remote.
 */
public CheckBoxModel getRemoteWM() {
    CheckBoxModel remote = (CheckBoxModel) getWidgetCache().getModel("remote");
    if (remote == null) {
        PrinterDefinitionViewerOutDto outputDto = ((PrinterDefinitionViewerComponent) getComponent()).getPrinterDefinitionViewerOutDto();
        remote = new CheckBoxModel(outputDto != null && outputDto.getRemote() != null ? outputDto.getRemote() : Boolean.FALSE);
        getWidgetCache().addModel("remote", remote);
    }
    return remote;
}
Also used : PrinterDefinitionViewerOutDto(org.jaffa.modules.printing.components.printerdefinitionviewer.dto.PrinterDefinitionViewerOutDto) CheckBoxModel(org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)

Example 18 with CheckBoxModel

use of org.jaffa.presentation.portlet.widgets.model.CheckBoxModel in project jaffa-framework by jaffa-projects.

the class PrinterOutputTypeViewerForm method getDirectPrintingWM.

/**
 * Getter for property directPrinting. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
 * @return Value of property directPrinting.
 */
public CheckBoxModel getDirectPrintingWM() {
    CheckBoxModel directPrinting = (CheckBoxModel) getWidgetCache().getModel("directPrinting");
    if (directPrinting == null) {
        PrinterOutputTypeViewerOutDto outputDto = ((PrinterOutputTypeViewerComponent) getComponent()).getPrinterOutputTypeViewerOutDto();
        directPrinting = new CheckBoxModel(outputDto != null && outputDto.getDirectPrinting() != null ? outputDto.getDirectPrinting() : Boolean.FALSE);
        getWidgetCache().addModel("directPrinting", directPrinting);
    }
    return directPrinting;
}
Also used : PrinterOutputTypeViewerOutDto(org.jaffa.modules.printing.components.printeroutputtypeviewer.dto.PrinterOutputTypeViewerOutDto) CheckBoxModel(org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)

Example 19 with CheckBoxModel

use of org.jaffa.presentation.portlet.widgets.model.CheckBoxModel in project jaffa-framework by jaffa-projects.

the class FileExplorerForm method addToTree.

private boolean addToTree(GridModel m, File path, int row, int level) {
    boolean any = false;
    try {
        FileExplorerBean fb = ((FileExplorerComponent) getComponent()).retrieveFiles(path);
        FileExplorerBean.FolderBean[] folders = fb.getFolders();
        if (folders != null && folders.length > 0)
            for (int i = 0; i < folders.length; i++) {
                any = true;
                GridModelRow r = m.newRow(row++);
                if (log.isDebugEnabled())
                    log.debug("Added Model Row : /" + folders[i].getName());
                r.put(COL_NAME, folders[i].getName());
                r.put(COL_LEVEL, new Integer(level));
                r.put(COL_LAST_MODIFIED, folders[i].getLastModified());
                r.put(COL_EXPANDED, new Boolean(false));
                r.put(COL_PARENT, new Boolean(true));
                r.put(COL_DISPLAYED, new Boolean(true));
                r.put(COL_FILE, folders[i].getFile());
            }
        FileExplorerBean.FileBean[] files = fb.getFiles();
        if (files != null && files.length > 0)
            for (int i = 0; i < files.length; i++) {
                any = true;
                GridModelRow r = m.newRow(row++);
                if (log.isDebugEnabled())
                    log.debug("Added Model Row : " + files[i].getName());
                r.put(COL_NAME, files[i].getName());
                r.put(COL_LEVEL, new Integer(level));
                r.put(COL_LAST_MODIFIED, files[i].getLastModified());
                r.put(COL_SIZE, files[i].getFormattedSize());
                if (files[i].isDeleteAllowed())
                    r.put(COL_SELECTED, new CheckBoxModel());
                r.put(COL_EXPANDED, new Boolean(false));
                r.put(COL_PARENT, new Boolean(false));
                r.put(COL_DISPLAYED, new Boolean(true));
                r.put(COL_FILE, files[i].getFile());
                r.put(COL_DOWNLOAD, new Boolean(files[i].isAccessable()));
            }
    } catch (ApplicationExceptions e) {
        log.error(null, e);
    } catch (FrameworkException e) {
        log.error(null, e);
    }
    return any;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) CheckBoxModel(org.jaffa.presentation.portlet.widgets.model.CheckBoxModel) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Aggregations

CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)19 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)9 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)7 EditBoxModel (org.jaffa.presentation.portlet.widgets.model.EditBoxModel)7 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)6 Iterator (java.util.Iterator)4 FrameworkException (org.jaffa.exceptions.FrameworkException)4 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)4 FormKey (org.jaffa.presentation.portlet.FormKey)4 DateTime (org.jaffa.datatypes.DateTime)3 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)3 DateTimeModel (org.jaffa.presentation.portlet.widgets.model.DateTimeModel)3 DropDownModel (org.jaffa.presentation.portlet.widgets.model.DropDownModel)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 org.jaffa.components.maint (org.jaffa.components.maint)2 ApplicationException (org.jaffa.exceptions.ApplicationException)2 FormSelectionMaintenanceOutDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto)2 ImageModel (org.jaffa.presentation.portlet.widgets.model.ImageModel)2 Method (java.lang.reflect.Method)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1