Search in sources :

Example 86 with GridModelRow

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

the class LookupAction method do_Rows_Select_Clicked.

/**
 * This will add the 'lookup' attribute on the request stream, with a Map containing the fieldnames (from the targetFields property) and values (from the selectedRow).
 * It will then invoke the quit() method on the component.
 * Finally it will return a FormKey object for the generic lookup jsp.
 * @param rowNum The selected row on the Results screen.
 * @return The FormKey for the generic lookup jsp.
 */
public FormKey do_Rows_Select_Clicked(String rowNum) {
    FormKey fk = null;
    LookupForm myForm = (LookupForm) form;
    LookupComponent2 myComp = (LookupComponent2) myForm.getComponent();
    GridModel model = myForm.getRowsWM();
    GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
    if (myComp.isInSelectLookupMode()) {
        try {
            Object finderOutDto = myComp.getFinderOutDto();
            Class finderOutDtoClass = finderOutDto.getClass();
            Method method = finderOutDtoClass.getMethod("getRows", new Class[] { Integer.TYPE });
            Object selectedRowDto = method.invoke(finderOutDto, new Object[] { new Integer(selectedRow.getRowId()) });
            SelectLookupEvent event = new SelectLookupEvent(myComp, selectedRowDto);
            fk = myComp.performSelectLookup(request, event);
        } catch (ApplicationExceptions e) {
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
            // This could only be caused by the listeners throwing and error, so we want to quit the component and return
            fk = myComp.quitLookup(request);
        } catch (Exception e) {
            log.error(null, e);
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
        }
    } else
        fk = myComp.performLookup(request, selectedRow);
    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) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 87 with GridModelRow

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

the class AttachmentFinderAction method do_Rows_Delete_Clicked.

// .//GEN-END:_do_Rows_Update_Clicked_4_be
// .//GEN-BEGIN:_do_Rows_Delete_Clicked_1_be
/**
 * Invokes the deleteObject() method on the component.
 * @param rowNum The selected row on the Results screen.
 * @return The FormKey for the Delete screen.
 */
