An idea is to wrap the Properties object in a class of your own implementing Map as follows:
class MyProps implements Map<String, String> { Properties props; public void put(String key, String value) { if (value == null) props.remove(key); else props.put(key, value); } This does sound like a bug in PropertyResolver as it should probably test whether the Map is a Hashtable and call remove() since Hashtable is documented to throw an NPE when put() is called with a null value. On Fri, Oct 18, 2013 at 1:55 PM, Andy Van Den Heuvel < andy.vandenheu...@gmail.com> wrote: > Hey, > > I'm trying to create a form with a CompoundPropertyModel to fill a > java.util.Properties object dynamically. > > Form<Properties> form = new Form<>("form", new > CompoundPropertyModel<>(properties)); > form.add(new TextField<String>("host")); > form.add(new TextField<String>("port")); > > This works correct when I start from an empty java.util.Properties object. > If I have an existing java.util.Properties object (with filled data) > and I remove the value in the html page, I want the key-value pair to be > deleted from the Properties object. > > With my current implementation I get a stacktrace (because it tries to > write a null value in the java.util.Properties object) > > java.lang.NullPointerException > at java.util.Hashtable.put(Hashtable.java:432) > at > > org.apache.wicket.core.util.lang.PropertyResolver$MapGetSet.setValue(PropertyResolver.java:803) > at > > org.apache.wicket.core.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:644) > at > > org.apache.wicket.core.util.lang.PropertyResolver.setValue(PropertyResolver.java:144) > > > Has anybody have an idea how best to create this behaviour? > Thanks in advance for your help! >