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;
}
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;
}
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;
}
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);
}
}
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));
}
Aggregations