Search in sources :

Example 16 with XMLAttributeValueFilter

use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.

the class BooleanClass method displayCheckboxEdit.

public void displayCheckboxEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    org.apache.ecs.xhtml.input check = new input(input.checkbox, prefix + name, 1);
    check.setAttributeFilter(new XMLAttributeValueFilter());
    check.setID(prefix + name);
    check.setDisabled(isDisabled());
    // If the (visible) checkbox is unchecked, it will not post anything back so the hidden input by the same
    // name will post back 0 and the save function will save the first entry it finds.
    org.apache.ecs.xhtml.input checkNo = new input(input.hidden, prefix + name, 0);
    checkNo.setAttributeFilter(new XMLAttributeValueFilter());
    try {
        IntegerProperty prop = (IntegerProperty) object.safeget(name);
        if (prop != null) {
            Integer ivalue = (Integer) prop.getValue();
            if (ivalue != null) {
                int value = ivalue.intValue();
                if (value == 1) {
                    check.setChecked(true);
                } else if (value == 0) {
                    check.setChecked(false);
                }
            } else {
                int value = getDefaultValue();
                if (value == 1) {
                    check.setChecked(true);
                } else {
                    check.setChecked(false);
                }
            }
        }
    } catch (Exception e) {
        // This should not happen
        e.printStackTrace();
    }
    buffer.append(check.toString());
    buffer.append(checkNo.toString());
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) IntegerProperty(com.xpn.xwiki.objects.IntegerProperty) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input)

Aggregations

XMLAttributeValueFilter (com.xpn.xwiki.internal.xml.XMLAttributeValueFilter)16 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)13 BaseProperty (com.xpn.xwiki.objects.BaseProperty)12 org.apache.ecs.xhtml.select (org.apache.ecs.xhtml.select)4 XWiki (com.xpn.xwiki.XWiki)3 IntegerProperty (com.xpn.xwiki.objects.IntegerProperty)3 org.apache.ecs.xhtml.option (org.apache.ecs.xhtml.option)3 ListProperty (com.xpn.xwiki.objects.ListProperty)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 org.apache.ecs.xhtml.div (org.apache.ecs.xhtml.div)1 org.apache.ecs.xhtml.label (org.apache.ecs.xhtml.label)1