protected void renderSelectOptions(FormField formField, HtmlDocumentBuilder documentBuilder) { EnumFormType enumFormType = (EnumFormType) formField.getType(); Map<String, String> values = enumFormType.getValues(); for (Map.Entry<String, String> value : values.entrySet()) { // <option> HtmlElementWriter option = new HtmlElementWriter(OPTION_ELEMENT, false) .attribute(VALUE_ATTRIBUTE, value.getKey()) .textContent(value.getValue()); documentBuilder.startElement(option).endElement(); } }
protected void renderSelectOptions(FormField formField, HtmlDocumentBuilder documentBuilder) { EnumFormType enumFormType = (EnumFormType) formField.getType(); Map<String, String> values = enumFormType.getValues(); for (Entry<String, String> value : values.entrySet()) { // <option> HtmlElementWriter option = new HtmlElementWriter(OPTION_ELEMENT, false) .attribute(VALUE_ATTRIBUTE, value.getKey()) .textContent(value.getValue()); documentBuilder.startElement(option).endElement(); } }
protected void renderSelectOptions(FormField formField, HtmlDocumentBuilder documentBuilder) { EnumFormType enumFormType = (EnumFormType) formField.getType(); Map<String, String> values = enumFormType.getValues(); for (Entry<String, String> value : values.entrySet()) { // <option> HtmlElementWriter option = new HtmlElementWriter(OPTION_ELEMENT, false) .attribute(VALUE_ATTRIBUTE, value.getKey()) .textContent(value.getValue()); documentBuilder.startElement(option).endElement(); } }
protected void renderSelectOptions(FormField formField, HtmlDocumentBuilder documentBuilder) { EnumFormType enumFormType = (EnumFormType) formField.getType(); Map<String, String> values = enumFormType.getValues(); for (Map.Entry<String, String> value : values.entrySet()) { // <option> HtmlElementWriter option = new HtmlElementWriter(OPTION_ELEMENT, false) .attribute(VALUE_ATTRIBUTE, value.getKey()) .textContent(value.getValue()); documentBuilder.startElement(option).endElement(); } }
public HtmlElementWriter toHtmlElementWriter() { HtmlElementWriter elementWriter; if (header) { elementWriter = new HtmlElementWriter("th"); } else { elementWriter = new HtmlElementWriter("td"); } if (colspan > 1) { elementWriter .attribute("colspan", String.valueOf(colspan)) .attribute("class", "text-center"); } elementWriter.textContent(text); return elementWriter; }
protected void renderInvalidValueMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT); String formFieldId = formField.getId(); String expression = String.format(REQUIRED_ERROR_EXPRESSION, formFieldId); divElement .attribute(NG_SHOW_ATTRIBUTE, expression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(REQUIRED_FIELD_MESSAGE); documentBuilder .startElement(divElement) .endElement(); }
protected void renderInvalidValueMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT); String formFieldId = formField.getId(); String expression = String.format(REQUIRED_ERROR_EXPRESSION, formFieldId); divElement .attribute(NG_SHOW_ATTRIBUTE, expression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(REQUIRED_FIELD_MESSAGE); documentBuilder .startElement(divElement) .endElement(); }
protected void renderInvalidValueMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT); String formFieldId = formField.getId(); String expression = String.format(REQUIRED_ERROR_EXPRESSION, formFieldId); divElement .attribute(NG_SHOW_ATTRIBUTE, expression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(REQUIRED_FIELD_MESSAGE); documentBuilder .startElement(divElement) .endElement(); }
protected void renderInvalidValueMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT); String formFieldId = formField.getId(); String expression = String.format(REQUIRED_ERROR_EXPRESSION, formFieldId); divElement .attribute(NG_SHOW_ATTRIBUTE, expression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(REQUIRED_FIELD_MESSAGE); documentBuilder .startElement(divElement) .endElement(); }
@SuppressWarnings("unchecked") protected void addHtmlSection(HtmlDocumentBuilder builder, String title, Object section, int level) { // add heading builder.startElement(new HtmlElementWriter("h" + level).textContent(title)).endElement(); if (section instanceof Map) { Map<String, Object> sections = (Map<String, Object>) section; addHtmlSections(builder, sections, level + 1); } else { TabularResultSet resultSet = (TabularResultSet) section; addHtmlTable(builder, resultSet); } }
protected void renderInvalidTypeMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT); String formFieldId = formField.getId(); String expression = String.format(TYPE_ERROR_EXPRESSION, formFieldId); String typeName = formField.getTypeName(); if (isEnum(formField)) { typeName = StringFormType.TYPE_NAME; } divElement .attribute(NG_SHOW_ATTRIBUTE, expression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(String.format(TYPE_FIELD_MESSAGE, typeName)); documentBuilder .startElement(divElement) .endElement(); }
protected void renderInvalidTypeMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT); String formFieldId = formField.getId(); String expression = String.format(TYPE_ERROR_EXPRESSION, formFieldId); String typeName = formField.getTypeName(); if (isEnum(formField)) { typeName = StringFormType.TYPE_NAME; } divElement .attribute(NG_SHOW_ATTRIBUTE, expression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(String.format(TYPE_FIELD_MESSAGE, typeName)); documentBuilder .startElement(divElement) .endElement(); }
protected void renderInvalidTypeMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT); String formFieldId = formField.getId(); String expression = String.format(TYPE_ERROR_EXPRESSION, formFieldId); String typeName = formField.getTypeName(); if (isEnum(formField)) { typeName = StringFormType.TYPE_NAME; } divElement .attribute(NG_SHOW_ATTRIBUTE, expression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(String.format(TYPE_FIELD_MESSAGE, typeName)); documentBuilder .startElement(divElement) .endElement(); }
protected void renderInvalidTypeMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT); String formFieldId = formField.getId(); String expression = String.format(TYPE_ERROR_EXPRESSION, formFieldId); String typeName = formField.getTypeName(); if (isEnum(formField)) { typeName = StringFormType.TYPE_NAME; } divElement .attribute(NG_SHOW_ATTRIBUTE, expression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(String.format(TYPE_FIELD_MESSAGE, typeName)); documentBuilder .startElement(divElement) .endElement(); }
protected void renderInvalidDateMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { String formFieldId = formField.getId(); HtmlElementWriter firstDivElement = new HtmlElementWriter(DIV_ELEMENT); String firstExpression = String.format(REQUIRED_ERROR_EXPRESSION + " && !" + DATE_ERROR_EXPRESSION, formFieldId, formFieldId); firstDivElement .attribute(NG_SHOW_ATTRIBUTE, firstExpression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(REQUIRED_FIELD_MESSAGE); documentBuilder .startElement(firstDivElement) .endElement(); HtmlElementWriter secondDivElement = new HtmlElementWriter(DIV_ELEMENT); String secondExpression = String.format(DATE_ERROR_EXPRESSION, formFieldId); secondDivElement .attribute(NG_SHOW_ATTRIBUTE, secondExpression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(INVALID_DATE_FIELD_MESSAGE); documentBuilder .startElement(secondDivElement) .endElement(); }
protected void renderInvalidDateMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { String formFieldId = formField.getId(); HtmlElementWriter firstDivElement = new HtmlElementWriter(DIV_ELEMENT); String firstExpression = String.format(REQUIRED_ERROR_EXPRESSION + " && !" + DATE_ERROR_EXPRESSION, formFieldId, formFieldId); firstDivElement .attribute(NG_SHOW_ATTRIBUTE, firstExpression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(REQUIRED_FIELD_MESSAGE); documentBuilder .startElement(firstDivElement) .endElement(); HtmlElementWriter secondDivElement = new HtmlElementWriter(DIV_ELEMENT); String secondExpression = String.format(DATE_ERROR_EXPRESSION, formFieldId); secondDivElement .attribute(NG_SHOW_ATTRIBUTE, secondExpression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(INVALID_DATE_FIELD_MESSAGE); documentBuilder .startElement(secondDivElement) .endElement(); }
protected void renderInvalidDateMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { String formFieldId = formField.getId(); HtmlElementWriter firstDivElement = new HtmlElementWriter(DIV_ELEMENT); String firstExpression = String.format(REQUIRED_ERROR_EXPRESSION + " && !" + DATE_ERROR_EXPRESSION, formFieldId, formFieldId); firstDivElement .attribute(NG_SHOW_ATTRIBUTE, firstExpression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(REQUIRED_FIELD_MESSAGE); documentBuilder .startElement(firstDivElement) .endElement(); HtmlElementWriter secondDivElement = new HtmlElementWriter(DIV_ELEMENT); String secondExpression = String.format(DATE_ERROR_EXPRESSION, formFieldId); secondDivElement .attribute(NG_SHOW_ATTRIBUTE, secondExpression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(INVALID_DATE_FIELD_MESSAGE + "'" + formField.getType().getInformation(DATE_PATTERN_ATTRIBUTE) + "'"); documentBuilder .startElement(secondDivElement) .endElement(); }
protected void renderInvalidDateMessage(FormField formField, HtmlDocumentBuilder documentBuilder) { String formFieldId = formField.getId(); HtmlElementWriter firstDivElement = new HtmlElementWriter(DIV_ELEMENT); String firstExpression = String.format(REQUIRED_ERROR_EXPRESSION + " && !" + DATE_ERROR_EXPRESSION, formFieldId, formFieldId); firstDivElement .attribute(NG_SHOW_ATTRIBUTE, firstExpression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(REQUIRED_FIELD_MESSAGE); documentBuilder .startElement(firstDivElement) .endElement(); HtmlElementWriter secondDivElement = new HtmlElementWriter(DIV_ELEMENT); String secondExpression = String.format(DATE_ERROR_EXPRESSION, formFieldId); secondDivElement .attribute(NG_SHOW_ATTRIBUTE, secondExpression) .attribute(CLASS_ATTRIBUTE, HELP_BLOCK_CLASS) .textContent(INVALID_DATE_FIELD_MESSAGE + "'" + formField.getType().getInformation(DATE_PATTERN_ATTRIBUTE) + "'"); documentBuilder .startElement(secondDivElement) .endElement(); }
protected void addHtmlHead(HtmlDocumentBuilder builder) { builder .startElement(new HtmlElementWriter("head")) .startElement(new HtmlElementWriter("title").textContent(reportName)).endElement() .startElement(new HtmlElementWriter("link") .attribute("rel", "stylesheet") .attribute("href", "http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css")) .endElement() .startElement(new HtmlElementWriter("link") .attribute("rel", "stylesheet") .attribute("href", "http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css")) .endElement() .endElement(); }
protected void addHtmlBody(HtmlDocumentBuilder builder) { builder.startElement(new HtmlElementWriter("body")); builder.startElement(new HtmlElementWriter("div").attribute("class", "container")); builder.startElement(new HtmlElementWriter("div").attribute("class", "row")); builder.startElement(new HtmlElementWriter("div").attribute("class", "coll-md-12")); builder.startElement(new HtmlElementWriter("h1").textContent(reportName)).endElement(); addHtmlSections(builder, sections, 3); builder.endElement(); builder.endElement(); builder.endElement(); builder.endElement(); }