use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.MissingParametersRuntimeException in project jaffa-framework by jaffa-projects.
the class DropDownTag method otherDoStartTagOperations.
/**
* This gets the WidgetModel for the field from the pageContext.
*/
public void otherDoStartTagOperations() {
try {
super.otherDoStartTagOperations();
} catch (JspException e) {
log.error("DropDownTag.otherDoStartTagOperations() error=" + e);
}
// Preprocess if within a Property widget
m_propertyRuleIntrospector = lookupPropertyTag();
// raise an error, if the 'field' is null
if (getField() == null) {
String str = "The " + TAG_NAME + " requires 'field' parameter to be supplied or it should be within a PropertyTag";
log.error(str);
throw new MissingParametersRuntimeException(str);
}
// Determine the m_model. The HTML will be rendered in the otherDoEndTagOperations() method
try {
m_model = (SimpleWidgetModel) 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);
}
try {
// Check for an IPropertyRuleIntrospector, if this tag is not within a Property widget
if (m_propertyRuleIntrospector == null)
m_propertyRuleIntrospector = TagHelper.getPropertyRuleIntrospector(pageContext, getField());
// Wrap the propertyRuleIntrospector
m_propertyRuleIntrospector = TagHelper.wrapPropertyRuleIntrospector(m_propertyRuleIntrospector, m_model);
if (log.isDebugEnabled())
log.debug(this.NAME + " [field=" + getField() + "] PropertyRuleIntrospector is " + m_propertyRuleIntrospector);
} catch (JspException e) {
log.error("DropDownTag.otherDoStartTagOperations(): error wrapping property rule inspector=" + e);
}
if (m_propertyRuleIntrospector.isHidden()) {
// Display the (Restricted) text for a hidden field
try {
pageContext.getOut().print(TagHelper.getTextForHiddenField(pageContext));
} catch (IOException e) {
String str = "Exception in writing the " + TAG_NAME;
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
} else {
if (m_propertyRuleIntrospector.isReadOnly())
m_displayOnly = true;
}
}
use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.MissingParametersRuntimeException 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);
}
}
Aggregations