Hi everyone,

I would like to introduce a new API to make responsive forms available with the HTML5 tag "output".

Information and examples can be found here:

https://github.com/klopfdreh/wicket-components-playground/wiki/14.-HTML5-OutputField-API

Benefits of the OutputField

* Easy client side calculations based on input fields and an AttributeAppender - so the calculation can be changed on server side:

// number1 and number2 are input fields
form.add(new AttributeAppender("onInput", String.format("%s.value=parseFloat(%s.value)+ parseFloat(%s.value)", outputField.getMarkupId(), number1.getMarkupId(), number2.getMarkupId())));

* Automated push of the value to the server side. There the value can be retrieved by get the model of the output field:

form.add(new AjaxButton("submit") {

    private static final long serialVersionUID = 1L;

    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
target.add(label.setDefaultModelObject("The current output value: " + outputField.getDefaultModelObject()));
    }
}.setDefaultFormProcessing(false));

I would be very pleased for any feedback! :-)

kind regards

Tobias

Reply via email to