Re: OnChangeAjaxBehavior: nth character

2010-02-13 Thread Steven Haines
Thanks so much, I appreciate all of your collective help. This list is a 
testimony to the passion I spoke of about the Wicket community - you guys rock!

Steve



- Original Message 
From: Cemal Bayramoglu 
To: users@wicket.apache.org
Sent: Sat, February 13, 2010 8:26:37 AM
Subject: Re: OnChangeAjaxBehavior: nth character

Steven,

Start with something like this:

zipcodeField.add(new OnChangeAjaxBehavior() {
@Override protected void onUpdate(AjaxRequestTarget target) {
// do your stuff here
}
@Override protected IAjaxCallDecorator getAjaxCallDecorator() {
return new AjaxCallDecorator() {
@Override public CharSequence decorateScript(CharSequence script) {
return "if(this.value.length % 5 == 0){" + script + "}";
}
};
}
});

Regards - Cemal
jWeekend
OO & Java Technologies, Wicket
Consulting, Development, Training
http://jWeekend.com


On 12 February 2010 20:45, Steven Haines  wrote:
> Hi,
>
> I
> would like to add AJAX behavior to an application that sends an update
> to my application after a certain number of characters have been typed.
> For example, if the user is entering a zipcode, I would like a callback
> to my application to be made after the user enters the fifth character.
>
> I've
> written code using OnChangeAjaxBehavior that sends messages back to my
> application after every character has been typed, such as the following:
>
>final TextField zipcodeField = new TextField( "zipcode" );
>form.add( zipcodeField.setRequired( true ) );
>OnChangeAjaxBehavior zipcodeUpdated = new OnChangeAjaxBehavior() {
>  @Override
>  protected void onUpdate( AjaxRequestTarget target ) {
>System.out.println( "Zipcode value: " + 
> zipcodeField.getDefaultModelObjectAsString() );
>  }
>};
>zipcodeField.add( zipcodeUpdated );
>
>
> I
> could check to see the size of the zipcodeField (in this example), but
> it makes my application more chatty than it needs to be. I also tried
> using onblur, which works fine, but does not satisfy my business
> requirements:
>
>  final TextField zipcodeField = new TextField( "zipcode" );
>  form.add( zipcodeField.setRequired( true ) );
>
>  AjaxFormComponentUpdatingBehavior zipcodeOnBlur = new 
> AjaxFormComponentUpdatingBehavior( "onblur" ) {
>  @Override
>  protected void onUpdate( AjaxRequestTarget target ) {
>  System.out.println( "Zipcode value (form component): " + 
> getFormComponent().getModelObject() );
>  }
>  };
>  zipcodeField.add( zipcodeOnBlur );
>
>
>
> Prior
> to using Wicket (which I'm currently prototyping for my company), we
> would handle this logic in JavaScript (observe changes to the field and
> when the user enters the fifth character then we made an AJAX call back
> our Struts 2 application.)
>
> What is the best way to achieve the same end using Wicket?
>
> Thanks, in advance, for your help!
> Steve
>
> P.S.
> I started using Wicket as part of an article series (because of all of
> your passion for it) and I have to say all of you are doing incredible
> work - I love it.. Here's the link to the article series in case any of
> you are interested:
> http://www.informit.com/guides/content.aspx?g=java&seqNum=529
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: OnChangeAjaxBehavior: nth character

2010-02-13 Thread Riyad Kalla
Cemal, very intuitive -- thanks for that.

On Sat, Feb 13, 2010 at 6:26 AM, Cemal Bayramoglu <
jweekend_for...@cabouge.com> wrote:

> Steven,
>
> Start with something like this:
>
> zipcodeField.add(new OnChangeAjaxBehavior() {
> @Override protected void onUpdate(AjaxRequestTarget target) {
> // do your stuff here
>}
>@Override protected IAjaxCallDecorator getAjaxCallDecorator() {
>return new AjaxCallDecorator() {
>@Override public CharSequence decorateScript(CharSequence
> script) {
>return "if(this.value.length % 5 == 0){" + script + "}";
>}
>};
>}
> });
>
> Regards - Cemal
> jWeekend
> OO & Java Technologies, Wicket
> Consulting, Development, Training
> http://jWeekend.com
>
>
> On 12 February 2010 20:45, Steven Haines  wrote:
> > Hi,
> >
> > I
> > would like to add AJAX behavior to an application that sends an update
> > to my application after a certain number of characters have been typed.
> > For example, if the user is entering a zipcode, I would like a callback
> > to my application to be made after the user enters the fifth character.
> >
> > I've
> > written code using OnChangeAjaxBehavior that sends messages back to my
> > application after every character has been typed, such as the following:
> >
> >final TextField zipcodeField = new TextField(
> "zipcode" );
> >form.add( zipcodeField.setRequired( true ) );
> >OnChangeAjaxBehavior zipcodeUpdated = new OnChangeAjaxBehavior() {
> >  @Override
> >  protected void onUpdate( AjaxRequestTarget target ) {
> >System.out.println( "Zipcode value: " +
> zipcodeField.getDefaultModelObjectAsString() );
> >  }
> >};
> >zipcodeField.add( zipcodeUpdated );
> >
> >
> > I
> > could check to see the size of the zipcodeField (in this example), but
> > it makes my application more chatty than it needs to be. I also tried
> > using onblur, which works fine, but does not satisfy my business
> > requirements:
> >
> >  final TextField zipcodeField = new TextField( "zipcode"
> );
> >  form.add( zipcodeField.setRequired( true ) );
> >
> >  AjaxFormComponentUpdatingBehavior zipcodeOnBlur = new
> AjaxFormComponentUpdatingBehavior( "onblur" ) {
> >  @Override
> >  protected void onUpdate( AjaxRequestTarget target ) {
> >  System.out.println( "Zipcode value (form component): " +
> getFormComponent().getModelObject() );
> >  }
> >  };
> >  zipcodeField.add( zipcodeOnBlur );
> >
> >
> >
> > Prior
> > to using Wicket (which I'm currently prototyping for my company), we
> > would handle this logic in JavaScript (observe changes to the field and
> > when the user enters the fifth character then we made an AJAX call back
> > our Struts 2 application.)
> >
> > What is the best way to achieve the same end using Wicket?
> >
> > Thanks, in advance, for your help!
> > Steve
> >
> > P.S.
> > I started using Wicket as part of an article series (because of all of
> > your passion for it) and I have to say all of you are doing incredible
> > work - I love it.. Here's the link to the article series in case any of
> > you are interested:
> > http://www.informit.com/guides/content.aspx?g=java&seqNum=529
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: OnChangeAjaxBehavior: nth character

2010-02-13 Thread Cemal Bayramoglu
Steven,

Start with something like this:

zipcodeField.add(new OnChangeAjaxBehavior() {
@Override protected void onUpdate(AjaxRequestTarget target) {
// do your stuff here
}
@Override protected IAjaxCallDecorator getAjaxCallDecorator() {
return new AjaxCallDecorator() {
@Override public CharSequence decorateScript(CharSequence script) {
return "if(this.value.length % 5 == 0){" + script + "}";
}
};
}
});

Regards - Cemal
jWeekend
OO & Java Technologies, Wicket
Consulting, Development, Training
http://jWeekend.com


On 12 February 2010 20:45, Steven Haines  wrote:
> Hi,
>
> I
> would like to add AJAX behavior to an application that sends an update
> to my application after a certain number of characters have been typed.
> For example, if the user is entering a zipcode, I would like a callback
> to my application to be made after the user enters the fifth character.
>
> I've
> written code using OnChangeAjaxBehavior that sends messages back to my
> application after every character has been typed, such as the following:
>
>    final TextField zipcodeField = new TextField( "zipcode" );
>    form.add( zipcodeField.setRequired( true ) );
>    OnChangeAjaxBehavior zipcodeUpdated = new OnChangeAjaxBehavior() {
>     �...@override
>      protected void onUpdate( AjaxRequestTarget target ) {
>        System.out.println( "Zipcode value: " + 
> zipcodeField.getDefaultModelObjectAsString() );
>      }
>    };
>    zipcodeField.add( zipcodeUpdated );
>
>
> I
> could check to see the size of the zipcodeField (in this example), but
> it makes my application more chatty than it needs to be. I also tried
> using onblur, which works fine, but does not satisfy my business
> requirements:
>
>  final TextField zipcodeField = new TextField( "zipcode" );
>  form.add( zipcodeField.setRequired( true ) );
>
>  AjaxFormComponentUpdatingBehavior zipcodeOnBlur = new 
> AjaxFormComponentUpdatingBehavior( "onblur" ) {
>     �...@override
>      protected void onUpdate( AjaxRequestTarget target ) {
>          System.out.println( "Zipcode value (form component): " + 
> getFormComponent().getModelObject() );
>      }
>  };
>  zipcodeField.add( zipcodeOnBlur );
>
>
>
> Prior
> to using Wicket (which I'm currently prototyping for my company), we
> would handle this logic in JavaScript (observe changes to the field and
> when the user enters the fifth character then we made an AJAX call back
> our Struts 2 application.)
>
> What is the best way to achieve the same end using Wicket?
>
> Thanks, in advance, for your help!
> Steve
>
> P.S.
> I started using Wicket as part of an article series (because of all of
> your passion for it) and I have to say all of you are doing incredible
> work - I love it.. Here's the link to the article series in case any of
> you are interested:
> http://www.informit.com/guides/content.aspx?g=java&seqNum=529
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: OnChangeAjaxBehavior: nth character

2010-02-12 Thread Igor Vaynberg
you can use an iajaxcalldecorator to add javascript before the call is
made and interrupt it by simply "return true" until fifth character
has been pressed.

-igor

On Fri, Feb 12, 2010 at 12:45 PM, Steven Haines  wrote:
> Hi,
>
> I
> would like to add AJAX behavior to an application that sends an update
> to my application after a certain number of characters have been typed.
> For example, if the user is entering a zipcode, I would like a callback
> to my application to be made after the user enters the fifth character.
>
> I've
> written code using OnChangeAjaxBehavior that sends messages back to my
> application after every character has been typed, such as the following:
>
>    final TextField zipcodeField = new TextField( "zipcode" );
>    form.add( zipcodeField.setRequired( true ) );
>    OnChangeAjaxBehavior zipcodeUpdated = new OnChangeAjaxBehavior() {
>     �...@override
>      protected void onUpdate( AjaxRequestTarget target ) {
>        System.out.println( "Zipcode value: " + 
> zipcodeField.getDefaultModelObjectAsString() );
>      }
>    };
>    zipcodeField.add( zipcodeUpdated );
>
>
> I
> could check to see the size of the zipcodeField (in this example), but
> it makes my application more chatty than it needs to be. I also tried
> using onblur, which works fine, but does not satisfy my business
> requirements:
>
>  final TextField zipcodeField = new TextField( "zipcode" );
>  form.add( zipcodeField.setRequired( true ) );
>
>  AjaxFormComponentUpdatingBehavior zipcodeOnBlur = new 
> AjaxFormComponentUpdatingBehavior( "onblur" ) {
>     �...@override
>      protected void onUpdate( AjaxRequestTarget target ) {
>          System.out.println( "Zipcode value (form component): " + 
> getFormComponent().getModelObject() );
>      }
>  };
>  zipcodeField.add( zipcodeOnBlur );
>
>
>
> Prior
> to using Wicket (which I'm currently prototyping for my company), we
> would handle this logic in JavaScript (observe changes to the field and
> when the user enters the fifth character then we made an AJAX call back
> our Struts 2 application.)
>
> What is the best way to achieve the same end using Wicket?
>
> Thanks, in advance, for your help!
> Steve
>
> P.S.
> I started using Wicket as part of an article series (because of all of
> your passion for it) and I have to say all of you are doing incredible
> work - I love it.. Here's the link to the article series in case any of
> you are interested:
> http://www.informit.com/guides/content.aspx?g=java&seqNum=529
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: OnChangeAjaxBehavior: nth character

2010-02-12 Thread Riyad Kalla
Ah! Thanks Vineet.

On Fri, Feb 12, 2010 at 3:42 PM, vineet semwal
wrote:

> Riyad,
> 1)url is callbackurl you will get from
> abstractdefaultajaxbehavior.getcallbackurl()
> 2)method you need to implement is the abstractdefaultajaxbehavior's respond
> method
>
> On Sat, Feb 13, 2010 at 3:58 AM, Riyad Kalla  wrote:
>
> > Vineet is exactly right, just to further flesh it out:
> >
> > You want to add a subclass of AbstractDefaultAjaxBehavior to your page,
> > this
> > automatically contributes the wicket-ajax.js file to your page which
> > exposes
> > these JavaScript methods for you:
> >
> > ===
> > function wicketAjaxGet(url, successHandler, failureHandler, precondition,
> > channel)
> > and
> > function wicketAjaxPost(url, body, successHandler, failureHandler,
> > precondition, channel)
> > ===
> >
> > (paraphrased from Wiki)
> >
> > The part I'm not clear on is which URL do you call with the JavaScript
> and
> > which method on the server side is intercepting the GET (or POST)?
> >
> > That information seems to be missing from the wiki unless it's easier
> than
> > I
> > realize and I'm overthinking this...
> >
> > On Fri, Feb 12, 2010 at 2:15 PM, vineet semwal
> > wrote:
> >
> > > you can do the same thing with wicket ie. on 5th char typed,make a
> > > ajaxcallback to wicket,
> > >
> > > 1)you need to add behavior to component and implement it's respond
> method
> > > the way it suits your need.
> > > 2)in the js part you  will make a callback on 5th char
> typed,callbackurl
> > > you
> > > will get from the behavior you
> > > added to the component.
> > > take a look at
> > >
> > >
> >
> http://cwiki.apache.org/confluence/display/WICKET/Calling+Wicket+from+Javascript
> > >
> > > On Sat, Feb 13, 2010 at 2:15 AM, Steven Haines 
> wrote:
> > >
> > > > Hi,
> > > >
> > > > I
> > > > would like to add AJAX behavior to an application that sends an
> update
> > > > to my application after a certain number of characters have been
> typed.
> > > > For example, if the user is entering a zipcode, I would like a
> callback
> > > > to my application to be made after the user enters the fifth
> character.
> > > >
> > > > I've
> > > > written code using OnChangeAjaxBehavior that sends messages back to
> my
> > > > application after every character has been typed, such as the
> > following:
> > > >
> > > >final TextField zipcodeField = new TextField(
> > > "zipcode"
> > > > );
> > > >form.add( zipcodeField.setRequired( true ) );
> > > >OnChangeAjaxBehavior zipcodeUpdated = new OnChangeAjaxBehavior() {
> > > >  @Override
> > > >  protected void onUpdate( AjaxRequestTarget target ) {
> > > >System.out.println( "Zipcode value: " +
> > > > zipcodeField.getDefaultModelObjectAsString() );
> > > >  }
> > > >};
> > > >zipcodeField.add( zipcodeUpdated );
> > > >
> > > >
> > > > I
> > > > could check to see the size of the zipcodeField (in this example),
> but
> > > > it makes my application more chatty than it needs to be. I also tried
> > > > using onblur, which works fine, but does not satisfy my business
> > > > requirements:
> > > >
> > > >  final TextField zipcodeField = new TextField(
> > "zipcode"
> > > );
> > > >  form.add( zipcodeField.setRequired( true ) );
> > > >
> > > >  AjaxFormComponentUpdatingBehavior zipcodeOnBlur = new
> > > > AjaxFormComponentUpdatingBehavior( "onblur" ) {
> > > >  @Override
> > > >  protected void onUpdate( AjaxRequestTarget target ) {
> > > >  System.out.println( "Zipcode value (form component): " +
> > > > getFormComponent().getModelObject() );
> > > >  }
> > > >  };
> > > >  zipcodeField.add( zipcodeOnBlur );
> > > >
> > > >
> > > >
> > > > Prior
> > > > to using Wicket (which I'm currently prototyping for my company), we
> > > > would handle this logic in JavaScript (observe changes to the field
> and
> > > > when the user enters the fifth character then we made an AJAX call
> back
> > > > our Struts 2 application.)
> > > >
> > > > What is the best way to achieve the same end using Wicket?
> > > >
> > > > Thanks, in advance, for your help!
> > > > Steve
> > > >
> > > > P.S.
> > > > I started using Wicket as part of an article series (because of all
> of
> > > > your passion for it) and I have to say all of you are doing
> incredible
> > > > work - I love it.. Here's the link to the article series in case any
> of
> > > > you are interested:
> > > > http://www.informit.com/guides/content.aspx?g=java&seqNum=529
> > > >
> > > > -
> > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > > For additional commands, e-mail: users-h...@wicket.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > regards,
> > > Vineet Semwal
> > >
> >
>
>
>
> --
> regards,
> Vineet Semwal
>


Re: OnChangeAjaxBehavior: nth character

2010-02-12 Thread vineet semwal
Riyad,
1)url is callbackurl you will get from
abstractdefaultajaxbehavior.getcallbackurl()
2)method you need to implement is the abstractdefaultajaxbehavior's respond
method

