- Wicket's Date & Time Components and Client-Server Timezones
- Some useful Java System Properties while starting JVM.
- Jbossws 2.0.1 with JDK 1.6
- Date & Time selection made simple in Wicket
- New Features in Vim 7
- Maven best practices: Use dependency management for multi module projects.
- Prototyping LAMP with WAMP
- Bash shell tricks
Reply to comment |
If you have been using a component based framework like JSF or wicket for your web development, One thing you realize very quickly, is that there are 2 things to know about component based development.
Here I am going to show you how you can use 2 different components from the Wicket Extensions project to create a Date/Time picker. We will let these components validate themselves, and manage the conversion to and from strings, on their own. All we need to do is specify the exact display format of our Date/Time.
First we will use the Having a text filed, that validates and converts date entries, is fine, but it is really cumbersome for a user, to have to type in the Date/Time values that conform to a specific format.
This is where the Following is code fragment for using the two together. import java.text.SimpleDateFormat; import wicket.extensions.markup.html.datepicker.DatePicker; import wicket.extensions.markup.html.form.DateTextField; import wicket.util.convert.converters.DateConverter; DateConverter conv = new DateConverter(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm a"); conv.setDateFormat(Locale.getDefault(), sdf); TextField startDate = new DateTextField("startDate",sdf.toPattern()); startDate.setRequired(true); DatePicker sDatePicker = new DatePicker("sDatePicker", startDate); sDatePicker.setDateConverter(conv); By default both the
The DatePicker component is very smart ,and can be used to select either just Date, or both
Date and Time, depending on its To finish off, here's the corresponding HTML for the 2 components. Start Date : <input type="text" wicket:id="startDate" size="20" /> <span wicket:id="sDatePicker" /> |
|||