Thanks for the great hints! I am going to apply your changes, soon!

kind regards

Tobias

> Am 01.06.2015 um 23:55 schrieb Sven Meier <s...@meiers.net>:
> 
> Hi Tobias,
> 
>> public  OutputField(String id, IModel<String> model)
> 
> something else than String could be possibly too, couldn't it?

There was a reason why to use String but I will try to change it to T again.

> 
> >public String getFormId()
> 
> I'd prefer #getForm() instead, similar to AjaxButton.
> 

Yep I will change this to not use Strings only.

> > public List<String> getForIds()
> 
> I'd prefer components instead of ids here too (similar to IFormValidator):
> 
>    public FormComponent<?>[] getDependentFormComponents()
> 

I like the syntax to be similar to other components - I will change this.

> >private class OutputDefaultAjaxBehavior extends AbstractDefaultAjaxBehavior
> 
> I don't see a need for this default behavior - devs will probably have to 
> recalculate the value on the server anyway.

The Idea behind this behavior is that you get the value just in time when it 
changes on client side and because it is calculated there the final value has 
to be send to the server.

> 
> > form1.add(new AttributeAppender("onInput", String.format(...)));
> 
> Couldn't that be handled by OutputField automatically? Preferably with event 
> registration instead of an inline event handler?
> 

No because the value calculation can be rather complex and there is no option 
to handle it in a generic way, but I will change it to event registration.

>    public void renderHead(IHeaderResponse response)
>    {
>        super.renderHead(response);
> 
> response.render(OnDomReadyHeaderItem.forScript(String.format("$('#%s').on('input',
>  function() { %s });", getForm().getMarkupId(), getInputScript()));
>    }

Good point - jquery is already loaded because of the ajax behavior.

> 
> My 2 cents
> Sven
> 
> 
>> On 01.06.2015 22:35, Tobias Soloschenko wrote:
>> 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