well, i find that people often forget how easy it is to subclass components and create new ones in wicket. if your own way of doing date picking is something you do more than twice on your site, a simple panel could collapse all the related components and initialization into one little class like DatePickerPanel so a usage of it looks more like the code below and the details of how it works don't bleed out into your usage code. it does take a little bit of fussing to do that, but the code is easier to work with and much more encapsulated.
private void addReservationDates() { // create the feedback panel FeedbackPanel feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true); add(feedback); add(new DatePickerPanel("checkIn", new PropertyModel(roomRequest, "checkIn"))); add(new DatePickerPanel("checkOut", new PropertyModel(roomRequest, "checkOut"))); ... } Scott Swank wrote: > > Igor, > > The most verbose code is the following. It creates the FeedbackPanel and > two fields: a check-in date and a check-out date. The comments are a bit > heavy because this is a proof-of-concept app. At this point, and such > "best > practices" pointers are more than welcome. Thank you. > > ...Oh, and the CylleniusCalendar (our underlying app is named Cyllenius) > is > simply a sub-class of DatePicker with a HeaderContributor.forCss() to > increase its z-index a a value greater than that of the ModalWindow from > which it is opened. > > private void addReservationDates() > { > // create the feedback panel > FeedbackPanel feedback = new FeedbackPanel("feedback"); > feedback.setOutputMarkupId(true); > add(feedback); > > // create the check-in field > DateTextField checkIn = new DateTextField("checkIn", new > PropertyModel(roomRequest, "checkIn"), > "MM/dd/yyyy"); > checkIn.setOutputMarkupId(true); > checkIn.setRequired(true); > checkIn.add(DateValidator.minimum(getToday())); > add(buildAjaxFeedbackBorder("checkInBorder", checkIn, feedback)); > > // create a date picker for the check-in field > add(new CylleniusCalendar("checkInPicker", checkIn)); > > // create the check-out field > DateTextField checkOut = new DateTextField("checkOut", new > PropertyModel(roomRequest, > "checkOut"), "MM/dd/yyyy"); > checkOut.setOutputMarkupId(true); > checkOut.setRequired(true); > add(buildAjaxFeedbackBorder("checkOutBorder", checkOut, > feedback)); > > // create a date picker for the check-out field > add(new CylleniusCalendar("checkOutPicker", checkOut)); > > // require checkIn to be before checkOut > add(new DatesComparatorValidator(checkIn, checkOut)); > } > > private FormComponentFeedbackBorder buildAjaxFeedbackBorder(String > borderId, > FormComponent component, final FeedbackPanel feedback) > { > final FormComponentFeedbackBorder border = new > FormComponentFeedbackBorder(borderId); > border.add(component); > border.setOutputMarkupId(true); > > component.add(new AjaxFormComponentUpdatingBehavior("onblur") { > private static final long serialVersionUID = > -8868206053122717303L; > > protected void onUpdate(AjaxRequestTarget target) > { > target.addComponent(feedback); > target.addComponent(border); > } > }); > > return border; > } > > On 2/7/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote: >> >> On 2/7/07, Scott Swank <[EMAIL PROTECTED]> wrote: >> > >> > 2. Overall there was a preference for Wicket's Java components over >> > JSF's taglibs and backing bean code. This was not a unanimous >> preference, >> > and taglibs are much more concise than Wicket code. However, the >> cleanness >> > of the resulting HTML was a factor in Wicket's favor and the rapidity >> of the >> > development effort largely offset the comparative verbosity of the code >> > base. This verbosity was most evident in ajax form feedback: feedback >> > panel, text field, ajax feedback border, ajax behavior, etc. >> >> >> got any examples of this verbouse code? i am doing something similar in a >> project i am building with 2.0 and i was able to factor out a lot of this >> stuff so its not so bad. maybe we can help you do the same. >> >> -igor >> >> >> >> ------------------------------------------------------------------------- >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job >> easier. >> Download IBM WebSphere Application Server v.1.0.1 based on Apache >> Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Wicket-user mailing list >> Wicket-user@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/wicket-user >> >> > > > -- > Scott Swank > reformed mathematician > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier. > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > > -- View this message in context: http://www.nabble.com/-Wicket-user--ajax-libraries---wicket-tf3191437.html#a8877521 Sent from the Wicket - User mailing list archive at Nabble.com. ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user