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 addCommonFormFieldAttributes(FormField formField, HtmlElementWriter formControl) { String typeName = formField.getTypeName(); if (isEnum(formField) || isDate(formField)) { typeName = StringFormType.TYPE_NAME; } typeName = typeName.substring(0, 1).toUpperCase() + typeName.substring(1); String formFieldId = formField.getId(); formControl .attribute(CLASS_ATTRIBUTE, FORM_CONTROL_CLASS) .attribute(NAME_ATTRIBUTE, formFieldId) .attribute(CAM_VARIABLE_TYPE_ATTRIBUTE, typeName) .attribute(CAM_VARIABLE_NAME_ATTRIBUTE, formFieldId); // add validation constraints for (FormFieldValidationConstraint constraint : formField.getValidationConstraints()) { String constraintName = constraint.getName(); String configuration = (String) constraint.getConfiguration(); formControl.attribute(constraintName, configuration); } }
protected void addCommonFormFieldAttributes(FormField formField, HtmlElementWriter formControl) { String typeName = formField.getTypeName(); if (isEnum(formField) || isDate(formField)) { typeName = StringFormType.TYPE_NAME; } typeName = typeName.substring(0, 1).toUpperCase() + typeName.substring(1); String formFieldId = formField.getId(); formControl .attribute(CLASS_ATTRIBUTE, FORM_CONTROL_CLASS) .attribute(NAME_ATTRIBUTE, formFieldId) .attribute(CAM_VARIABLE_TYPE_ATTRIBUTE, typeName) .attribute(CAM_VARIABLE_NAME_ATTRIBUTE, formFieldId); // add validation constraints for (FormFieldValidationConstraint constraint : formField.getValidationConstraints()) { String constraintName = constraint.getName(); String configuration = (String) constraint.getConfiguration(); formControl.attribute(constraintName, configuration); } }
protected void renderFormField(FormField formField, HtmlDocumentBuilder documentBuilder) { // start group HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT) .attribute(CLASS_ATTRIBUTE, FORM_GROUP_CLASS); documentBuilder.startElement(divElement); String formFieldId = formField.getId(); String formFieldLabel = formField.getLabel(); // write label if (formFieldLabel != null && !formFieldLabel.isEmpty()) { HtmlElementWriter labelElement = new HtmlElementWriter(LABEL_ELEMENT) .attribute(FOR_ATTRIBUTE, formFieldId) .textContent(formFieldLabel); // <label for="...">...</label> documentBuilder.startElement(labelElement).endElement(); } // render form control if(isEnum(formField)) { // <select ...> renderSelectBox(formField, documentBuilder); } else if (isDate(formField)){ renderDatePicker(formField, documentBuilder); } else { // <input ...> renderInputField(formField, documentBuilder); } renderInvalidMessageElement(formField, documentBuilder); // end group documentBuilder.endElement(); }
protected void renderFormField(FormField formField, HtmlDocumentBuilder documentBuilder) { // start group HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT) .attribute(CLASS_ATTRIBUTE, FORM_GROUP_CLASS); documentBuilder.startElement(divElement); String formFieldId = formField.getId(); String formFieldLabel = formField.getLabel(); // write label if (formFieldLabel != null && !formFieldLabel.isEmpty()) { HtmlElementWriter labelElement = new HtmlElementWriter(LABEL_ELEMENT) .attribute(FOR_ATTRIBUTE, formFieldId) .textContent(formFieldLabel); // <label for="...">...</label> documentBuilder.startElement(labelElement).endElement(); } // render form control if(isEnum(formField)) { // <select ...> renderSelectBox(formField, documentBuilder); } else if (isDate(formField)){ renderDatePicker(formField, documentBuilder); } else { // <input ...> renderInputField(formField, documentBuilder); } renderInvalidMessageElement(formField, documentBuilder); // end group documentBuilder.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 addCommonFormFieldAttributes(FormField formField, HtmlElementWriter formControl) { String typeName = formField.getTypeName(); if (isEnum(formField) || isDate(formField)) { typeName = StringFormType.TYPE_NAME; } typeName = typeName.substring(0, 1).toUpperCase() + typeName.substring(1); String formFieldId = formField.getId(); formControl .attribute(CLASS_ATTRIBUTE, FORM_CONTROL_CLASS) .attribute(NAME_ATTRIBUTE, formFieldId) .attribute(CAM_VARIABLE_TYPE_ATTRIBUTE, typeName) .attribute(CAM_VARIABLE_NAME_ATTRIBUTE, formFieldId); // add validation constraints for (FormFieldValidationConstraint constraint : formField.getValidationConstraints()) { String constraintName = constraint.getName(); String configuration = (String) constraint.getConfiguration(); formControl.attribute(constraintName, configuration); } }
protected void renderFormField(FormField formField, HtmlDocumentBuilder documentBuilder) { // start group HtmlElementWriter divElement = new HtmlElementWriter(DIV_ELEMENT) .attribute(CLASS_ATTRIBUTE, FORM_GROUP_CLASS); documentBuilder.startElement(divElement); String formFieldId = formField.getId(); String formFieldLabel = formField.getLabel(); // write label if (formFieldLabel != null && !formFieldLabel.isEmpty()) { HtmlElementWriter labelElement = new HtmlElementWriter(LABEL_ELEMENT) .attribute(FOR_ATTRIBUTE, formFieldId) .textContent(formFieldLabel); // <label for="...">...</label> documentBuilder.startElement(labelElement).endElement(); } // render form control if(isEnum(formField)) { // <select ...> renderSelectBox(formField, documentBuilder); } else if (isDate(formField)){ renderDatePicker(formField, documentBuilder); } else { // <input ...> renderInputField(formField, documentBuilder); } renderInvalidMessageElement(formField, documentBuilder); // end group documentBuilder.endElement(); }