Search in sources :

Example 6 with XMLAttributeValueFilter

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

the class StringClass method displayEdit.

@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    input input = new input();
    input.setAttributeFilter(new XMLAttributeValueFilter());
    BaseProperty prop = (BaseProperty) object.safeget(name);
    if (prop != null) {
        input.setValue(prop.toText());
    }
    input.setType("text");
    input.setName(prefix + name);
    input.setID(prefix + name);
    input.setSize(getSize());
    input.setDisabled(isDisabled());
    if (isPicker()) {
        input.setClass("suggested");
        String path = "";
        XWiki xwiki = context.getWiki();
        path = xwiki.getURL("Main.WebHome", "view", context);
        String classname = this.getObject().getName();
        String fieldname = this.getName();
        String secondCol = "-", firstCol = "-";
        String script = "\"" + path + "?xpage=suggest&classname=" + classname + "&fieldname=" + fieldname + "&firCol=" + firstCol + "&secCol=" + secondCol + "&\"";
        String varname = "\"input\"";
        input.setOnFocus("new ajaxSuggest(this, {script:" + script + ", varname:" + varname + "} )");
    }
    buffer.append(input.toString());
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) XWiki(com.xpn.xwiki.XWiki) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 7 with XMLAttributeValueFilter

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

the class DBListClass method displayEdit.

// override the method from parent ListClass
@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    // input display
    if (getDisplayType().equals(DISPLAYTYPE_INPUT)) {
        input input = new input();
        input.setAttributeFilter(new XMLAttributeValueFilter());
        input.setType("text");
        input.setSize(getSize());
        boolean changeInputName = false;
        boolean setInpVal = true;
        BaseProperty prop = (BaseProperty) object.safeget(name);
        String value = "";
        String databaseValue = "";
        if (prop != null) {
            value = this.toFormString(prop);
            databaseValue = prop.toText();
        }
        if (isPicker()) {
            input.setClass("suggested");
            String path = "";
            XWiki xwiki = context.getWiki();
            path = xwiki.getURL("Main.WebHome", "view", context);
            String classname = this.getObject().getName();
            String fieldname = this.getName();
            String hibquery = this.getSql();
            String secondCol = "-", firstCol = "-";
            if (hibquery != null && !hibquery.equals("")) {
                firstCol = returnCol(hibquery, true);
                secondCol = returnCol(hibquery, false);
                if (secondCol.compareTo("-") != 0) {
                    changeInputName = true;
                    input hidden = new input();
                    hidden.setAttributeFilter(new XMLAttributeValueFilter());
                    hidden.setID(prefix + name);
                    hidden.setName(prefix + name);
                    hidden.setType("hidden");
                    hidden.setDisabled(isDisabled());
                    if (StringUtils.isNotEmpty(value)) {
                        hidden.setValue(value);
                    }
                    buffer.append(hidden.toString());
                    input.setValue(getValue(databaseValue, hibquery, context));
                    setInpVal = false;
                }
            }
            String script = "\"" + path + "?xpage=suggest&classname=" + classname + "&fieldname=" + fieldname + "&firCol=" + firstCol + "&secCol=" + secondCol + "&\"";
            String varname = "\"input\"";
            String seps = "\"" + this.getSeparators() + "\"";
            if (isMultiSelect()) {
                input.setOnFocus("new ajaxSuggest(this, {script:" + script + ", varname:" + varname + ", seps:" + seps + "} )");
            } else {
                input.setOnFocus("new ajaxSuggest(this, {script:" + script + ", varname:" + varname + "} )");
            }
        }
        if (changeInputName == true) {
            input.setName(prefix + name + "_suggest");
            input.setID(prefix + name + "_suggest");
        } else {
            input.setName(prefix + name);
            input.setID(prefix + name);
        }
        if (setInpVal == true) {
            input.setValue(value);
        }
        input.setDisabled(isDisabled());
        buffer.append(input.toString());
    } else if (getDisplayType().equals(DISPLAYTYPE_RADIO) || getDisplayType().equals(DISPLAYTYPE_CHECKBOX)) {
        displayRadioEdit(buffer, name, prefix, object, context);
    } else {
        displaySelectEdit(buffer, name, prefix, object, context);
    }
    if (!getDisplayType().equals("input")) {
        org.apache.ecs.xhtml.input hidden = new input(input.hidden, prefix + name, "");
        hidden.setAttributeFilter(new XMLAttributeValueFilter());
        buffer.append(hidden);
    }
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) XWiki(com.xpn.xwiki.XWiki) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 8 with XMLAttributeValueFilter

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

