Search in sources :

Example 36 with GridModel

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

the class PropertyEditorHelper method getPropertiesWM.

/**
 * Convert a property string into a grid model, if the model is already
 * being cached on the form, it returns the cached version. If it was not cached
 * it is added to the cache after it has been create.
 * <p>
 * <b>NOTE: if the model is cached and this method is called with a 'new' source
 * string, it will only return the current cached version, not a new grid based
 * on the new source string. If you want this, clear the model cache prior to calling
 * this method
 * </b>
 * @param form the form object that will contains this model
 * @param cacheName the name being used by the form to cache this model
 * @param source the source string containing the property data
 * @return the converted grid model
 */
public static GridModel getPropertiesWM(FormBase form, String cacheName, String source) {
    GridModel model = (GridModel) form.getWidgetCache().getModel(cacheName);
    if (model == null) {
        model = new GridModel();
        ListProperties p = new ListProperties();
        try {
            if (source != null)
                p.load(new ByteArrayInputStream(source.getBytes()));
            for (Enumeration e = p.keys(); e.hasMoreElements(); ) {
                String key = (String) e.nextElement();
                String value = (String) p.getProperty(key);
                String comment = (String) p.getComments(key);
                GridModelRow row = model.newRow();
                row.addElement(KEY, new EditBoxModel(key == null ? EMPTY : key));
                row.addElement(VALUE, new EditBoxModel(value == null ? EMPTY : value));
                row.addElement(COMMENT, new EditBoxModel(comment == null ? EMPTY : value));
            }
            form.getWidgetCache().addModel(cacheName, model);
        } catch (IOException e) {
            log.error("Failed to Load Properties For Field : " + cacheName, e);
        }
    }
    return model;
}
Also used : ListProperties(org.jaffa.util.ListProperties) Enumeration(java.util.Enumeration) ByteArrayInputStream(java.io.ByteArrayInputStream) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) EditBoxModel(org.jaffa.presentation.portlet.widgets.model.EditBoxModel) IOException(java.io.IOException) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 37 with GridModel

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

the class FinderForm method getRowsWM.

// ************************************************************
// Methods used by the Results Screen
// ************************************************************
/**
 * Getter for property rows. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
 * This gets the current data from the component.
 * @return Value of property userRef1.
 */
public GridModel getRowsWM() {
    GridModel rows = (GridModel) getWidgetCache().getModel(ROWS);
    if (rows == null) {
        rows = new GridModel();
        getWidgetCache().addModel(ROWS, rows);
        populateRows(rows);
    }
    return rows;
}
Also used : GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel)

Example 38 with GridModel

use of org.jaffa.presentation.portlet.widgets.model.GridModel 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 39 with GridModel

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

the class GridComponent method getGridChildren.

public void getGridChildren(String rowNo, String field, GridForm myForm) {
    GridModel w_model1 = (GridModel) myForm.getWidgetCache().getModel(field);
    GridModelRow row;
    System.out.println("The row number is " + rowNo);
    row = w_model1.getRowById(new Integer(rowNo).intValue());
    if ((row.getElement("isExpanded") != null) && (Boolean.TRUE.equals((Boolean) row.getElement("isExpanded")))) {
        return;
    }
    row.addElement("isExpanded", new Boolean(true));
    row.addElement("isDisplayed", new Boolean(true));
    w_model1.setTarget(row);
    row = w_model1.newRow(new Integer(rowNo).intValue() + 1);
    row.addElement("isDisplayed", new Boolean(true));
    row.addElement("isTarget", new Boolean(false));
    row.addElement("isParent", new Boolean(false));
    row.addElement("level", new Integer(4));
    row.addElement("field1", new EditBoxModel("Field91Value"));
    row.addElement("field2", new EditBoxModel("Field92Value"));
    row.addElement("field3", new DateTimeModel(DateTime.addMonth(new DateTime(), 1)));
    row.addElement("field4", new CheckBoxModel(true));
    row.addElement("field5", new ImageModel(ImageComponent.getImageBytes("C:\\Sandbox\\Jaffa\\source\\httpunittest\\html\\widgets\\tests\\testimage1_up.gif")));
    row.addElement("field6", new DropDownModel("Value3"));
}
Also used : GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) DateTimeModel(org.jaffa.presentation.portlet.widgets.model.DateTimeModel) DropDownModel(org.jaffa.presentation.portlet.widgets.model.DropDownModel) EditBoxModel(org.jaffa.presentation.portlet.widgets.model.EditBoxModel) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow) ImageModel(org.jaffa.presentation.portlet.widgets.model.ImageModel) DateTime(org.jaffa.datatypes.DateTime) CheckBoxModel(org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)

Example 40 with GridModel

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

the class LookupForm method createNewModel.

private GridModel createNewModel() {
    GridModel model = new GridModel();
    GridModelRow row;
    row = model.newRow();
    row.addElement("partNo", "Part1");
    row.addElement("segCode", "SC1");
    row.addElement("status", "S1");
    row.addElement("condition", "C1");
    row = model.newRow();
    row.addElement("partNo", "Part2");
    row.addElement("segCode", "SC2");
    row.addElement("status", "S2");
    row.addElement("condition", "C2");
    row = model.newRow();
    row.addElement("partNo", "Part3");
    row.addElement("segCode", "SC3");
    row.addElement("status", "S3");
    row.addElement("condition", "C3");
    return model;
}
Also used : GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Aggregations

GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)135 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)113 FormKey (org.jaffa.presentation.portlet.FormKey)106 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)104 FrameworkException (org.jaffa.exceptions.FrameworkException)101 CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)6 EditBoxModel (org.jaffa.presentation.portlet.widgets.model.EditBoxModel)6 DateTime (org.jaffa.datatypes.DateTime)3 DateTimeModel (org.jaffa.presentation.portlet.widgets.model.DateTimeModel)3 DropDownModel (org.jaffa.presentation.portlet.widgets.model.DropDownModel)3 Method (java.lang.reflect.Method)2 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)2 FormSelectionMaintenanceOutDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto)2 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)2 ImageModel (org.jaffa.presentation.portlet.widgets.model.ImageModel)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Enumeration (java.util.Enumeration)1