Inline date field

Hi all,

I tried not to use the datefield as one component but tried to separe it into three major components (the textfield containing the date, a subWindow containing an inlinedatefield and the buttom to show subWindow containing the InlineDateField)

What I want is to close the subWindow containing the InlineDateField once the user clics and chooses the date.

I have tried to use the ValueChangeListener but it doesen’t work cause the subwindow does not close if I choose the date.
my code is like this :

hlayout = new HorizontalLayout();
final TextField txt = new TextField(“date”);
final InlineDateField dt = new InlineDateField();
hlayout.addComponent(txt);
final Window ww = new Window();
ww.addComponent(dt);
ww.setWidth(300, Sizeable.UNITS_PIXELS);
dt.setResolution(DateField.RESOLUTION_DAY);
dt.addListener(new ValueChangeListener() {

		public void valueChange(ValueChangeEvent event) {
			// TODO Auto-generated method stub
			dt.commit();
			txt.setValue(dt.getValue());
			getMainWindow().removeWindow(ww);
		}
		
	});
ww.setStyleName("light");
Button btn = new Button("Choose");
btn.addListener(new ClickListener() {

		public void buttonClick(ClickEvent event) {
			// TODO Auto-generated method stub
			getMainWindow().addWindow(ww);
		}
});

hlayout.addComponent(btn);

The problem is that the window does not close if I choose the date and the value of the date is set if I close the subWindow. I think that the changeValue Listener is not fired when choosing the date but When exiting from the datefield.

Any idea???
thanks :slight_smile:

Hi!

I didn’t see a call to setImmediate(true) for your inline datefield, or is it missing from the code listing? Anyways, in order for fields to immediately trigger value change events, they need to be set immediate.

HTH,
/Jonatan

Hi,

yes It was missing from my code list. I added setImmediate(true) and now it works perfectly :slight_smile:
thanks :slight_smile: