wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpmihai <dpmi...@yahoo.com>
Subject Re: DateField and AjaxFormComponentUpdatingBehavior in wicket 1.5.5
Date Fri, 13 Apr 2012 07:09:53 GMT
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 &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>
<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


Mime
View raw message