use of org.jaffa.presentation.portlet.FormKey in project jaffa-framework by jaffa-projects.
the class AttachmentLookupAction method do_Rows_View_Clicked.
// .//GEN-END:_do_CreateFromResults_Clicked_4_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
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_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("attachmentId"));
} 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.FormKey in project jaffa-framework by jaffa-projects.
the class AttachmentViewerAction method do_Update_Clicked.
// .//GEN-END:_do_Close_Clicked_2_be
// .//GEN-BEGIN:_do_Update_Clicked_1_be
/**
* Invokes the updateObject() method on the component.
* @return The FormKey for the Update screen.
*/
public FormKey do_Update_Clicked() {
FormKey fk = null;
// .//GEN-END:_do_Update_Clicked_1_be
// Add custom code before processing the action//GEN-FIRST:_do_Update_Clicked_1
// .//GEN-LAST:_do_Update_Clicked_1
// .//GEN-BEGIN:_do_Update_Clicked_2_be
AttachmentViewerForm myForm = (AttachmentViewerForm) form;
AttachmentViewerComponent myComp = (AttachmentViewerComponent) myForm.getComponent();
try {
// .//GEN-END:_do_Update_Clicked_2_be
// Add custom code before invoking the component//GEN-FIRST:_do_Update_Clicked_2
// .//GEN-LAST:_do_Update_Clicked_2
// .//GEN-BEGIN:_do_Update_Clicked_3_be
fk = myComp.updateObject();
} 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.getViewerFormKey();
return fk;
}
use of org.jaffa.presentation.portlet.FormKey in project jaffa-framework by jaffa-projects.
the class AttachmentComponentHelper method loadAttachmentData.
/**
* Creates a temporary file with the input 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 form the Form instance to which an error will be added, in case an IOException occurs while creating the temporary file.
* @param request the request stream.
* @param fileName Its suffix is used for creating the temporary file. May be null.
* @param data The contents to be downloaded. May be null, in which case nothing is done.
* @return the FormKey for the FileExplorer servlet. A null is returned if the input data is null.
*/
public static FormKey loadAttachmentData(FormBase form, HttpServletRequest request, String fileName, byte[] data) {
FormKey fk = null;
if (data != null && data.length > 0) {
OutputStream outputStream = null;
try {
// Determine the suffix
int i = fileName != null ? fileName.lastIndexOf('.') : -1;
String suffix = i >= 0 ? fileName.substring(i) : null;
// Create a temporary file with the suffix
File attachmentDataFile = File.createTempFile("jaffa", suffix);
// Add the data to the file
outputStream = new BufferedOutputStream(new FileOutputStream(attachmentDataFile));
outputStream.write(data);
outputStream.flush();
// Return a FormKey pointing to Jaffa's FileExplorer servlet
request.setAttribute("org.jaffa.applications.jaffa.modules.admin.components.fileexplorer", attachmentDataFile);
request.setAttribute("org.jaffa.applications.jaffa.modules.admin.components.fileexplorer.fileName", fileName);
return new FormKey("jaffa_admin_fileExplorer_download", null);
} catch (IOException e) {
log.error("Exception in writing the attachment data to a temporary file", e);
form.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
} finally {
try {
if (outputStream != null)
outputStream.close();
} catch (IOException e) {
// do nothing
}
}
}
return fk;
}
use of org.jaffa.presentation.portlet.FormKey in project jaffa-framework by jaffa-projects.
the class TaskMaintenanceAction method do_RelatedBusinessEventLog_View_Clicked.
/**
* 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_RelatedBusinessEventLog_View_Clicked(String rowNum) {
FormKey fk = null;
TaskMaintenanceForm myForm = (TaskMaintenanceForm) form;
TaskMaintenanceComponent myComp = (TaskMaintenanceComponent) myForm.getComponent();
GridModel model = (GridModel) myForm.getRelatedBusinessEventLogWM();
GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
if (selectedRow != null) {
try {
fk = myComp.displayBusinessEventLogViewer((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");
}
}
// 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.determineFormKey();
return fk;
}
use of org.jaffa.presentation.portlet.FormKey in project jaffa-framework by jaffa-projects.
the class UserFinderAction method do_CreateFromCriteria_Clicked.
// .//GEN-END:_2_be
// .//GEN-BEGIN:_do_CreateFromCriteria_Clicked_1_be
/**
* Invokes the createFromCriteria() method on the component.
* @return The FormKey for the Create screen.
*/
public FormKey do_CreateFromCriteria_Clicked() {
FormKey fk = null;
// .//GEN-END:_do_CreateFromCriteria_Clicked_1_be
// Add custom code before processing the action //GEN-FIRST:_do_CreateFromCriteria_Clicked_1
// .//GEN-LAST:_do_CreateFromCriteria_Clicked_1
// .//GEN-BEGIN:_do_CreateFromCriteria_Clicked_2_be
UserFinderForm myForm = (UserFinderForm) form;
UserFinderComponent myComp = (UserFinderComponent) myForm.getComponent();
if (myForm.doValidate(request)) {
try {
// .//GEN-END:_do_CreateFromCriteria_Clicked_2_be
// Add custom code before invoking the component //GEN-FIRST:_do_CreateFromCriteria_Clicked_2
// .//GEN-LAST:_do_CreateFromCriteria_Clicked_2
// .//GEN-BEGIN:_do_CreateFromCriteria_Clicked_3_be
fk = myComp.createFromCriteria();
} catch (ApplicationExceptions e) {
if (log.isDebugEnabled())
log.debug("Create 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.getCriteriaFormKey();
return fk;
}
Aggregations