You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by dpmihai <dp...@yahoo.com> on 2012/04/12 13:35:44 UTC
DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
I created a simple page with a DateField and an
AjaxFormComponentUpdatingBehavior where I want to read the model. The
following code does work in Wicket 1.4.16 (prints the selected date), but
does not in Wicket 1.5.5 (prints null):
public class DatePage extends WebPage {
private Date date;
public DatePage() {
super();
final DateField txtDate = new DateField("txtDate", new PropertyModel(this,
"date")) {
@Override
protected DateTextField newDateTextField(java.lang.String id,
PropertyModel dateFieldModel) {
DateTextField f = super.newDateTextField(id, dateFieldModel);
f.add(createAjaxBehavior());
return f;
}
};
add(txtDate);
}
private AjaxFormComponentUpdatingBehavior createAjaxBehavior() {
return new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("*** date=" + date);
}
};
}
}
Does anyone know something about this?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4551607.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by dpmihai <dp...@yahoo.com>.
Here is the link
https://issues.apache.org/jira/browse/WICKET-4496
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4554218.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by Martin Grigorov <mg...@apache.org>.
Create a quickstart app and attach it to Jira.
Thanks!
On Fri, Apr 13, 2012 at 11:35 AM, dpmihai <dp...@yahoo.com> wrote:
> For a DateField and a DateTimeField in the onUpdate method for an
> AjaxFormComponentUpdatingBehavior , the model is never updated, it rests
> with the initial date selection.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4554163.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by dpmihai <dp...@yahoo.com>.
As the bug link states you have to create date object by yourself. It's ugly
as a witch I know. But for wicket 1.5 I had no other solution. I do not know
how DateField and DateTimeField perform in wicket 1.6.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4655289.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by dmalescot <d....@gmail.com>.
Any suggestion ? I have the same problem.
When i update my datefield with this behavior, my date is null.
Thanks,
Damien
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4655258.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by dpmihai <dp...@yahoo.com>.
I saw that the resolution for this
bug(https://issues.apache.org/jira/browse/WICKET-4496) is "Not a problem"
using getDefaultModelObject().
But it remains a question. If I have a DatetimeField and I want an
AjaxFormComponentUpdatingBehavior so that if I click the button, or if I
change the hours or minutes field, to see the model of my current date, I
was done like this in wicket 1.4 (and in wicket 1.5 date is null):
private Date date;
final DateTimeField txtDate = new DateTimeField("txtDate", new
PropertyModel(this, "date")) {
@Override
protected DateTextField newDateTextField(java.lang.String id,
PropertyModel dateFieldModel) {
final DateTextField f = super.newDateTextField(id, dateFieldModel);
f.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("*** date=" + f.getDefaultModelObject());
}
});
return f;
}
};
final Component HOUR = txtDate.get("hours");
HOUR.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("*** hours=" + HOUR.getDefaultModelObject()); // ok
as sugested
System.out.println("*** date=" + date); //
null in wicket 1.5
}
});
final Component MINUTES = txtDate.get("minutes");
MINUTES.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("*** minutes=" + MINUTES.getDefaultModelObject()); //
ok as sugested
System.out.println("*** date=" + date); //
null in wicket 1.5
}
});
add(txtDate);
Using getDefaultModelObject() I can get hours and minutes field. But how to
get the entire date? Do you have any sugestions?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4566846.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by Martin Grigorov <mg...@apache.org>.
Create a quickstart app and attach it to Jira.
Thanks!
On Fri, Apr 13, 2012 at 11:35 AM, dpmihai <dp...@yahoo.com> wrote:
> For a DateField and a DateTimeField in the onUpdate method for an
> AjaxFormComponentUpdatingBehavior , the model is never updated, it rests
> with the initial date selection.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4554163.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by dpmihai <dp...@yahoo.com>.
For a DateField and a DateTimeField in the onUpdate method for an
AjaxFormComponentUpdatingBehavior , the model is never updated, it rests
with the initial date selection.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4554163.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Apr 13, 2012 at 11:26 AM, dpmihai <dp...@yahoo.com> wrote:
> This workaround works. But it seems DateField and DateTimeField are buggy in
> Wicket 1.5.5.
Can you explain the bug ?
>
> So the only solution for now is to create my new components DateField and
> DateTimeField.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4554145.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by dpmihai <dp...@yahoo.com>.
This workaround works. But it seems DateField and DateTimeField are buggy in
Wicket 1.5.5.
So the only solution for now is to create my new components DateField and
DateTimeField.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4554145.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by Francois Meillet <fr...@gmail.com>.
try this
public TestForm(String form, final IModel<Date> dateModel) {
super(form, dateModel);
DateTextField dateTextField = new DateTextField("txtDate", dateModel, new StrictPatternDateConverter("dd/MM/yyyy", false));
DatePicker datePicker = new DatePicker();
datePicker.setShowOnFieldClick(true);
dateTextField.add(datePicker);
AjaxFormComponentUpdatingBehavior ajaxFormComponentUpdatingBehavior = new AjaxFormComponentUpdatingBehavior("onChange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("dateModel :[" + dateModel + "]");
}
};
dateTextField.add(ajaxFormComponentUpdatingBehavior);
add(dateTextField);
}
Le 13 avr. 2012 à 09:09, dpmihai a écrit :
> import java.util.Date;
> import org.apache.wicket.ajax.AjaxRequestTarget;
> import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
> import org.apache.wicket.datetime.markup.html.form.DateTextField;
> import org.apache.wicket.extensions.yui.calendar.DateField;
> import org.apache.wicket.markup.html.WebPage;
> import org.apache.wicket.markup.html.form.Form;
> import org.apache.wicket.model.IModel;
> import org.apache.wicket.model.Model;
> import org.apache.wicket.model.PropertyModel;
>
> public class DatePage extends WebPage {
>
> private IModel<Date> date;
>
> public DatePage() {
> super();
> add(new TestForm("form", date = new Model<Date>(new Date())));
> }
>
> private class TestForm extends Form {
>
> public TestForm(String form, final IModel<Date> dateModel) {
> super(form, dateModel);
>
> DateField txtDate = new DateField("txtDate", dateModel) {
>
> @Override
> protected DateTextField
> newDateTextField(java.lang.String id, PropertyModel dateFieldModel) {
> DateTextField dateTextField =
> super.newDateTextField(id, dateFieldModel);
>
> AjaxFormComponentUpdatingBehavior
> ajaxFormComponentUpdatingBehavior = new
> AjaxFormComponentUpdatingBehavior("onChange") {
> @Override
> protected void
> onUpdate(AjaxRequestTarget target) {
>
> System.out.println("dateModel :[" + dateModel + "]");
> }
> };
>
>
> dateTextField.add(ajaxFormComponentUpdatingBehavior);
> return dateTextField;
> }
> };
>
> add( txtDate );
> }
> }
> }
>
> with DatePage.html:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
>
> xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.5-strict.dtd/"
> xml:lang="en"
> lang="en">
>
> <head>
> <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
> </head>
>
> <body>
> <form wicket:id="form">
> <div wicket:id="txtDate" class="left"/>
> </form>
> </body>
> </html>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4554031.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by dpmihai <dp...@yahoo.com>.
import java.util.Date;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.datetime.markup.html.form.DateTextField;
import org.apache.wicket.extensions.yui.calendar.DateField;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
public class DatePage extends WebPage {
private IModel<Date> date;
public DatePage() {
super();
add(new TestForm("form", date = new Model<Date>(new Date())));
}
private class TestForm extends Form {
public TestForm(String form, final IModel<Date> dateModel) {
super(form, dateModel);
DateField txtDate = new DateField("txtDate", dateModel) {
@Override
protected DateTextField
newDateTextField(java.lang.String id, PropertyModel dateFieldModel) {
DateTextField dateTextField =
super.newDateTextField(id, dateFieldModel);
AjaxFormComponentUpdatingBehavior
ajaxFormComponentUpdatingBehavior = new
AjaxFormComponentUpdatingBehavior("onChange") {
@Override
protected void
onUpdate(AjaxRequestTarget target) {
System.out.println("dateModel :[" + dateModel + "]");
}
};
dateTextField.add(ajaxFormComponentUpdatingBehavior);
return dateTextField;
}
};
add( txtDate );
}
}
}
with DatePage.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.5-strict.dtd/"
xml:lang="en"
lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>
<body>
<form wicket:id="form">
<div wicket:id="txtDate" class="left"/>
</form>
</body>
</html>
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4554031.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by dpmihai <dp...@yahoo.com>.
The class I put here was the full code:
import java.util.Date;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.datetime.markup.html.form.DateTextField;
import org.apache.wicket.extensions.yui.calendar.DateField;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.PropertyModel;
public class DatePage extends WebPage {
private Date date;
public DatePage() {
super();
final DateField txtDate = new DateField("txtDate", new PropertyModel(this,
"date")) {
@Override
protected DateTextField newDateTextField(java.lang.String id,
PropertyModel dateFieldModel) {
DateTextField f = super.newDateTextField(id, dateFieldModel);
f.add(createAjaxBehavior());
return f;
}
};
add(txtDate);
}
private AjaxFormComponentUpdatingBehavior createAjaxBehavior() {
return new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("*** date=" + date);
}
};
}
}
and DatePage.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.5-strict.dtd/"
xml:lang="en"
lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>
<body>
<div wicket:id="txtDate" class="left"/>
</body>
</html>
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4554015.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by Francois Meillet <qq...@gmail.com>.
Show me your code. full file class.
Le 12 avr. 2012 à 16:41, dpmihai a écrit :
> It does not matter. Your code (DateTextField instead DateField) does not work
> either in Wicket 1.5.5 It prints just the current date no matter what date I
> choose.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4552082.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by dpmihai <dp...@yahoo.com>.
It does not matter. Your code (DateTextField instead DateField) does not work
either in Wicket 1.5.5 It prints just the current date no matter what date I
choose.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4552082.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Posted by Francois Meillet <fr...@gmail.com>.
Hi,
Should be better with a form
private IModel<Date> date;
public Test() {
super();
add(new TestForm("form", date = new Model<Date>(new Date())));
}
private class TestForm extends Form {
public TestForm(String form, final IModel<Date> dateModel) {
super(form, dateModel);
DateField txtDate = new DateField("txtDate", dateModel) {
@Override
protected DateTextField newDateTextField(java.lang.String id, PropertyModel dateFieldModel) {
DateTextField dateTextField = super.newDateTextField(id, dateFieldModel);
AjaxFormComponentUpdatingBehavior ajaxFormComponentUpdatingBehavior = new AjaxFormComponentUpdatingBehavior("onChange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("dateModel :[" + dateModel + "]");
}
};
dateTextField.add(ajaxFormComponentUpdatingBehavior);
return dateTextField;
}
};
add( txtDate );
}
}
François
Le 12 avr. 2012 à 13:35, dpmihai a écrit :
> I created a simple page with a DateField and an
> AjaxFormComponentUpdatingBehavior where I want to read the model. The
> following code does work in Wicket 1.4.16 (prints the selected date), but
> does not in Wicket 1.5.5 (prints null):
>
> public class DatePage extends WebPage {
>
> private Date date;
>
> public DatePage() {
> super();
>
> final DateField txtDate = new DateField("txtDate", new PropertyModel(this,
> "date")) {
> @Override
> protected DateTextField newDateTextField(java.lang.String id,
> PropertyModel dateFieldModel) {
> DateTextField f = super.newDateTextField(id, dateFieldModel);
> f.add(createAjaxBehavior());
> return f;
> }
> };
> add(txtDate);
> }
>
> private AjaxFormComponentUpdatingBehavior createAjaxBehavior() {
> return new AjaxFormComponentUpdatingBehavior("onchange") {
> @Override
> protected void onUpdate(AjaxRequestTarget target) {
> System.out.println("*** date=" + date);
> }
>
> };
> }
>
> }
>
> Does anyone know something about this?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DateField-and-AjaxFormComponentUpdatingBehavior-in-wicket-1-5-5-tp4551607p4551607.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org