64 lines
1.7 KiB
Java
64 lines
1.7 KiB
Java
package models.components.commons.datafield;
|
|
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Element;
|
|
import org.w3c.dom.Node;
|
|
import org.w3c.dom.NodeList;
|
|
|
|
import models.components.commons.datafield.ComboBoxData.Option;
|
|
|
|
public class AutoCompleteData extends ComboBoxData<AutoCompleteData>{
|
|
private String url;
|
|
private Option autoCompleteOptions;
|
|
|
|
@Override
|
|
public Element toXml(Document doc) {
|
|
Element root = super.toXml(doc);
|
|
|
|
root.setAttribute("url", this.url);
|
|
|
|
Element element = doc.createElement("option");
|
|
element.setAttribute("label", this.autoCompleteOptions.getLabel());
|
|
element.setAttribute("value", autoCompleteOptions.getValue());
|
|
root.appendChild(element);
|
|
return root;
|
|
}
|
|
@Override
|
|
public AutoCompleteData fromXml(Element item) {
|
|
super.fromXml(item);
|
|
this.url = item.getAttribute("url");
|
|
Element optionElement = (Element)item.getElementsByTagName("option").item(0);
|
|
|
|
if(optionElement!=null){
|
|
this.autoCompleteOptions = new Option();
|
|
this.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
|
|
this.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
|
|
}
|
|
return this;
|
|
}
|
|
@Override
|
|
public AutoCompleteData fromData(Object data) {
|
|
super.fromData(data);
|
|
this.autoCompleteOptions = new Option();
|
|
if(data!=null){
|
|
this.url = (String)((Map<String,Object>)data).get("url");
|
|
Map<String,String> options = ((Map<String,Map<String,String>>)data).get("option");
|
|
this.autoCompleteOptions.setLabel(options.get("label"));
|
|
this.autoCompleteOptions.setValue(options.get("value"));
|
|
}
|
|
|
|
return this;
|
|
}
|
|
@Override
|
|
public Object toData() {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
|
|
}
|