use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.
the class BooleanClass method displaySelectEdit.
public void displaySelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
select select = new select(prefix + name, 1);
select.setAttributeFilter(new XMLAttributeValueFilter());
select.setName(prefix + name);
select.setID(prefix + name);
select.setDisabled(isDisabled());
String String0 = getDisplayValue(context, 0);
String String1 = getDisplayValue(context, 1);
int nb1 = 1;
int nb2 = 2;
option[] options;
if (getDefaultValue() == -1) {
options = new option[] { new option("---", ""), new option(String1, "1"), new option(String0, "0") };
options[0].addElement("---");
options[1].addElement(XMLUtils.escape(String1));
options[2].addElement(XMLUtils.escape(String0));
} else {
options = new option[] { new option(String1, "1"), new option(String0, "0") };
options[0].addElement(XMLUtils.escape(String1));
options[1].addElement(XMLUtils.escape(String0));
nb1 = 0;
nb2 = 1;
}
for (option option : options) {
option.setAttributeFilter(new XMLAttributeValueFilter());
}
try {
IntegerProperty prop = (IntegerProperty) object.safeget(name);
Integer ivalue = (prop == null) ? null : (Integer) prop.getValue();
if (ivalue != null) {
int value = ivalue.intValue();
if (value == 1) {
options[nb1].setSelected(true);
} else if (value == 0) {
options[nb2].setSelected(true);
}
} else {
int value = getDefaultValue();
if (value == 1) {
options[nb1].setSelected(true);
} else if (value == 0) {
options[nb2].setSelected(true);
} else if (value == -1) {
options[0].setSelected(true);
}
}
} catch (Exception e) {
// This should not happen
e.printStackTrace();
}
select.addElement(options);
buffer.append(select.toString());
}
use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.
the class BooleanClass method displayRadioEdit.
public void displayRadioEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
String StringNone = getDisplayValue(context, 2);
String StringTrue = getDisplayValue(context, 1);
String StringFalse = getDisplayValue(context, 0);
div[] inputs;
input radioNone = new input(input.radio, prefix + name, "");
radioNone.setAttributeFilter(new XMLAttributeValueFilter());
input radioTrue = new input(input.radio, prefix + name, "1");
radioTrue.setAttributeFilter(new XMLAttributeValueFilter());
input radioFalse = new input(input.radio, prefix + name, "0");
radioFalse.setAttributeFilter(new XMLAttributeValueFilter());
radioNone.setDisabled(isDisabled());
radioTrue.setDisabled(isDisabled());
radioFalse.setDisabled(isDisabled());
label labelNone = new label();
label labelTrue = new label();
label labelFalse = new label();
div divNone = new div();
div divTrue = new div();
div divFalse = new div();
labelNone.addElement(radioNone);
labelNone.addElement(StringNone);
divNone.addElement(labelNone);
labelTrue.addElement(radioTrue);
labelTrue.addElement(StringTrue);
divTrue.addElement(labelTrue);
labelFalse.addElement(radioFalse);
labelFalse.addElement(StringFalse);
divFalse.addElement(labelFalse);
radioNone.setID(prefix + name + "_none");
labelNone.setFor(prefix + name + "_none");
radioTrue.setID(prefix + name);
labelTrue.setFor(prefix + name);
radioFalse.setID(prefix + name + "_false");
labelFalse.setFor(prefix + name + "_false");
if (getDefaultValue() == -1) {
inputs = new div[] { divNone, divTrue, divFalse };
} else {
inputs = new div[] { divTrue, divFalse };
}
try {
IntegerProperty prop = (IntegerProperty) object.safeget(name);
Integer ivalue = (prop == null) ? null : (Integer) prop.getValue();
if (ivalue != null) {
int value = ivalue.intValue();
if (value == 1) {
radioTrue.setChecked(true);
} else if (value == 0) {
radioFalse.setChecked(true);
}
} else {
int value = getDefaultValue();
if (value == 1) {
radioTrue.setChecked(true);
} else if (value == 0) {
radioFalse.setChecked(true);
} else if (value == -1) {
radioNone.setChecked(true);
}
}
} catch (Exception e) {
// This should not happen
e.printStackTrace();
}
for (div input : inputs) {
buffer.append(input.toString());
}
}
use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.
the class PasswordClass 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);
// the property is set.
if (prop != null && !StringUtils.isEmpty(prop.toText())) {
input.setValue(FORM_PASSWORD_PLACEHODLER);
}
input.setType("password");
input.setName(prefix + name);
input.setID(prefix + name);
input.setSize(getSize());
input.setDisabled(isDisabled());
buffer.append(input.toString());
}
use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.
the class PropertyClass 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());
}
use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter 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);
}
}
Aggregations