Search in sources :

Example 16 with WFieldSet

use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.

the class WFieldSetRenderer method doRender.

/**
 * Paints the given WFieldSet.
 *
 * @param component the WFieldSet to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WFieldSet fieldSet = (WFieldSet) component;
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("ui:fieldset");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendOptionalAttribute("hidden", fieldSet.isHidden(), "true");
    switch(fieldSet.getFrameType()) {
        case NO_BORDER:
            xml.appendOptionalAttribute("frame", "noborder");
            break;
        case NO_TEXT:
            xml.appendOptionalAttribute("frame", "notext");
            break;
        case NONE:
            xml.appendOptionalAttribute("frame", "none");
            break;
        case NORMAL:
        default:
            break;
    }
    xml.appendOptionalAttribute("required", fieldSet.isMandatory(), "true");
    xml.appendClose();
    // Render margin
    MarginRendererUtil.renderMargin(fieldSet, renderContext);
    // Label
    WDecoratedLabel label = fieldSet.getTitle();
    label.paint(renderContext);
    // Children
    xml.appendTag("ui:content");
    int size = fieldSet.getChildCount();
    for (int i = 0; i < size; i++) {
        WComponent child = fieldSet.getChildAt(i);
        // Skip label, as it has already been painted
        if (child != label) {
            child.paint(renderContext);
        }
    }
    xml.appendEndTag("ui:content");
    DiagnosticRenderUtil.renderDiagnostics(fieldSet, renderContext);
    xml.appendEndTag("ui:fieldset");
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WFieldSet(com.github.bordertech.wcomponents.WFieldSet) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder) WDecoratedLabel(com.github.bordertech.wcomponents.WDecoratedLabel)

Example 17 with WFieldSet

use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.

the class WLabelRenderer_Test method testWhatForGroupWFieldSet.

@Test
public void testWhatForGroupWFieldSet() throws IOException, SAXException, XpathException {
    WFieldSet comp = new WFieldSet("legend");
    WLabel label = new WLabel("label", comp);
    assertXpathEvaluatesTo("group", "//ui:label/@what", label);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Aggregations

WFieldSet (com.github.bordertech.wcomponents.WFieldSet)17 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)10 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)6 Test (org.junit.Test)6 WButton (com.github.bordertech.wcomponents.WButton)5 Margin (com.github.bordertech.wcomponents.Margin)4 WLabel (com.github.bordertech.wcomponents.WLabel)4 WField (com.github.bordertech.wcomponents.WField)3 WTextField (com.github.bordertech.wcomponents.WTextField)3 Action (com.github.bordertech.wcomponents.Action)2 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)2 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)2 WDateField (com.github.bordertech.wcomponents.WDateField)2 WDropdown (com.github.bordertech.wcomponents.WDropdown)2 WHeading (com.github.bordertech.wcomponents.WHeading)2 WRadioButton (com.github.bordertech.wcomponents.WRadioButton)2 WTextArea (com.github.bordertech.wcomponents.WTextArea)2 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)2 Disable (com.github.bordertech.wcomponents.subordinate.Disable)2 Enable (com.github.bordertech.wcomponents.subordinate.Enable)2