diff --git a/hsarweb/src/de/hsadmin/web/AbstractModule.java b/hsarweb/src/de/hsadmin/web/AbstractModule.java index 6e9d4f3..e76f7ab 100644 --- a/hsarweb/src/de/hsadmin/web/AbstractModule.java +++ b/hsarweb/src/de/hsadmin/web/AbstractModule.java @@ -82,7 +82,7 @@ public abstract class AbstractModule implements Module, Serializable { public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(childWindow); try { - Map map = new HashMap(); + Map map = new HashMap(); genericForm.transferToHash(map, form); ((InsertAble) thisModule).insertRow(map); componentFactory.loadData(); diff --git a/hsarweb/src/de/hsadmin/web/AbstractProperty.java b/hsarweb/src/de/hsadmin/web/AbstractProperty.java index 2c0455a..e3b894d 100644 --- a/hsarweb/src/de/hsadmin/web/AbstractProperty.java +++ b/hsarweb/src/de/hsadmin/web/AbstractProperty.java @@ -1,7 +1,10 @@ package de.hsadmin.web; -public abstract class AbstractProperty { +public abstract class AbstractProperty implements XmlrpcProperty { + @Override public abstract Object toXmlrpcParam(); - + + public abstract String toStringValue(); + } diff --git a/hsarweb/src/de/hsadmin/web/DatabaseModule.java b/hsarweb/src/de/hsadmin/web/DatabaseModule.java index c62bba0..5a497fa 100644 --- a/hsarweb/src/de/hsadmin/web/DatabaseModule.java +++ b/hsarweb/src/de/hsadmin/web/DatabaseModule.java @@ -122,7 +122,7 @@ public abstract class DatabaseModule extends GenericModule { public List getDatabaseUsers() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap()); + Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { diff --git a/hsarweb/src/de/hsadmin/web/DateProperty.java b/hsarweb/src/de/hsadmin/web/DateProperty.java new file mode 100644 index 0000000..613da8b --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/DateProperty.java @@ -0,0 +1,40 @@ +package de.hsadmin.web; + +import java.text.DateFormat; +import java.text.ParseException; +import java.util.Date; + +public class DateProperty extends AbstractProperty { + + public static final DateFormat serverDf = DateFormat.getDateInstance(DateFormat.SHORT); + + final private Date property; + + public DateProperty(Date propertyValue) { + this.property = propertyValue; + } + + public DateProperty(String propertyValue) { + Date temp = null; + try { + temp = serverDf.parse(propertyValue); + } catch (ParseException e) { + } + property = temp; + } + + @Override + public Object toXmlrpcParam() { + return serverDf.format(property); + } + + @Override + public String toStringValue() { + return serverDf.format(property); + } + + public Date getDateValue() { + return property; + } + +} diff --git a/hsarweb/src/de/hsadmin/web/DeleteAble.java b/hsarweb/src/de/hsadmin/web/DeleteAble.java index 938c12f..1227e30 100644 --- a/hsarweb/src/de/hsadmin/web/DeleteAble.java +++ b/hsarweb/src/de/hsadmin/web/DeleteAble.java @@ -4,6 +4,6 @@ import java.util.Map; public interface DeleteAble { - public void deleteRow(Map paramHash) throws HsarwebException; + public void deleteRow(Map paramHash) throws HsarwebException; } diff --git a/hsarweb/src/de/hsadmin/web/GenericModule.java b/hsarweb/src/de/hsadmin/web/GenericModule.java index f754624..0bd5a17 100644 --- a/hsarweb/src/de/hsadmin/web/GenericModule.java +++ b/hsarweb/src/de/hsadmin/web/GenericModule.java @@ -12,16 +12,16 @@ public abstract class GenericModule extends AbstractModule implements InsertAble private static final long serialVersionUID = 1L; - public void insertRow(Map paramHash) throws HsarwebException { + public void insertRow(Map paramHash) throws HsarwebException { getApplication().getRemote().callAdd(getModuleConfig().getRemoteName(), paramHash); } - public void deleteRow(Map paramHash) throws HsarwebException { + public void deleteRow(Map paramHash) throws HsarwebException { getApplication().getRemote().callDelete(getModuleConfig().getRemoteName(), paramHash); } - public void updateRow(Map paramHash) throws HsarwebException { - Map whereHash = new HashMap(); + public void updateRow(Map paramHash) throws HsarwebException { + Map whereHash = new HashMap(); String idKey = findIdKey(); whereHash.put(idKey, paramHash.get(idKey)); getApplication().getRemote().callUpdate(getModuleConfig().getRemoteName(), paramHash, whereHash); @@ -43,7 +43,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble public List getUsers() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch("user", new HashMap()); + Object callSearch = getApplication().getRemote().callSearch("user", new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { @@ -64,7 +64,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble public List getEMailAliases() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch("emailalias", new HashMap()); + Object callSearch = getApplication().getRemote().callSearch("emailalias", new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { @@ -85,7 +85,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble public List getDomains() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap()); + Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { @@ -106,7 +106,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble public List getPackets() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap()); + Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { diff --git a/hsarweb/src/de/hsadmin/web/HomeModule.java b/hsarweb/src/de/hsadmin/web/HomeModule.java index 65031d5..a109e4d 100644 --- a/hsarweb/src/de/hsadmin/web/HomeModule.java +++ b/hsarweb/src/de/hsadmin/web/HomeModule.java @@ -35,8 +35,8 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda setComponentFactory(this); } - public void updateRow(Map paramHash) throws HsarwebException { - Map whereHash = new HashMap(); + public void updateRow(Map paramHash) throws HsarwebException { + Map whereHash = new HashMap(); String idKey = findIdKey(); whereHash.put(idKey, paramHash.get(idKey)); paramHash.remove(idKey); @@ -94,7 +94,7 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda Button button = new Button(moduleConfig.getLabel("change_password")); ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon")); button.setIcon(icon); - Map whereHash = new HashMap(); + Map whereHash = new HashMap(); whereHash.put("name", new StringProperty(application.getRunAs())); Long key = -1L; try { @@ -130,7 +130,7 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(childWindow); try { - Map map = new HashMap(); + Map map = new HashMap(); map.put("id", new StringProperty(((Long) event.getButton().getData()).toString())); Iterator componentIterator = form.getLayout().getComponentIterator(); while (componentIterator.hasNext()) { diff --git a/hsarweb/src/de/hsadmin/web/InsertAble.java b/hsarweb/src/de/hsadmin/web/InsertAble.java index c7af5a0..f366617 100644 --- a/hsarweb/src/de/hsadmin/web/InsertAble.java +++ b/hsarweb/src/de/hsadmin/web/InsertAble.java @@ -4,6 +4,6 @@ import java.util.Map; public interface InsertAble { - public void insertRow(Map paramHash) throws HsarwebException; + public void insertRow(Map paramHash) throws HsarwebException; } diff --git a/hsarweb/src/de/hsadmin/web/ItemsReader.java b/hsarweb/src/de/hsadmin/web/ItemsReader.java index d1c22d5..ffd372b 100644 --- a/hsarweb/src/de/hsadmin/web/ItemsReader.java +++ b/hsarweb/src/de/hsadmin/web/ItemsReader.java @@ -9,7 +9,7 @@ public class ItemsReader { public static List readItemList(MainApplication app, String module, String property) throws HsarwebException { final List itemsList = new ArrayList(); - Object custListObj = app.getRemote().callSearch(module, new HashMap()); + Object custListObj = app.getRemote().callSearch(module, new HashMap()); if (custListObj instanceof Object[]) { Object[] custList = (Object[]) custListObj; for (Object custObj : custList) { diff --git a/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java b/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java index 6a2366d..97358f0 100644 --- a/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java +++ b/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java @@ -1,9 +1,10 @@ package de.hsadmin.web; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; -public class ListOfStringsProperty extends AbstractProperty { +public class ListOfStringsProperty implements XmlrpcProperty { public final List properties; @@ -25,4 +26,8 @@ public class ListOfStringsProperty extends AbstractProperty { } return result; } + + public Iterator stringsIterator() { + return properties.iterator(); + } } diff --git a/hsarweb/src/de/hsadmin/web/Remote.java b/hsarweb/src/de/hsadmin/web/Remote.java index df819aa..9261aaa 100644 --- a/hsarweb/src/de/hsadmin/web/Remote.java +++ b/hsarweb/src/de/hsadmin/web/Remote.java @@ -18,23 +18,23 @@ public class Remote { this.app = application; } - public Object callSearch(String module, Map where) throws HsarwebException { + public Object callSearch(String module, Map where) throws HsarwebException { return xmlrpcCall(module, "search", buildXmlrpcParam(where)); } - public void callAdd(String module, Map set) throws HsarwebException { + public void callAdd(String module, Map set) throws HsarwebException { xmlrpcCall(module, "add", buildXmlrpcParam(set)); } - public void callUpdate(String module, Map set, Map where) throws HsarwebException { + public void callUpdate(String module, Map set, Map where) throws HsarwebException { xmlrpcCall(module, "update", buildXmlrpcParam(set), buildXmlrpcParam(where)); } - public void callDelete(String module, Map where) throws HsarwebException { + public void callDelete(String module, Map where) throws HsarwebException { xmlrpcCall(module, "delete", buildXmlrpcParam(where)); } - private Map buildXmlrpcParam(Map paramHash) { + private Map buildXmlrpcParam(Map paramHash) { Map resultMap = new HashMap(); if (paramHash == null) { return null; diff --git a/hsarweb/src/de/hsadmin/web/StringProperty.java b/hsarweb/src/de/hsadmin/web/StringProperty.java index daf67f6..615ff25 100644 --- a/hsarweb/src/de/hsadmin/web/StringProperty.java +++ b/hsarweb/src/de/hsadmin/web/StringProperty.java @@ -2,15 +2,28 @@ package de.hsadmin.web; public class StringProperty extends AbstractProperty { - public String property ; + final public String property ; public StringProperty(String property) { this.property = property; } + public StringProperty(Object value) { + String temp = "undefined"; + if (value instanceof String) { + temp = (String) value; + } + this.property = temp; + } + @Override public Object toXmlrpcParam() { return property; } + @Override + public String toStringValue() { + return property; + } + } diff --git a/hsarweb/src/de/hsadmin/web/UpdateAble.java b/hsarweb/src/de/hsadmin/web/UpdateAble.java index 1753c09..cec5cff 100644 --- a/hsarweb/src/de/hsadmin/web/UpdateAble.java +++ b/hsarweb/src/de/hsadmin/web/UpdateAble.java @@ -4,6 +4,6 @@ import java.util.Map; public interface UpdateAble { - public void updateRow(Map paramHash) throws HsarwebException; + public void updateRow(Map paramHash) throws HsarwebException; } diff --git a/hsarweb/src/de/hsadmin/web/XmlrpcProperty.java b/hsarweb/src/de/hsadmin/web/XmlrpcProperty.java new file mode 100644 index 0000000..ea15516 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/XmlrpcProperty.java @@ -0,0 +1,7 @@ +package de.hsadmin.web; + +public interface XmlrpcProperty { + + public abstract Object toXmlrpcParam(); + +} \ No newline at end of file diff --git a/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java index 95d7cd0..7a2a6d3 100644 --- a/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java @@ -1,13 +1,13 @@ package de.hsadmin.web.config; -import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; +import de.hsadmin.web.XmlrpcProperty; public interface PropertyFieldFactory { - public Object createFieldComponent(PropertyConfig prop, Object value); + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value); - public AbstractProperty getValue(PropertyConfig prop, Object component) throws HsarwebException; + public XmlrpcProperty getValue(PropertyConfig prop, Object component) throws HsarwebException; public void setReadOnly(boolean readOnly); diff --git a/hsarweb/src/de/hsadmin/web/vaadin/DatePropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/DatePropertyFieldFactory.java index c973d70..5fff817 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/DatePropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/DatePropertyFieldFactory.java @@ -11,7 +11,9 @@ import com.vaadin.ui.DateField; import com.vaadin.ui.PopupDateField; import de.hsadmin.web.AbstractProperty; +import de.hsadmin.web.DateProperty; import de.hsadmin.web.StringProperty; +import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -23,14 +25,21 @@ public class DatePropertyFieldFactory implements PropertyFieldFactory { private boolean writeOnce = false; @Override - public Object createFieldComponent(PropertyConfig prop, Object value) { + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { DateField dateField = new PopupDateField(prop.getLabel()); dateField.setDateFormat("dd.MM.yyyy"); dateField.setData(prop.getId()); dateField.setWidth(480.0f, Sizeable.UNITS_PIXELS); try { if (value != null) { - dateField.setValue(serverDf.parse((String) value)); + if (value instanceof AbstractProperty) { + if (value instanceof StringProperty) { + dateField.setValue(DateProperty.serverDf.parse(((StringProperty) value).toStringValue())); + } + if (value instanceof DateProperty) { + dateField.setValue(((DateProperty) value).getDateValue()); + } + } dateField.setReadOnly(isReadOnly()); return dateField; } diff --git a/hsarweb/src/de/hsadmin/web/vaadin/DefaultPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/DefaultPropertyFieldFactory.java index 1089fe3..3783767 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/DefaultPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/DefaultPropertyFieldFactory.java @@ -5,6 +5,7 @@ import com.vaadin.ui.TextField; import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.StringProperty; +import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -14,11 +15,15 @@ public class DefaultPropertyFieldFactory implements PropertyFieldFactory { private boolean writeOnce = false; @Override - public Object createFieldComponent(PropertyConfig prop, Object value) { + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { TextField tf = new TextField(prop.getLabel()); tf.setData(prop.getId()); tf.setWidth(480.0f, Sizeable.UNITS_PIXELS); - tf.setValue(value != null ? value : prop.getDefaultValue()); + String valueOrDefault = prop.getDefaultValue(); + if (value instanceof AbstractProperty) { + valueOrDefault = ((AbstractProperty) value).toStringValue(); + } + tf.setValue(valueOrDefault); tf.setReadOnly(isReadOnly()); return tf; } diff --git a/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java index cd0d3d5..fd00e75 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java @@ -1,22 +1,17 @@ -/** - * - */ package de.hsadmin.web.vaadin; import java.util.HashMap; import java.util.Map; -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.terminal.Sizeable; import com.vaadin.ui.AbstractField; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Select; import com.vaadin.ui.VerticalLayout; import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.ListOfStringsProperty; +import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -49,13 +44,13 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory { } @Override - public Object createFieldComponent(PropertyConfig prop, Object value) { + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { // TODO Auto-generated method stub return null; } @Override - public AbstractProperty getValue(PropertyConfig prop, Object component) + public XmlrpcProperty getValue(PropertyConfig prop, Object component) throws HsarwebException { return setOptions; } diff --git a/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java index b6a4d98..0b9b549 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java @@ -1,6 +1,7 @@ package de.hsadmin.web.vaadin; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; @@ -18,8 +19,10 @@ import com.vaadin.ui.VerticalLayout; import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.GenericModule; import de.hsadmin.web.HsarwebException; +import de.hsadmin.web.ListOfStringsProperty; import de.hsadmin.web.Module; import de.hsadmin.web.StringProperty; +import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -61,7 +64,7 @@ public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory { } @Override - public Object createFieldComponent(PropertyConfig prop, Object value) { + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { GenericModule genModule = (GenericModule) module; users = genModule.getUsers(); mailAliases = genModule.getEMailAliases(); @@ -71,21 +74,21 @@ public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory { targets = new HashMap(); lastIndex = 0; - if (value instanceof String) { - StringTokenizer tokenizer = new StringTokenizer((String) value, ","); + if (value instanceof AbstractProperty) { + String stringValue = ((AbstractProperty) value).toStringValue(); + StringTokenizer tokenizer = new StringTokenizer(stringValue, ","); while (tokenizer.hasMoreTokens()) { String target = tokenizer.nextToken().trim(); targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, target)); lastIndex++; } } - if (value instanceof Object[]) { - Object[] list = (Object[]) value; - for (Object o : list) { - if (o instanceof String) { - targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, (String) o)); - lastIndex++; - } + if (value instanceof ListOfStringsProperty) { + ListOfStringsProperty list = (ListOfStringsProperty) value; + Iterator stringsIterator = list.stringsIterator(); + while (stringsIterator.hasNext()) { + targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, stringsIterator.next())); + lastIndex++; } } targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, "")); diff --git a/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java b/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java index bc60ef1..e10c3b7 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java @@ -10,11 +10,12 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Layout; -import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; +import de.hsadmin.web.ListOfStringsProperty; import de.hsadmin.web.MainApplication; import de.hsadmin.web.Module; import de.hsadmin.web.StringProperty; +import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -48,7 +49,7 @@ public class GenericForm { try { MainApplication application = module.getApplication(); ModuleConfig config = module.getModuleConfig(); - Map where = new HashMap(); + Map where = new HashMap(); where.put(findIdKey(), new StringProperty(entityId.toString())); Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where); if (searchResult instanceof Object[]) { @@ -60,7 +61,18 @@ public class GenericForm { for (PropertyConfig prop : config.getPropertyList()) { if (!prop.getPropTableColumn().equals(PropertyTableColumn.INTERNAL_KEY) && prop.isShowInForm()) { PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory(); - Object value = row.get(prop.getId()); + Object propValue = row.get(prop.getId()); + XmlrpcProperty value = new StringProperty(""); + if (propValue instanceof Object[]) { + ListOfStringsProperty list = new ListOfStringsProperty(); + for (Object o : ((Object[]) propValue)) { + list.add(o.toString()); + } + value = list; + } + if (propValue instanceof String) { + value = new StringProperty(propValue); + } Component component = (Component) propFieldFactory.createFieldComponent(prop, value); if (propFieldFactory.isWriteOnce()) { component.setReadOnly(true); @@ -81,7 +93,7 @@ public class GenericForm { try { MainApplication application = module.getApplication(); ModuleConfig config = module.getModuleConfig(); - Map where = new HashMap(); + Map where = new HashMap(); where.put(findIdKey(), new StringProperty(entityId.toString())); Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where); if (searchResult instanceof Object[]) { @@ -96,7 +108,8 @@ public class GenericForm { && prop.getPropTableColumn().equals(PropertyTableColumn.DISPLAY)) { PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory(); Object value = row.get(prop.getId()); - Component component = (Component) propFieldFactory.createFieldComponent(prop, value); + StringProperty propValue = new StringProperty(value); + Component component = (Component) propFieldFactory.createFieldComponent(prop, propValue); component.setReadOnly(true); layout.addComponent(component); } @@ -123,7 +136,7 @@ public class GenericForm { return idKey; } - public void transferToHash(Map map, Form form) throws HsarwebException { + public void transferToHash(Map map, Form form) throws HsarwebException { Iterator iterator = form.getLayout().getComponentIterator(); Object formData = form.getData(); if (formData != null && formData instanceof Long) { diff --git a/hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java index 368f570..2a7fd26 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java @@ -11,6 +11,7 @@ import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.Module; import de.hsadmin.web.StringProperty; +import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -28,7 +29,7 @@ public class PacPrefixedNamePropertyFieldFactory implements PropertyFieldFactory } @Override - public Object createFieldComponent(PropertyConfig prop, Object value) { + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { ModuleConfig config = module.getModuleConfig(); HorizontalLayout layout = new HorizontalLayout(); layout.setCaption(prop.getLabel()); @@ -55,7 +56,10 @@ public class PacPrefixedNamePropertyFieldFactory implements PropertyFieldFactory tf.setData(prop.getId()); tf.setWidth(384.0f, Sizeable.UNITS_PIXELS); layout.addComponent(tf); - String valueOrDefault = (value != null && value instanceof String) ? ((String) value) : prop.getDefaultValue(); + String valueOrDefault = prop.getDefaultValue(); + if (value instanceof AbstractProperty) { + valueOrDefault = ((AbstractProperty) value).toStringValue(); + } if (valueOrDefault.length() >= 5) { sel.setValue(valueOrDefault.substring(0, 5)); tf.setValue(valueOrDefault.length() > 6 ? valueOrDefault.substring(6) : ""); diff --git a/hsarweb/src/de/hsadmin/web/vaadin/PasswordPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/PasswordPropertyFieldFactory.java index 6367152..2c99086 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/PasswordPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/PasswordPropertyFieldFactory.java @@ -8,6 +8,7 @@ import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.Module; import de.hsadmin.web.StringProperty; +import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -24,7 +25,7 @@ public class PasswordPropertyFieldFactory implements PropertyFieldFactory { } @Override - public Object createFieldComponent(PropertyConfig prop, Object value) { + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { ModuleConfig config = module.getModuleConfig(); VerticalLayout layout = new VerticalLayout(); layout.setCaption(prop.getLabel()); @@ -32,13 +33,17 @@ public class PasswordPropertyFieldFactory implements PropertyFieldFactory { PasswordField tf1 = new PasswordField(config.getLabel(prop.getId() + "1")); tf1.setData(prop.getId()); tf1.setWidth(480.0f, Sizeable.UNITS_PIXELS); - tf1.setValue(value != null ? value : prop.getDefaultValue()); + String valueOrDefault = prop.getDefaultValue(); + if (value instanceof AbstractProperty) { + valueOrDefault = ((AbstractProperty) value).toStringValue(); + } + tf1.setValue(valueOrDefault); tf1.setReadOnly(readOnly); layout.addComponent(tf1); PasswordField tf2 = new PasswordField(config.getLabel(prop.getId() + "2")); tf2.setData(prop.getId()); tf2.setWidth(480.0f, Sizeable.UNITS_PIXELS); - tf2.setValue(value != null ? value : prop.getDefaultValue()); + tf2.setValue(valueOrDefault); tf2.setReadOnly(readOnly); layout.addComponent(tf2); return layout; diff --git a/hsarweb/src/de/hsadmin/web/vaadin/SelectPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/SelectPropertyFieldFactory.java index 6850a1d..7381153 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/SelectPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/SelectPropertyFieldFactory.java @@ -8,6 +8,7 @@ import com.vaadin.ui.Select; import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.StringProperty; +import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -17,7 +18,7 @@ public class SelectPropertyFieldFactory implements PropertyFieldFactory { private boolean writeOnce = false; @Override - public Object createFieldComponent(PropertyConfig prop, Object value) { + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { Select sel = new Select(prop.getLabel()); sel.setData(prop.getId()); sel.setNullSelectionAllowed(false); @@ -28,7 +29,11 @@ public class SelectPropertyFieldFactory implements PropertyFieldFactory { sel.setItemCaption(key, selectValues.get(key)); } sel.setWidth(480.0f, Sizeable.UNITS_PIXELS); - sel.setValue(value != null ? value : prop.getDefaultValue()); + String valueOrDefault = prop.getDefaultValue(); + if (value instanceof AbstractProperty) { + valueOrDefault = ((AbstractProperty) value).toStringValue(); + } + sel.setValue(valueOrDefault); sel.setReadOnly(readOnly); sel.setInvalidAllowed(prop.newItemsAllowed()); return sel; diff --git a/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java index 0eaf71d..a6c7df8 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java @@ -21,13 +21,13 @@ import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.themes.BaseTheme; -import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.DeleteAble; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.MainApplication; import de.hsadmin.web.Module; import de.hsadmin.web.StringProperty; import de.hsadmin.web.UpdateAble; +import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.config.ComponentFactory; import de.hsadmin.web.config.LocaleConfig; import de.hsadmin.web.config.ModuleConfig; @@ -108,7 +108,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable { table.removeAllItems(); try { ModuleConfig moduleConfig = module.getModuleConfig(); - Object callSearch = module.getApplication().getRemote().callSearch(moduleConfig.getRemoteName(), new HashMap()); + Object callSearch = module.getApplication().getRemote().callSearch(moduleConfig.getRemoteName(), new HashMap()); List propertyList = moduleConfig.getPropertyList(); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { @@ -230,7 +230,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable { public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(childWindow); try { - Map map = new HashMap(); + Map map = new HashMap(); genericForm.transferToHash(map, form); ((UpdateAble) module).updateRow(map); loadData(); @@ -289,7 +289,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable { public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(childWindow); try { - Map map = new HashMap(); + Map map = new HashMap(); map.put(findIdKey(), new StringProperty(((Long) button.getData()).toString())); ((DeleteAble) module).deleteRow(map); loadData();