the class ListClass method displayEdit.

@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    if (getDisplayType().equals(DISPLAYTYPE_INPUT)) {
        input input = new input();
        input.setAttributeFilter(new XMLAttributeValueFilter());
        BaseProperty prop = (BaseProperty) object.safeget(name);
        if (prop != null) {
            input.setValue(this.toFormString(prop));
        }
        input.setType("text");
        input.setSize(getSize());
        input.setName(prefix + name);
        input.setID(prefix + name);
        input.setDisabled(isDisabled());
        buffer.append(input.toString());
    } else if (getDisplayType().equals(DISPLAYTYPE_RADIO) || getDisplayType().equals(DISPLAYTYPE_CHECKBOX)) {
        displayRadioEdit(buffer, name, prefix, object, context);
    } else {
        displaySelectEdit(buffer, name, prefix, object, context);
    }
    if (!getDisplayType().equals(DISPLAYTYPE_INPUT)) {
        org.apache.ecs.xhtml.input hidden = new input(input.hidden, prefix + name, "");
        hidden.setAttributeFilter(new XMLAttributeValueFilter());
        buffer.append(hidden);
    }
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 9 with XMLAttributeValueFilter

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

the class ListClass method displayHidden.

@Override
public void displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    input input = new input();
    input.setAttributeFilter(new XMLAttributeValueFilter());
    BaseProperty prop = (BaseProperty) object.safeget(name);
    if (prop != null) {
        input.setValue(prop.toText());
    }
    input.setType("hidden");
    input.setName(prefix + name);
    input.setID(prefix + name);
    buffer.append(input.toString());
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 10 with XMLAttributeValueFilter

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

the class ListClass method displayRadioEdit.

protected void displayRadioEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    List<String> list = getList(context);
    Map<String, ListItem> map = getMap(context);
    BaseProperty prop = (BaseProperty) object.safeget(name);
    List<String> selectlist = toList(prop);
    // Add the selected values that are not in the predefined list.
    for (String item : selectlist) {
        // single selection is on) so we don't have to generate a radio/checkbox for the empty value.
        if (!StringUtils.isEmpty(item) && !list.contains(item)) {
            list.add(item);
        }
    }
    // Add options from Set
    int count = 0;
    for (Object rawvalue : list) {
        String value = getElementValue(rawvalue);
        String display = XMLUtils.escape(getDisplayValue(rawvalue, name, map, context));
        input radio = new input((getDisplayType().equals(DISPLAYTYPE_RADIO) && !isMultiSelect()) ? input.radio : input.checkbox, prefix + name, value);
        radio.setAttributeFilter(new XMLAttributeValueFilter());
        radio.setID("xwiki-form-" + name + "-" + object.getNumber() + "-" + count);
        radio.setDisabled(isDisabled());
        if (selectlist.contains(value)) {
            radio.setChecked(true);
        }
        radio.addElement(display);
        buffer.append("<label class=\"xwiki-form-listclass\" for=\"xwiki-form-" + XMLUtils.escape(name) + "-" + object.getNumber() + "-" + count++ + "\">");
        buffer.append(radio.toString());
        buffer.append("</label>");
    }
    // We need a hidden input with an empty value to be able to clear the selected values when no value is selected
    // from the above radio/checkbox buttons.
    org.apache.ecs.xhtml.input hidden = new input(input.hidden, prefix + name, "");
    hidden.setAttributeFilter(new XMLAttributeValueFilter());
    hidden.setDisabled(isDisabled());
    buffer.append(hidden);
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

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