public FormKey do_Rows_Delete_Clicked(String rowNum) {
    FormKey fk = null;
    // .//GEN-END:_do_Rows_Delete_Clicked_1_be
    // Add custom code before processing the action//GEN-FIRST:_do_Rows_Delete_Clicked_1
    // .//GEN-LAST:_do_Rows_Delete_Clicked_1
    // .//GEN-BEGIN:_do_Rows_Delete_Clicked_2_be
    AttachmentFinderForm myForm = (AttachmentFinderForm) form;
    AttachmentFinderComponent myComp = (AttachmentFinderComponent) myForm.getComponent();
    try {
        // This will stop double submits
        performTokenValidation(request);
        GridModel model = (GridModel) myForm.getRowsWM();
        GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
        if (selectedRow != null) {
            // .//GEN-END:_do_Rows_Delete_Clicked_2_be
            // Add custom code before invoking the component//GEN-FIRST:_do_Rows_Delete_Clicked_2
            // .//GEN-LAST:_do_Rows_Delete_Clicked_2
            // .//GEN-BEGIN:_do_Rows_Delete_Clicked_3_be
            fk = myComp.deleteObject((java.lang.String) selectedRow.get("attachmentId"));
        }
    } catch (ApplicationExceptions e) {
        if (log.isDebugEnabled())
            log.debug("Delete 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.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 88 with GridModelRow

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

the class AttachmentFinderAction method do_Rows_ViewAttachmentData_Clicked.

// .//GEN-END:_do_Rows_Delete_Clicked_4_be
// All the custom code goes here//GEN-FIRST:_custom
/**
 * Creates a temporary file with the attachment data and adds it as an attribute to the request stream.
 * Returns a FormKey pointing to Jaffa's FileExplorer servlet which downloads the temporary file.
 * @param rowNum The selected row on the Results screen.
 * @return the FormKey for the FileExplorer servlet. A null is returned if the input data is null.
 */
public FormKey do_Rows_ViewAttachmentData_Clicked(String rowNum) {
    FormKey fk = null;
    AttachmentFinderForm myForm = (AttachmentFinderForm) form;
    AttachmentFinderComponent myComp = (AttachmentFinderComponent) myForm.getComponent();
    GridModel model = (GridModel) myForm.getRowsWM();
    GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
    if (selectedRow != null)
        fk = AttachmentComponentHelper.loadAttachmentData(myForm, request, (String) selectedRow.get("originalFileName"), (byte[]) selectedRow.get("data"));
    if (fk == null)
        fk = myComp.getResultsFormKey();
    return fk;
}
Also used : GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 89 with GridModelRow

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

the class AttachmentLookupAction method do_Rows_Update_Clicked.

// .//GEN-END:_do_Rows_View_Clicked_4_be
// .//GEN-BEGIN:_do_Rows_Update_Clicked_1_be
/**
 * Invokes the updateObject() method on the component.
 * @param rowNum The selected row on the Results screen.
 * @return The FormKey for the Update screen.
 */
public FormKey do_Rows_Update_Clicked(String rowNum) {
    FormKey fk = null;
    // .//GEN-END:_do_Rows_Update_Clicked_1_be
    // Add custom code before processing the action//GEN-FIRST:_do_Rows_Update_Clicked_1
    // .//GEN-LAST:_do_Rows_Update_Clicked_1
    // .//GEN-BEGIN:_do_Rows_Update_Clicked_2_be
    AttachmentLookupForm myForm = (AttachmentLookupForm) form;
    AttachmentLookupComponent myComp = (AttachmentLookupComponent) myForm.getComponent();
    GridModel model = (GridModel) myForm.getRowsWM();
    GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
    if (selectedRow != null) {
        try {
            // .//GEN-END:_do_Rows_Update_Clicked_2_be
            // Add custom code before invoking the component//GEN-FIRST:_do_Rows_Update_Clicked_2
            // .//GEN-LAST:_do_Rows_Update_Clicked_2
            // .//GEN-BEGIN:_do_Rows_Update_Clicked_3_be
            fk = myComp.updateObject((java.lang.String) selectedRow.get("attachmentId"));
        } 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.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 90 with GridModelRow

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

the class GridColumnTag method writeTagBodyContent.

/**
 * This generates the HTML for the tag.
 * @param out The JspWriter object.
 * @param bodyContent The BodyContent object.
 * @throws IOException if any I/O error occurs.
 */
public void writeTagBodyContent(JspWriter out, BodyContent bodyContent) throws IOException {
    // log.debug("writeTagBodyContent: " + this.toString());
    if (!m_gridTag.isColumnHidden(getLabel())) {
        StringBuffer sb = new StringBuffer();
        String bodyContentString = bodyContent.getString();
        sb.append(getColumnStartHtml());
        // 
        if (m_treeField != null) {
            boolean isDisplayed = false;
            GridModelRow row = (GridModelRow) m_gridTag.currentGridRow();
            Integer level = (Integer) row.get("level");
            Boolean isExpanded = (Boolean) row.get("isExpanded");
            Boolean isParent = (Boolean) row.get("isParent");
            if (row.get("isDisplayed") != null)
                isDisplayed = ((Boolean) row.get("isDisplayed")).booleanValue();
            if (log.isDebugEnabled())
                log.debug("Tree Row " + m_gridTag.getRowNumber() + " : isDisplayed=" + row.get("isDisplayed") + " [" + isDisplayed + "]");
            String lastLevelId = m_gridTag.retrieveLastLevelId(level);
            String newLevelId = new String();
            if (lastLevelId != null) {
                int levelIndex = lastLevelId.lastIndexOf("-");
                if (lastLevelId.lastIndexOf("-") != -1) {
                    Integer lastDigits = new Integer(lastLevelId.substring((levelIndex + 1), lastLevelId.length()));
                    if (log.isDebugEnabled())
                        log.debug("levelindex is " + levelIndex + " length is" + lastLevelId.length() + "last levelId is " + lastLevelId);
                    if (lastDigits != null) {
                        lastDigits = new Integer(lastDigits.intValue() + 1);
                    }
                    Integer lastLevel = new Integer(level.intValue() - 1);
                    String parentLevelId = m_gridTag.retrieveLastLevelId(lastLevel);
                    if (parentLevelId != null && !parentLevelId.equals(lastLevelId.substring(0, levelIndex))) {
                        newLevelId = parentLevelId + "-1";
                    } else {
                        newLevelId = lastLevelId.substring(0, levelIndex) + "-" + lastDigits;
                    }
                } else {
                    newLevelId = "" + (new Integer(lastLevelId).intValue() + 1);
                }
            } else {
                if (level.intValue() > m_gridTag.ROOT_LEVEL) {
                    Integer lastLevel = new Integer(level.intValue() - 1);
                    String parentLevelId = m_gridTag.retrieveLastLevelId(lastLevel);
                    newLevelId = parentLevelId + "-1";
                } else {
                    if (log.isDebugEnabled())
                        log.debug("level is " + level + " and that first level was fired");
                    newLevelId = "" + m_gridTag.ROOT_LEVEL;
                }
            }
            if (log.isDebugEnabled())
                log.debug("the new levelid is " + newLevelId);
            m_gridTag.updateLastLevelId(level, newLevelId);
            for (int i = 1; i < level.intValue(); i++) {
                sb.append(m_treeSpacer);
            }
            newLevelId = m_gridTag.getField() + ":" + newLevelId;
            if (isParent != null && isParent.booleanValue()) {
                if (isExpanded.booleanValue()) {
                    sb.append("<script>currentState.addExpanded('").append(newLevelId).append("-')</script><a").append((m_gridTag.getIsTarget() ? " id='rowTarget' " : "")).append(" style='text-decoration:none' href='javascript:void(0);' onclick=\"toggleRows(this ,'").append(m_gridTag.getServerSideCall()).append("');return false\" nowrap><img src=\"jaffa/imgs/tree/contractLevel.gif\" border=\"0\"></a>");
                } else {
                    sb.append("<a").append((m_gridTag.getIsTarget() ? " id='rowTarget' " : "")).append(" style='text-decoration:none' href='javascript:void(0);' onclick=\"toggleRows(this ,'").append(m_gridTag.getServerSideCall()).append("');return false\" nowrap><img src=\"jaffa/imgs/tree/expandLevel.gif\" border=\"0\"></a>");
                }
            } else {
                sb.append("<a").append((m_gridTag.getIsTarget() ? " id='rowTarget' " : "")).append("><img src=\"jaffa/imgs/tree/childItem.gif\" border=\"0\" nowrap></a>");
            }
            m_gridTag.setCurrentLevelId(newLevelId);
            m_gridTag.setRowDisplayed(isDisplayed);
        }
        if (bodyContentString == null || bodyContentString.trim().length() == 0)
            sb.append(TagHelper.HTML_SPACE_CHARACTER);
        else
            sb.append(bodyContentString.trim());
        sb.append(getColumnEndingHtml()).append('\n');
        m_gridTag.addColumnContentsToStack(getLabel(), sb.toString());
        // clear the body content for the next time through.
        bodyContent.clearBody();
    }
// else
// log.debug("No content for hidden column " + getLabel());
}
Also used : 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