On Sat, Feb 13, 2010 at 3:58 AM, Riyad Kalla  wrote:

> Vineet is exactly right, just to further flesh it out:
>
> You want to add a subclass of AbstractDefaultAjaxBehavior to your page,
> this
> automatically contributes the wicket-ajax.js file to your page which
> exposes
> these JavaScript methods for you:
>
> ===
> function wicketAjaxGet(url, successHandler, failureHandler, precondition,
> channel)
> and
> function wicketAjaxPost(url, body, successHandler, failureHandler,
> precondition, channel)
> ===
>
> (paraphrased from Wiki)
>
> The part I'm not clear on is which URL do you call with the JavaScript and
> which method on the server side is intercepting the GET (or POST)?
>
> That information seems to be missing from the wiki unless it's easier than
> I
> realize and I'm overthinking this...
>
> On Fri, Feb 12, 2010 at 2:15 PM, vineet semwal
> wrote:
>
> > you can do the same thing with wicket ie. on 5th char typed,make a
> > ajaxcallback to wicket,
> >
> > 1)you need to add behavior to component and implement it's respond method
> > the way it suits your need.
> > 2)in the js part you  will make a callback on 5th char typed,callbackurl
> > you
> > will get from the behavior you
> > added to the component.
> > take a look at
> >
> >
> http://cwiki.apache.org/confluence/display/WICKET/Calling+Wicket+from+Javascript
> >
> > On Sat, Feb 13, 2010 at 2:15 AM, Steven Haines  wrote:
> >
> > > Hi,
> > >
> > > I
> > > would like to add AJAX behavior to an application that sends an update
> > > to my application after a certain number of characters have been typed.
> > > For example, if the user is entering a zipcode, I would like a callback
> > > to my application to be made after the user enters the fifth character.
> > >
> > > I've
> > > written code using OnChangeAjaxBehavior that sends messages back to my
> > > application after every character has been typed, such as the
> following:
> > >
> > >final TextField zipcodeField = new TextField(
> > "zipcode"
> > > );
> > >form.add( zipcodeField.setRequired( true ) );
> > >OnChangeAjaxBehavior zipcodeUpdated = new OnChangeAjaxBehavior() {
> > >  @Override
> > >  protected void onUpdate( AjaxRequestTarget target ) {
> > >System.out.println( "Zipcode value: " +
> > > zipcodeField.getDefaultModelObjectAsString() );
> > >  }
> > >};
> > >zipcodeField.add( zipcodeUpdated );
> > >
> > >
> > > I
> > > could check to see the size of the zipcodeField (in this example), but
> > > it makes my application more chatty than it needs to be. I also tried
> > > using onblur, which works fine, but does not satisfy my business
> > > requirements:
> > >
> > >  final TextField zipcodeField = new TextField(
> "zipcode"
> > );
> > >  form.add( zipcodeField.setRequired( true ) );
> > >
> > >  AjaxFormComponentUpdatingBehavior zipcodeOnBlur = new
> > > AjaxFormComponentUpdatingBehavior( "onblur" ) {
> > >  @Override
> > >  protected void onUpdate( AjaxRequestTarget target ) {
> > >  System.out.println( "Zipcode value (form component): " +
> > > getFormComponent().getModelObject() );
> > >  }
> > >  };
> > >  zipcodeField.add( zipcodeOnBlur );
> > >
> > >
> > >
> > > Prior
> > > to using Wicket (which I'm currently prototyping for my company), we
> > > would handle this logic in JavaScript (observe changes to the field and
> > > when the user enters the fifth character then we made an AJAX call back
> > > our Struts 2 application.)
> > >
> > > What is the best way to achieve the same end using Wicket?
> > >
> > > Thanks, in advance, for your help!
> > > Steve
> > >
> > > P.S.
> > > I started using Wicket as part of an article series (because of all of
> > > your passion for it) and I have to say all of you are doing incredible
> > > work - I love it.. Here's the link to the article series in case any of
> > > you are interested:
> > > http://www.informit.com/guides/content.aspx?g=java&seqNum=529
> > >
> > > -
> > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > For additional commands, e-mail: users-h...@wicket.apache.org
> > >
> > >
> >
> >
> > --
> > regards,
> > Vineet Semwal
> >
>



-- 
regards,
Vineet Semwal


Re: OnChangeAjaxBehavior: nth character

2010-02-12 Thread Riyad Kalla
Vineet is exactly right, just to further flesh it out:

You want to add a subclass of AbstractDefaultAjaxBehavior to your page, this
automatically contributes the wicket-ajax.js file to your page which exposes
these JavaScript methods for you:

===
function wicketAjaxGet(url, successHandler, failureHandler, precondition,
channel)
and
function wicketAjaxPost(url, body, successHandler, failureHandler,
precondition, channel)
===

(paraphrased from Wiki)

The part I'm not clear on is which URL do you call with the JavaScript and
which method on the server side is intercepting the GET (or POST)?

That information seems to be missing from the wiki unless it's easier than I
realize and I'm overthinking this...

On Fri, Feb 12, 2010 at 2:15 PM, vineet semwal
wrote:

> you can do the same thing with wicket ie. on 5th char typed,make a
> ajaxcallback to wicket,
>
> 1)you need to add behavior to component and implement it's respond method
> the way it suits your need.
> 2)in the js part you  will make a callback on 5th char typed,callbackurl
> you
> will get from the behavior you
> added to the component.
> take a look at
>
> http://cwiki.apache.org/confluence/display/WICKET/Calling+Wicket+from+Javascript
>
> On Sat, Feb 13, 2010 at 2:15 AM, Steven Haines  wrote:
>
> > Hi,
> >
> > I
> > would like to add AJAX behavior to an application that sends an update
> > to my application after a certain number of characters have been typed.
> > For example, if the user is entering a zipcode, I would like a callback
> > to my application to be made after the user enters the fifth character.
> >
> > I've
> > written code using OnChangeAjaxBehavior that sends messages back to my
> > application after every character has been typed, such as the following:
> >
> >final TextField zipcodeField = new TextField(
> "zipcode"
> > );
> >form.add( zipcodeField.setRequired( true ) );
> >OnChangeAjaxBehavior zipcodeUpdated = new OnChangeAjaxBehavior() {
> >  @Override
> >  protected void onUpdate( AjaxRequestTarget target ) {
> >System.out.println( "Zipcode value: " +
> > zipcodeField.getDefaultModelObjectAsString() );
> >  }
> >};
> >zipcodeField.add( zipcodeUpdated );
> >
> >
> > I
> > could check to see the size of the zipcodeField (in this example), but
> > it makes my application more chatty than it needs to be. I also tried
> > using onblur, which works fine, but does not satisfy my business
> > requirements:
> >
> >  final TextField zipcodeField = new TextField( "zipcode"
> );
> >  form.add( zipcodeField.setRequired( true ) );
> >
> >  AjaxFormComponentUpdatingBehavior zipcodeOnBlur = new
> > AjaxFormComponentUpdatingBehavior( "onblur" ) {
> >  @Override
> >  protected void onUpdate( AjaxRequestTarget target ) {
> >  System.out.println( "Zipcode value (form component): " +
> > getFormComponent().getModelObject() );
> >  }
> >  };
> >  zipcodeField.add( zipcodeOnBlur );
> >
> >
> >
> > Prior
> > to using Wicket (which I'm currently prototyping for my company), we
> > would handle this logic in JavaScript (observe changes to the field and
> > when the user enters the fifth character then we made an AJAX call back
> > our Struts 2 application.)
> >
> > What is the best way to achieve the same end using Wicket?
> >
> > Thanks, in advance, for your help!
> > Steve
> >
> > P.S.
> > I started using Wicket as part of an article series (because of all of
> > your passion for it) and I have to say all of you are doing incredible
> > work - I love it.. Here's the link to the article series in case any of
> > you are interested:
> > http://www.informit.com/guides/content.aspx?g=java&seqNum=529
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
>
> --
> regards,
> Vineet Semwal
>


Re: OnChangeAjaxBehavior: nth character

2010-02-12 Thread vineet semwal
you can do the same thing with wicket ie. on 5th char typed,make a
ajaxcallback to wicket,

1)you need to add behavior to component and implement it's respond method
the way it suits your need.
2)in the js part you  will make a callback on 5th char typed,callbackurl you
will get from the behavior you
added to the component.
take a look at
http://cwiki.apache.org/confluence/display/WICKET/Calling+Wicket+from+Javascript

