Last active
May 20, 2016 21:04
-
-
Save raugustinus/8d5579367cbeb895c81f to your computer and use it in GitHub Desktop.
wicket TimeField supporting the <input type="time" .../> attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.wicket.markup.html.form.TextField; | |
import org.apache.wicket.model.IModel; | |
import org.joda.time.LocalTime; | |
import org.slf4j.Logger; | |
import static org.slf4j.LoggerFactory.getLogger; | |
public class TimeField extends TextField<LocalTime> { | |
private static final Logger LOG = getLogger(TimeField.class); | |
public TimeField(String id, IModel<LocalTime> model) { | |
super(id, model); | |
} | |
@Override | |
protected String getInputType() { | |
return "time"; | |
} | |
@Override | |
protected void convertInput() { | |
super.convertInput(); | |
String input = getInput(); | |
LOG.debug("convering input: {}", input); | |
LocalTime result = LocalTime.parse(input); | |
LOG.debug("result: {}", result); | |
setConvertedInput(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment