Search in sources :

Example 31 with GridModelRow

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

the class ValidationRulesEditorAction method do_ValidatorsUrls_Update_Clicked.

/**
 * Invoked if a update button on a row is selected.
 * @param rowId The selected row on the screen.
 * @return The FormKey for the Update screen.
 */
public FormKey do_ValidatorsUrls_Update_Clicked(String rowId) {
    ValidationRulesEditorForm myForm = (ValidationRulesEditorForm) form;
    ValidationRulesEditorComponent myComp = (ValidationRulesEditorComponent) myForm.getComponent();
    FormKey fk = null;
    GridModel model = (GridModel) myForm.getValidatorsUrlsWM();
    GridModelRow selectedRow = model.getRowById(Integer.parseInt(rowId));
    if (selectedRow != null) {
        try {
            String fileName = (String) selectedRow.get("validatorsUrl");
            if (!fileName.equals(myComp.getValidationRulesFile())) {
                myComp.setFileContents(null);
                myComp.setValidationRulesFile(fileName);
                myComp.loadFileContents();
            }
            myComp.determineAndSetNextScreen();
        } catch (ApplicationExceptions e) {
            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.determineFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 32 with GridModelRow

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

the class ValidationRulesEditorAction method do_Rules_Update_Clicked.

/**
 * Invoked if a update button on a row is selected.
 * @param rowId The selected row on the screen.
 * @return The FormKey for the Update screen.
 */
public FormKey do_Rules_Update_Clicked(String rowId) {
    ValidationRulesEditorForm myForm = (ValidationRulesEditorForm) form;
    ValidationRulesEditorComponent myComp = (ValidationRulesEditorComponent) myForm.getComponent();
    FormKey fk = null;
    GridModel model = (GridModel) myForm.getRulesWM();
    GridModelRow selectedRow = model.getRowById(Integer.parseInt(rowId));
    if (selectedRow != null) {
        try {
            String fileName = (String) selectedRow.get("name");
            if (!fileName.equals(myComp.getValidationRulesFile())) {
                myComp.setFileContents(null);
                myComp.setValidationRulesFile(fileName);
                myComp.loadFileContents();
            }
            myComp.determineAndSetNextScreen();
        } catch (ApplicationExceptions e) {
            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.determineFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 33 with GridModelRow

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

the class BusinessEventLogFinderAction method do_Rows_View_Clicked.

// .//GEN-END:_2_be
// .//GEN-BEGIN:_do_Rows_View_Clicked_1_be
/**
 * Invokes the viewObject() method on the component.
 * @param rowNum The selected row on the Results screen.
 * @return The FormKey for the View screen.
 */
public FormKey do_Rows_View_Clicked(String rowNum) {
    FormKey fk = null;
    // .//GEN-END:_do_Rows_View_Clicked_1_be
    // Add custom code before processing the action //GEN-FIRST:_do_Rows_View_Clicked_1
    // .//GEN-LAST:_do_Rows_View_Clicked_1
    // .//GEN-BEGIN:_do_Rows_View_Clicked_2_be
    BusinessEventLogFinderForm myForm = (BusinessEventLogFinderForm) form;
    BusinessEventLogFinderComponent myComp = (BusinessEventLogFinderComponent) myForm.getComponent();
    GridModel model = (GridModel) myForm.getRowsWM();
    GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
    if (selectedRow != null) {
        try {
            // .//GEN-END:_do_Rows_View_Clicked_2_be
            // Add custom code before invoking the component //GEN-FIRST:_do_Rows_View_Clicked_2
            // .//GEN-LAST:_do_Rows_View_Clicked_2
            // .//GEN-BEGIN:_do_Rows_View_Clicked_3_be
            fk = myComp.viewObject((java.lang.String) selectedRow.get("logId"));
        } catch (ApplicationExceptions e) {
            if (log.isDebugEnabled())
                log.debug("Viewer Failed");
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
        } catch (FrameworkException e) {
            log.error(null, e);
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
        }
    }
    // .//GEN-END:_do_Rows_View_Clicked_3_be
    // Add custom code after returning from the component //GEN-FIRST:_do_Rows_View_Clicked_3
    // .//GEN-LAST:_do_Rows_View_Clicked_3
    // .//GEN-BEGIN:_do_Rows_View_Clicked_4_be
    // The Viewer will be rendered in a new window
    // We don't want to see the existing HistoryNav in that window
    // Hence, initialize the HistoryNav
    HistoryNav.initializeHistoryNav(request);
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getResultsFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 34 with GridModelRow

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

the class GridController method updateModel.

/**
 * Updates the model with the input value.
 * This will throw the XmlStructureRuntimeException, in case the input is not well-formed.
 * @param value The new value for the model.
 * @param model The model to be updated.
 */
public static void updateModel(String value, GridModel model) {
    try {
        String user = null;
        String gridId = null;
        String tableWidth = null;
        List listSettings = new ArrayList();
        // get the root element for the input XML
        Element root = getRootElement(value);
        // iterate through each element in the Grid, and update there model
        for (Iterator it = root.getChildren(XML_WIDGET).iterator(); it.hasNext(); ) {
            Element element = (Element) it.next();
            int rowId = Integer.parseInt(element.getAttribute(XML_ROW).getValue());
            String field = element.getAttribute(XML_FIELD).getValue();
            String contents = getContents(element);
            GridModelRow row = model.getRowById(rowId);
            Object innerModel = row.get(field);
            if (innerModel != null) {
                interpretAndUpdateModel(contents, innerModel);
            }
        }
        // Gets the Setting info posted from the JSP
        // This is only posted when the Grid's Layout is being modified
        Element element = root.getChild(XML_SETTINGS);
        if (element != null) {
            // no longer expect the user to be passed as this could be spoofed, get it from the security manager
            if (SecurityManager.getPrincipal() != null) {
                user = SecurityManager.getPrincipal().getName();
            } else {
                // Error can't save settings if no user is set
                log.error(" Can't save user settings: User unknown or not set by SecurityManager.");
                model.setErrorInSavingUserSettings(true);
                return;
            }
            gridId = element.getChildText(XML_GRIDID);
            log.debug("Grid id=" + gridId + " for user=" + user + " is being modified");
            // This means delete there customized version
            if (element.getChild(XML_RESTORE) != null) {
                // Delete custom settings
                model.setErrorInSavingUserSettings(!UserGridManager.restore(user, gridId));
                log.debug("Grid id=" + gridId + " for user=" + user + " has been reset to the default");
            } else {
                tableWidth = element.getChildText(XML_TABLEWIDTH);
                // create an ObjectFactory instance.
                ObjectFactory objFactory = new ObjectFactory();
                UserGridSettings thing = objFactory.createUserGridSettings();
                List cols = thing.getUserGridColumnSettings();
                // And passes that list to the UserGridManager setColSettings()
                if (log.isDebugEnabled()) {
                    log.debug("Saving Grid Column Listing for User=" + user + ", GridId=" + gridId);
                }
                for (Iterator it = element.getChildren(XML_COLUMN).iterator(); it.hasNext(); ) {
                    Element column = (Element) it.next();
                    String name = column.getAttribute(XML_NAME).getValue();
                    String width = column.getAttribute(XML_WIDTH).getValue();
                    UserGridColumnSettings thing2 = objFactory.createUserGridColumnSettings();
                    thing2.setName(name);
                    thing2.setWidth(width);
                    cols.add(thing2);
                    if (log.isDebugEnabled()) {
                        log.debug("    show column = " + name + ", width=" + width);
                    }
                }
                // Sets the value of the Outer Table Width
                thing.setGridWidth(tableWidth);
                // Save settings to xml file
                // Raise the error flag in the model, in case the 'save' fails
                // The UserGridTag will raise an Error, in case the error-flag is set, and then reset the error-flag
                model.setErrorInSavingUserSettings(!UserGridManager.setColSettings(user, gridId, thing));
            }
            // See if the user whats to toggle the popup hints.
            String hints = element.getChildText(XML_HINTS);
            if (hints != null) {
                try {
                    log.debug("Current Rule " + GridTag.RULE_USERGRID_POPUP + " = " + ContextManagerFactory.instance().getProperty(GridTag.RULE_USERGRID_POPUP));
                    ContextManagerFactory.instance().setUserPreference(GridTag.RULE_USERGRID_POPUP, hints);
                    log.debug("New Rule " + GridTag.RULE_USERGRID_POPUP + " = " + ContextManagerFactory.instance().getProperty(GridTag.RULE_USERGRID_POPUP));
                } catch (IOException e) {
                    log.error("Failed to changed user preferences for " + GridTag.RULE_USERGRID_POPUP, e);
                }
            }
        }
        // Process any state related to the Tree Widget
        for (Iterator it = root.getChildren(XML_DISPLAY).iterator(); it.hasNext(); ) {
            Element data = (Element) it.next();
            int rowId = Integer.parseInt(data.getAttribute(XML_ROW).getValue());
            Boolean expanded = new Boolean(data.getAttribute(XML_EXPANDED).getValue());
            String contents = getContents(data);
            GridModelRow row = model.getRow(rowId);
            row.addElement("isDisplayed", new Boolean(contents));
            row.addElement("isExpanded", expanded);
        }
    } catch (Exception e) {
        log.error("Failed to create Java content objects for marshalling into XML", e);
        model.setErrorInSavingUserSettings(true);
    }
}
Also used : XmlStructureRuntimeException(org.jaffa.presentation.portlet.widgets.controller.exceptions.XmlStructureRuntimeException) ObjectFactory(org.jaffa.presentation.portlet.widgets.controller.usergriddomain.ObjectFactory) UserGridSettings(org.jaffa.presentation.portlet.widgets.controller.usergriddomain.UserGridSettings) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow) UserGridColumnSettings(org.jaffa.presentation.portlet.widgets.controller.usergriddomain.UserGridColumnSettings)

Example 35 with GridModelRow

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

the class PropertyEditorHelper method addRow.

/**
 * Call from the action class to add a new row at the end of the property list
 * @param model grid model to add the row to
 */
public static void addRow(GridModel model) {
    GridModelRow row = model.newRow();
    row.addElement(KEY, new EditBoxModel(EMPTY));
    row.addElement(VALUE, new EditBoxModel(EMPTY));
    row.addElement(COMMENT, new EditBoxModel(EMPTY));
}
Also used : EditBoxModel(org.jaffa.presentation.portlet.widgets.model.EditBoxModel) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Aggregations

GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)136 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)113 FormKey (org.jaffa.presentation.portlet.FormKey)104 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)103 FrameworkException (org.jaffa.exceptions.FrameworkException)100 CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)9 EditBoxModel (org.jaffa.presentation.portlet.widgets.model.EditBoxModel)8 Iterator (java.util.Iterator)6 SimpleWidgetModel (org.jaffa.presentation.portlet.widgets.model.SimpleWidgetModel)4 DateTime (org.jaffa.datatypes.DateTime)3 MessageViewerOutDto (org.jaffa.modules.messaging.components.messageviewer.dto.MessageViewerOutDto)3 DateTimeModel (org.jaffa.presentation.portlet.widgets.model.DateTimeModel)3 DropDownModel (org.jaffa.presentation.portlet.widgets.model.DropDownModel)3 File (java.io.File)2 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 BusinessEventLogFinderOutDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderOutDto)2 BusinessEventLogFinderOutRowDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderOutRowDto)2 HeaderElementDto (org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto)2 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)2