On Sat, Feb 13, 2010 at 2:15 AM, Steven Haines  wrote:

> Hi,
>
> I
> would like to add AJAX behavior to an application that sends an update
> to my application after a certain number of characters have been typed.
> For example, if the user is entering a zipcode, I would like a callback
> to my application to be made after the user enters the fifth character.
>
> I've
> written code using OnChangeAjaxBehavior that sends messages back to my
> application after every character has been typed, such as the following:
>
>final TextField zipcodeField = new TextField( "zipcode"
> );
>form.add( zipcodeField.setRequired( true ) );
>OnChangeAjaxBehavior zipcodeUpdated = new OnChangeAjaxBehavior() {
>  @Override
>  protected void onUpdate( AjaxRequestTarget target ) {
>System.out.println( "Zipcode value: " +
> zipcodeField.getDefaultModelObjectAsString() );
>  }
>};
>zipcodeField.add( zipcodeUpdated );
>
>
> I
> could check to see the size of the zipcodeField (in this example), but
> it makes my application more chatty than it needs to be. I also tried
> using onblur, which works fine, but does not satisfy my business
> requirements:
>
>  final TextField zipcodeField = new TextField( "zipcode" );
>  form.add( zipcodeField.setRequired( true ) );
>
>  AjaxFormComponentUpdatingBehavior zipcodeOnBlur = new
> AjaxFormComponentUpdatingBehavior( "onblur" ) {
>  @Override
>  protected void onUpdate( AjaxRequestTarget target ) {
>  System.out.println( "Zipcode value (form component): " +
> getFormComponent().getModelObject() );
>  }
>  };
>  zipcodeField.add( zipcodeOnBlur );
>
>
>
> Prior
> to using Wicket (which I'm currently prototyping for my company), we
> would handle this logic in JavaScript (observe changes to the field and
> when the user enters the fifth character then we made an AJAX call back
> our Struts 2 application.)
>
> What is the best way to achieve the same end using Wicket?
>
> Thanks, in advance, for your help!
> Steve
>
> P.S.
> I started using Wicket as part of an article series (because of all of
> your passion for it) and I have to say all of you are doing incredible
> work - I love it.. Here's the link to the article series in case any of
> you are interested:
> http://www.informit.com/guides/content.aspx?g=java&seqNum=529
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
regards,
Vineet Semwal


OnChangeAjaxBehavior: nth character

2010-02-12 Thread Steven Haines
Hi,

I
would like to add AJAX behavior to an application that sends an update
to my application after a certain number of characters have been typed.
For example, if the user is entering a zipcode, I would like a callback
to my application to be made after the user enters the fifth character.

I've
written code using OnChangeAjaxBehavior that sends messages back to my
application after every character has been typed, such as the following:

final TextField zipcodeField = new TextField( "zipcode" );
form.add( zipcodeField.setRequired( true ) );
OnChangeAjaxBehavior zipcodeUpdated = new OnChangeAjaxBehavior() {
  @Override
  protected void onUpdate( AjaxRequestTarget target ) {
System.out.println( "Zipcode value: " + 
zipcodeField.getDefaultModelObjectAsString() );
  }
};
zipcodeField.add( zipcodeUpdated );


I
could check to see the size of the zipcodeField (in this example), but
it makes my application more chatty than it needs to be. I also tried
using onblur, which works fine, but does not satisfy my business
requirements:

  final TextField zipcodeField = new TextField( "zipcode" );
  form.add( zipcodeField.setRequired( true ) );

  AjaxFormComponentUpdatingBehavior zipcodeOnBlur = new 
AjaxFormComponentUpdatingBehavior( "onblur" ) {
  @Override
  protected void onUpdate( AjaxRequestTarget target ) {
  System.out.println( "Zipcode value (form component): " + 
getFormComponent().getModelObject() );
  }
  };
  zipcodeField.add( zipcodeOnBlur );



Prior
to using Wicket (which I'm currently prototyping for my company), we
would handle this logic in JavaScript (observe changes to the field and
when the user enters the fifth character then we made an AJAX call back
our Struts 2 application.) 

What is the best way to achieve the same end using Wicket?

Thanks, in advance, for your help!
Steve

P.S.
I started using Wicket as part of an article series (because of all of
your passion for it) and I have to say all of you are doing incredible
work - I love it.. Here's the link to the article series in case any of
you are interested:
http://www.informit.com/guides/content.aspx?g=java&seqNum=529

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org