use of com.github.bordertech.wcomponents.Diagnosable in project wcomponents by BorderTech.
the class AbstractWFieldIndicatorRenderer method doRender.
/**
* Paints the given AbstractWFieldIndicator.
*
* @param component the WFieldErrorIndicator to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
AbstractWFieldIndicator fieldIndicator = (AbstractWFieldIndicator) component;
XmlStringBuilder xml = renderContext.getWriter();
WComponent validationTarget = fieldIndicator.getTargetComponent();
// Diagnosables takes care of thieir own messaging.
if (validationTarget == null || (validationTarget instanceof Diagnosable && !(validationTarget instanceof Input))) {
return;
}
if (validationTarget instanceof Input && !((Input) validationTarget).isReadOnly()) {
return;
}
List<Diagnostic> diags = fieldIndicator.getDiagnostics();
if (diags != null && !diags.isEmpty()) {
xml.appendTagOpen("ui:fieldindicator");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
switch(fieldIndicator.getFieldIndicatorType()) {
case INFO:
xml.appendAttribute("type", "info");
break;
case WARN:
xml.appendAttribute("type", "warn");
break;
case ERROR:
xml.appendAttribute("type", "error");
break;
default:
throw new SystemException("Cannot paint field indicator due to an invalid field indicator type: " + fieldIndicator.getFieldIndicatorType());
}
xml.appendAttribute("for", fieldIndicator.getRelatedFieldId());
xml.appendClose();
for (Diagnostic diag : diags) {
xml.appendTag("ui:message");
xml.appendEscaped(diag.getDescription());
xml.appendEndTag("ui:message");
}
xml.appendEndTag("ui:fieldindicator");
}
}
Aggregations