use of org.jaffa.presentation.portlet.widgets.model.TableModel in project jaffa-framework by jaffa-projects.
the class TableTag 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 {
// clear the body content for the next time through.
bodyContent.clearBody();
// get the model
TableModel model = null;
try {
model = (TableModel) TagHelper.getModel(pageContext, getField(), TAG_NAME);
} catch (ClassCastException e) {
String str = "Wrong WidgetModel for " + TAG_NAME + " on field " + getField();
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
if (model != null) {
// write out the html
String idPrefix = getHtmlIdPrefix();
out.println(getHtml(idPrefix, model));
}
}
use of org.jaffa.presentation.portlet.widgets.model.TableModel in project jaffa-framework by jaffa-projects.
the class TableForm method createNewModel.
private TableModel createNewModel() {
TableModel model = new TableModel();
// Add Columns
model.addColumn("Column1", Defaults.STRING);
model.addColumn("Column2", Defaults.INTEGER);
model.addColumn("Column3", Defaults.DATEONLY);
// Create & Add Row
List row = new ArrayList();
row.add("Value1");
row.add("1");
row.add((new DateOnly()).toString());
model.addRow(row);
// Create & Add Row
row = new ArrayList();
row.add("Value2");
row.add("2");
row.add(DateOnly.addDay(new DateOnly(), 1).toString());
model.addRow(row);
// Create & Add Row
row = new ArrayList();
row.add("Value3");
row.add("3");
row.add(DateOnly.addDay(new DateOnly(), 2).toString());
model.addRow(row);
// Create & Add Row
row = new ArrayList();
row.add("Value4");
row.add("4");
row.add(DateOnly.addDay(new DateOnly(), 3).toString());
model.addRow(row);
return model;
}
use of org.jaffa.presentation.portlet.widgets.model.TableModel in project jaffa-framework by jaffa-projects.
the class EmailHelper method emailExcel.
/**
* Sends an email with Excel spreadsheet(s) as attachment(s).
* @param smtpLocalhost (Optional) Name of host sending message, used in the HELO message for
* server authentication
* @param smtpUser (Optional) User name to authenticate to mail server. Not needed if server
* is an 'open relay'
* @param smtpPass (Optional) Password to authenticate to mail server. Not needed if server
* is an 'open relay'
* @param smtpHost (REQUIRED) name of mail server ie mail.yahoo.com
* @param from (REQUIRED) from email ie paul@yahoo.com
* @param to (REQUIRED) array of strings to send email to ie bob@yahoo.com
* @param subject Text for the email subject (defaults to 'No Subject' if null)
* @param bodyText Text for the main mail's body, in addition to the attachment
* @param excelDataArray An array of data to convert to spread sheet. Mkae sure to specify 'String' as a datatype on columns that
* excel should not auto format
* @throws MessagingException Contains error if message could not be sent
*/
public static void emailExcel(String smtpHost, String smtpLocalhost, String smtpUser, String smtpPass, Boolean sendpartial, String from, String[] to, String subject, String bodyText, TableModel[] excelDataArray) throws MessagingException {
BodyPart[] attachments = new BodyPart[excelDataArray.length];
for (int i = 0; i < excelDataArray.length; i++) {
// Create Excel Attachment
TableModel excelData = excelDataArray[i];
StringBuffer sb = new StringBuffer();
convertTableToExcel(excelData, sb);
// Make it an Email Body Part
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(sb.toString(), "text/html");
messageBodyPart.setFileName("excel-file-" + i + ".xls");
messageBodyPart.setHeader("Content-Type", "application/vnd.ms-excel");
attachments[i] = messageBodyPart;
}
// Email excel as attachment(s)
emailAttachments(smtpHost, smtpLocalhost, smtpUser, smtpPass, sendpartial, from, to, subject, bodyText, attachments);
}
use of org.jaffa.presentation.portlet.widgets.model.TableModel in project jaffa-framework by jaffa-projects.
the class TableAction method do_Model1_Clicked.
public FormKey do_Model1_Clicked() throws IOException, ServletException {
if (log.isDebugEnabled())
log.debug("Executing the method 'do_Model1_Clicked'");
TableForm tForm = (TableForm) form;
TableModel model = (TableModel) tForm.getModel1WM();
List selectedRows = model.getSelectedRows();
for (Iterator itr = selectedRows.iterator(); itr.hasNext(); ) {
List row = (List) itr.next();
if (log.isDebugEnabled())
log.debug("Selected Row with Column1 = " + row.get(0).toString());
}
// just return to the same screen
return new FormKey(TableForm.NAME, component != null ? component.getComponentId() : null);
}
Aggregations