Search in sources :

Example 26 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class StaticListClass 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());
        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\"";
            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 + "} )");
            }
        }
        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);
        // We need a hidden input with an empty value to be able to clear the selected values from the above select
        // when it has multiple selection enabled and no value selected.
        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) XWiki(com.xpn.xwiki.XWiki) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 27 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty 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 28 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class TextAreaClass method newProperty.

@Override
public BaseProperty newProperty() {
    BaseProperty property = new LargeStringProperty();
    property.setName(getName());
    return property;
}
Also used : LargeStringProperty(com.xpn.xwiki.objects.LargeStringProperty) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 29 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class UsersClass method fromString.

@Override
public BaseProperty fromString(String value) {
    BaseProperty prop = newProperty();
    prop.setValue(value);
    return prop;
}
Also used : BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 30 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty 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)

Aggregations

BaseProperty (com.xpn.xwiki.objects.BaseProperty)87 BaseObject (com.xpn.xwiki.objects.BaseObject)26 ArrayList (java.util.ArrayList)16 XWikiException (com.xpn.xwiki.XWikiException)14 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)12 XMLAttributeValueFilter (com.xpn.xwiki.internal.xml.XMLAttributeValueFilter)12 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)11 XWikiContext (com.xpn.xwiki.XWikiContext)10 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)9 DocumentReference (org.xwiki.model.reference.DocumentReference)9 StringProperty (com.xpn.xwiki.objects.StringProperty)8 ListProperty (com.xpn.xwiki.objects.ListProperty)7 XWiki (com.xpn.xwiki.XWiki)5 BaseCollection (com.xpn.xwiki.objects.BaseCollection)5 LargeStringProperty (com.xpn.xwiki.objects.LargeStringProperty)5 List (java.util.List)5 Test (org.junit.Test)5 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)5 DBStringListProperty (com.xpn.xwiki.objects.DBStringListProperty)4 PropertyClass (com.xpn.xwiki.objects.classes.PropertyClass)4