use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class WPartialDateFieldRenderer method doRender.
/**
* Paints the given WPartialDateField.
*
* @param component the WPartialDateField to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPartialDateField dateField = (WPartialDateField) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = dateField.isReadOnly();
String date = formatDate(dateField);
xml.appendTagOpen("ui:datefield");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", dateField.isHidden(), "true");
xml.appendOptionalAttribute("date", date);
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
xml.appendAttribute("allowPartial", "true");
xml.appendOptionalAttribute("disabled", dateField.isDisabled(), "true");
xml.appendOptionalAttribute("required", dateField.isMandatory(), "true");
xml.appendOptionalAttribute("toolTip", dateField.getToolTip());
xml.appendOptionalAttribute("accessibleText", dateField.getAccessibleText());
WComponent submitControl = dateField.getDefaultSubmitButton();
String submitControlId = submitControl == null ? null : submitControl.getId();
xml.appendOptionalAttribute("buttonId", submitControlId);
}
xml.appendClose();
if (date == null) {
xml.appendEscaped(dateField.getText());
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(dateField, renderContext);
}
xml.appendEndTag("ui:datefield");
}
use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class WPasswordFieldRenderer method doRender.
/**
* Paints the given WPasswordField.
*
* @param component the WPasswordField to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPasswordField field = (WPasswordField) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = field.isReadOnly();
xml.appendTagOpen(TAG_NAME);
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
xml.appendEnd();
return;
}
int cols = field.getColumns();
int minLength = field.getMinLength();
int maxLength = field.getMaxLength();
WComponent submitControl = field.getDefaultSubmitButton();
String submitControlId = submitControl == null ? null : submitControl.getId();
xml.appendOptionalAttribute("disabled", field.isDisabled(), "true");
xml.appendOptionalAttribute("required", field.isMandatory(), "true");
xml.appendOptionalAttribute("minLength", minLength > 0, minLength);
xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength);
xml.appendOptionalAttribute("toolTip", field.getToolTip());
xml.appendOptionalAttribute("accessibleText", field.getAccessibleText());
xml.appendOptionalAttribute("size", cols > 0, cols);
xml.appendOptionalAttribute("buttonId", submitControlId);
xml.appendOptionalAttribute("placeholder", HtmlRenderUtil.getEffectivePlaceholder(field));
List<Diagnostic> diags = field.getDiagnostics(Diagnostic.ERROR);
if (diags == null || diags.isEmpty()) {
xml.appendEnd();
return;
}
xml.appendClose();
DiagnosticRenderUtil.renderDiagnostics(field, renderContext);
xml.appendEndTag(TAG_NAME);
}
use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class WPhoneNumberFieldRenderer method doRender.
/**
* Paints the given WPhoneNumberField.
*
* @param component the WPhoneNumberField to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPhoneNumberField field = (WPhoneNumberField) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = field.isReadOnly();
xml.appendTagOpen("ui:phonenumberfield");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
int cols = field.getColumns();
int minLength = field.getMinLength();
int maxLength = field.getMaxLength();
String pattern = field.getPattern();
WSuggestions suggestions = field.getSuggestions();
String suggestionsId = suggestions == null ? null : suggestions.getId();
WComponent submitControl = field.getDefaultSubmitButton();
String submitControlId = submitControl == null ? null : submitControl.getId();
xml.appendOptionalAttribute("disabled", field.isDisabled(), "true");
xml.appendOptionalAttribute("required", field.isMandatory(), "true");
xml.appendOptionalAttribute("minLength", minLength > 0, minLength);
xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength);
xml.appendOptionalAttribute("toolTip", field.getToolTip());
xml.appendOptionalAttribute("accessibleText", field.getAccessibleText());
xml.appendOptionalAttribute("size", cols > 0, cols);
xml.appendOptionalAttribute("buttonId", submitControlId);
xml.appendOptionalAttribute("pattern", !Util.empty(pattern), pattern);
xml.appendOptionalAttribute("list", suggestionsId);
xml.appendOptionalAttribute("placeholder", HtmlRenderUtil.getEffectivePlaceholder(field));
}
xml.appendClose();
xml.appendEscaped(field.getText());
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(field, renderContext);
}
xml.appendEndTag("ui:phonenumberfield");
}
use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class WRepeaterRenderer method paintRows.
/**
* Paints the rows.
*
* @param repeater the repeater to paint the rows for.
* @param renderContext the RenderContext to paint to.
*/
protected void paintRows(final WRepeater repeater, final WebXmlRenderContext renderContext) {
List<?> beanList = repeater.getBeanList();
WComponent row = repeater.getRepeatedComponent();
for (int i = 0; i < beanList.size(); i++) {
Object rowData = beanList.get(i);
// Each row has its own context. This is why we can reuse the same
// WComponent instance for each row.
UIContext rowContext = repeater.getRowContext(rowData, i);
UIContextHolder.pushContext(rowContext);
try {
row.paint(renderContext);
} finally {
UIContextHolder.popContext();
}
}
}
use of com.github.bordertech.wcomponents.WComponent in project wcomponents by BorderTech.
the class WTabRenderer method doRender.
/**
* Paints the given WTab.
*
* @param component the WTab to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTab tab = (WTab) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:tab");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("open", tab.isOpen(), "true");
xml.appendOptionalAttribute("disabled", tab.isDisabled(), "true");
xml.appendOptionalAttribute("hidden", tab.isHidden(), "true");
xml.appendOptionalAttribute("toolTip", tab.getToolTip());
switch(tab.getMode()) {
case CLIENT:
xml.appendAttribute("mode", "client");
break;
case LAZY:
xml.appendAttribute("mode", "lazy");
break;
case EAGER:
xml.appendAttribute("mode", "eager");
break;
case DYNAMIC:
xml.appendAttribute("mode", "dynamic");
break;
case SERVER:
xml.appendAttribute("mode", "server");
break;
default:
throw new SystemException("Unknown tab mode: " + tab.getMode());
}
if (tab.getAccessKey() != 0) {
xml.appendAttribute("accessKey", String.valueOf(Character.toUpperCase(tab.getAccessKey())));
}
xml.appendClose();
// Paint label
tab.getTabLabel().paint(renderContext);
// Paint content
WComponent content = tab.getContent();
xml.appendTagOpen("ui:tabcontent");
xml.appendAttribute("id", tab.getId() + "-content");
xml.appendClose();
// Render content if not EAGER Mode or is EAGER and is the current AJAX trigger
if (content != null && (TabMode.EAGER != tab.getMode() || AjaxHelper.isCurrentAjaxTrigger(tab))) {
// Visibility of content set in prepare paint
content.paint(renderContext);
}
xml.appendEndTag("ui:tabcontent");
xml.appendEndTag("ui:tab");
}
Aggregations