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