use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException in project jaffa-framework by jaffa-projects.
the class HeaderTag method otherDoStartTagOperations.
/**
* Called from the doStartTag()
*/
public void otherDoStartTagOperations() throws JspException {
super.otherDoStartTagOperations();
JspWriter writer = pageContext.getOut();
StringBuffer buf = new StringBuffer();
buf.append(getNoCacheTag());
buf.append(getBaseTag());
buf.append("<script type=\"text/javascript\" src=\"jaffa/js/panels/header.js\"></script>\n");
buf.append("<script type=\"text/javascript\" src=\"jaffa/js/panels/errorpopup.js\"></script>\n");
buf.append("<script type=\"text/javascript\" src=\"jaffa/js/rules/coreRules.js\"></script>\n");
buf.append("<script type=\"text/javascript\" src=\"jaffa/js/rules/rulesValidator.js\"></script>\n");
buf.append("<script type=\"text/javascript\" src=\"jaffa/js/rules/initializeRules.js\"></script>\n");
buf.append("<script type=\"text/javascript\" src=\"jaffa/js/widgets/datetimePicker.js\"></script>\n");
buf.append("<script type=\"text/javascript\" src=\"jaffa/js/widgets/dropdownManager.js\"></script>\n");
buf.append("<script type=\"text/javascript\" src=\"jaffa/js/widgets/widgetCache.js\"></script>\n");
String firstDayOfWeek = (String) ContextManagerFactory.instance().getProperty("jaffa.date.firstDayOfWeek");
if (firstDayOfWeek != null) {
Pattern p = Pattern.compile("[0-6]");
Matcher m = p.matcher(firstDayOfWeek);
if (!m.matches()) {
firstDayOfWeek = "0";
}
buf.append("<script type=\"text/javascript\">" + StringHelper.convertToHTML(MessageHelper.findMessage("label.Jaffa.Widgets.Grid.ColumnHeader.firstDayOfWeek", null)) + " = " + firstDayOfWeek + " </script>\n");
}
if (getErrorBoxInSameWindow()) {
buf.append("<script> var windowType = \"false\" </script>");
pageContext.setAttribute(TagHelper.ATTRIBUTE_ERROR_BOX_IN_SAME_WINDOW, Boolean.TRUE, pageContext.REQUEST_SCOPE);
} else {
buf.append("<script> var windowType = \"true\" </script>");
pageContext.setAttribute(TagHelper.ATTRIBUTE_ERROR_BOX_IN_SAME_WINDOW, Boolean.FALSE, pageContext.REQUEST_SCOPE);
}
buf.append(generateGetServerDateFunction());
try {
writer.println(buf.toString());
} catch (IOException e) {
String str = "Exception in writing the HeaderTag";
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
}
use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException in project jaffa-framework by jaffa-projects.
the class LabelTag method otherDoStartTagOperations.
/**
* Called from the doStartTag()
*/
public void otherDoStartTagOperations() throws JspException {
super.otherDoStartTagOperations();
// Preprocess if within a Property widget
lookupPropertyTag();
// determine the key to be used for the label
String key = null;
if (m_key != null)
key = m_key;
else if (m_domain != null && m_field != null) {
try {
key = TagHelper.getFieldMetaData(m_domain, m_field).getLabelToken();
if (log.isDebugEnabled())
log.debug("LabelToken for the MetaField '" + m_field + "' is : " + key);
} catch (Exception e) {
String str = "Exception thrown while determining the LabelToken for the MetaField " + m_field + ". Domain=" + m_domain + ", Field=" + m_field;
log.error(str, e);
try {
JspWriter out = pageContext.getOut();
out.print(ERROR_LABEL);
} catch (IOException ioe) {
String str2 = "Exception in writing the " + TAG_NAME;
log.error(str2, ioe);
throw new JspWriteRuntimeException(str2, ioe);
}
return;
// throw new JspWriteRuntimeException(str, e);
}
}
// raise an error, if the key is still null
if (key == null) {
String str = "The " + TAG_NAME + " requires either a valid 'key' or 'domain and field' parameters to be supplied";
log.error(str);
throw new MissingParametersRuntimeException(str);
}
/* NOTE: Key can be of the following formats
* xyz : Invoke MessageHelper.findMessage() to find the label for the key 'xyz'
* [xyz] : Invoke MessageHelper.findMessage() to find the label for the detokenized key 'xyz'
* abc [xyz] efg : Invoke MessageHelper.replaceTokens to resolve the text'abc [xyz] efg'
*/
// get the label from the resource bundle
String label = null;
if (MessageHelper.hasTokens(key)) {
// Remove the begin/end token-markers
String detokenizedKey = MessageHelper.removeTokenMarkers(key);
// Check if there are more tokens left
if (MessageHelper.hasTokens(detokenizedKey))
label = MessageHelper.replaceTokens(pageContext, key);
else
key = detokenizedKey;
}
if (label == null) {
Object[] args = null;
if (m_arg0 != null || m_arg1 != null || m_arg2 != null || m_arg3 != null || m_arg4 != null)
args = new Object[] { m_arg0, m_arg1, m_arg2, m_arg3, m_arg4 };
label = MessageHelper.findMessage(pageContext, key, args);
}
// write the label
try {
JspWriter out = pageContext.getOut();
out.print((label != null ? label : UNDEFINED_LABEL + '(' + key + ')'));
out.print(TagHelper.getLabelEditorLink(pageContext, key));
} catch (IOException e) {
String str = "Exception in writing the " + TAG_NAME;
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
}
use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException in project jaffa-framework by jaffa-projects.
the class RaiseErrorsTag method otherDoEndTagOperations.
/**
* This generates the HTML for the tag.
* Writes a script tag containing error message details to be added to the current jsp.
*
* @throws JspException if any error occurs.
*/
public void otherDoEndTagOperations() throws JspException {
// Get the form bean from the page.
FormBase form = TagHelper.getFormBase(pageContext);
if (form == null) {
String str = "The " + TAG_NAME + " should be inside a FormTag";
log.error(str);
throw new OuterFormTagMissingRuntimeException(str);
}
// get the errors from the form
if (!FormBase.hasErrors((HttpServletRequest) pageContext.getRequest())) {
return;
}
ActionMessages errors = FormBase.getErrors((HttpServletRequest) pageContext.getRequest());
StringBuilder buf = new StringBuilder();
buf.append("<SCRIPT type=\"text/javascript\">");
for (Iterator itr = errors.get(); itr.hasNext(); ) {
ActionMessage error = (ActionMessage) itr.next();
buf.append("addMessage(\"");
String messageHtml = StringHelper.convertToHTML(MessageHelper.findMessage(pageContext, error.getKey(), error.getValues()));
String labelEditorLink = TagHelper.getLabelEditorLink(pageContext, error.getKey());
// escape the message for html to prevent XSS
String message = Encode.forHtml(messageHtml) + labelEditorLink;
buf.append(message);
buf.append("\");");
}
// delete the error so that it doesn't get re-displayed
form.clearErrors((HttpServletRequest) pageContext.getRequest());
buf.append("</SCRIPT>");
// add the script tag containing the error message to the current jsp
try {
JspWriter w = pageContext.getOut();
w.print(buf.toString());
} catch (IOException e) {
String str = "Exception in writing the " + TAG_NAME;
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
}
Aggregations