Re: HTML5 Output tag API

2015-06-02 Thread Martin Grigorov
Hi,

Please create a proper Pull Request so it is easier to see the changed code
and to comment on it.


On Tue, Jun 2, 2015 at 7:03 AM, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 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, IModelString 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 ListString 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.


You should not use jQuery and/or $ in Java code. Only Wicket.xyz APIs.
Otherwise IJavaScriptLibrarySettings#setWicketAjaxReference() would have no
purpose.



 
  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
 



Re: HTML5 Output tag API

2015-06-02 Thread Tobias Soloschenko
Done.

kind regards

Tobias

 Am 02.06.2015 um 08:49 schrieb Martin Grigorov mgrigo...@apache.org:
 
 Hi,
 
 Please create a proper Pull Request so it is easier to see the changed code
 and to comment on it.
 
 
 On Tue, Jun 2, 2015 at 7:03 AM, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 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, IModelString 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 ListString 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.
 
 
 You should not use jQuery and/or $ in Java code. Only Wicket.xyz APIs.
 Otherwise IJavaScriptLibrarySettings#setWicketAjaxReference() would have no
 purpose.
 
 
 
 
 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
 
 


[GitHub] wicket pull request: HTML5 output tag

2015-06-02 Thread klopfdreh
GitHub user klopfdreh opened a pull request:

https://github.com/apache/wicket/pull/123

HTML5 output tag

Code formatting in a future commit.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/klopfdreh/wicket html5_output_tag

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/wicket/pull/123.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #123


commit 1d5a4110af1cf8cd6a63d69d4794b8bc88e8ef6d
Author: Tobias Soloschenko tsolosche...@apache.org
Date:   2015-05-30T23:31:00Z

HTML5 output tag




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


Re: HTML5 Output tag API

2015-06-02 Thread Tobias Soloschenko
Done: 
https://github.com/klopfdreh/wicket/commit/c903161c422b24fb1e74a93b14ac8a22bcbc6ee9

(Have to fix the formatting)

I like it much more, now - thank you a lot Sven! 

kind regards

Tobias

 Am 01.06.2015 um 23:55 schrieb Sven Meier s...@meiers.net:
 
 Hi Tobias,
 
 public  OutputField(String id, IModelString model)
 
 something else than String could be possibly too, couldn't it?
 
 public String getFormId()
 
 I'd prefer #getForm() instead, similar to AjaxButton.
 
  public ListString getForIds()
 
 I'd prefer components instead of ids here too (similar to IFormValidator):
 
public FormComponent?[] getDependentFormComponents()
 
 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.
 
  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?
 
public void renderHead(IHeaderResponse response)
{
super.renderHead(response);
 
 response.render(OnDomReadyHeaderItem.forScript(String.format($('#%s').on('input',
  function() { %s });, getForm().getMarkupId(), getInputScript()));
}
 
 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