Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DateItem with valueMap

    Hi,
    when I'm trying to show a special String for certain dates (and also get these special strings as buttons on the DateChooser - but not tried yet).

    I thought to do this with a ValueMap, but the date stays in the textfield and doesn't change.
    Should I do some other kind of formatting (toString on the Date object maybe?) to put as key in the valueMap?

    Code:
    	private VLayout test2() {
    		DynamicForm form = new DynamicForm();
    		
    		DateItem date = new DateItem("date","Input");
    		date.setUseTextField(true);
    		date.setEnforceDate(false);
    		
    		//If user chooses Jan 1st, 2000, change the textual value to 'Start'
    		LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(1);
    		java.util.Date specialDate = new Date(2000-1900,1-1,1); //2000-01-01
    		valueMap.put("1/1/2000", "Start");
    		date.setValueMap(valueMap);
    		date.setValue(specialDate);
    //problem: user still sees "1/1/2000" iso "Start"
    		
    		
    		form.setFields(date);
    		VLayout result = new VLayout();
    		result.addMember(form);
    		return result;
    	}
Working...
X