Re: TextField submit via Ajax

2011-02-10 Thread Olivier Dutrieux

Hello,

Just a question : why we can't add Behavior on onsubmit event on form to do
that ?


-
Duto
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/TextField-submit-via-Ajax-tp3002094p3298726.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: TextField submit via Ajax

2011-02-10 Thread Olivier Dutrieux

I do that to intercept (by submit btn or ENTER key on every components form)
the submit form : 

form.add(new AjaxFormValidatingBehavior(form, onsubmit) {

@Override
protected void onSubmit(AjaxRequestTarget target) {
setResponsePage(ResultPage.class, null);
}

@Override
protected CharSequence getEventHandler() {
AppendingStringBuffer handler = new AppendingStringBuffer();
handler.append(super.getEventHandler());
handler.append(; return false;); //  very importante
return handler;
   }

});

If that can help.

Best regards

-
Duto
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/TextField-submit-via-Ajax-tp3002094p3298872.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: TextField submit via Ajax

2011-02-07 Thread jensiator

Thanks. I have been looking for this for s long. Thank again. 

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/TextField-submit-via-Ajax-tp3002094p3264367.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: TextField submit via Ajax

2011-02-07 Thread msj121

If you have multiple html text input elements you can insert the javascript
below in your document etc The only thing new in wicket is that you
simply need to add a callback to your java method, which you can learn about
here (I made a video for this type of issue): 
http://www.youtube.com/watch?v=aqNQShdSOvM
http://www.youtube.com/watch?v=aqNQShdSOvM 

left out of your code post, but you should need an
AjaxFormSubmitBehavior(onkeydown) as Martin pointed out, so for other
users you should post a more complete solution instead of simply script.
But everyone does appreciate you left something for the next person.

function cancelEvent(event){
  event.cancelBubble = true;
  if (event.stopPropagation) event.stopPropagation();
}
if (typeof window.event == 'undefined'){
   document.onkeypress = function(e){
var test_var=e.target.nodeName.toUpperCase();
if (e.target.type) var test_type=e.target.type.toUpperCase();
if ((test_var == 'INPUT'  test_type == 'TEXT') || test_var ==
'TEXTAREA'){
  return e.keyCode;
}else if (e.keyCode == 13){
submit form
  e.preventDefault();
}
   }
 }else{
   document.onkeydown = function(){
var test_var=event.srcElement.tagName.toUpperCase();
if (event.srcElement.type) var
test_type=event.srcElement.type.toUpperCase();
if ((test_var == 'INPUT'  test_type == 'TEXT') || test_var ==
'TEXTAREA'){
  return event.keyCode;
}else if (event.keyCode == 13){
submit value
  event.returnValue=false;
}
   }
 }

Matthew


Altuğ Bilgin Altıntaş wrote:
 
 Hi Martin;
 
 It works thanks; but my condition needs onkeydown anyway  now i am
 posting
 the complete solution for others
 
 Code goal : user enters some char in textfield and press enter, and data
 comes via ajax.
 
 final TextFieldString txtMy= new TextFieldString(txtMy, new
 Model())
 ;
 txtMy.add(new AjaxFormComponentUpdatingBehavior(onkeydown) {
 @Override
 protected void onUpdate(AjaxRequestTarget target) {
 //...
 }
 
 @Override
 protected IAjaxCallDecorator getAjaxCallDecorator() {
 return new AjaxCallDecorator() {
 private static final long serialVersionUID = 1L;
 
 @Override
 public CharSequence decorateScript(CharSequence
 script)
 {
 return if(wicketKeyCode(event) == 13){ + script
 +
  return false;};
 }
 };
 }
 ;
 });
 
 Altug.
 
 2010/10/19 Martin Grigorov mgrigo...@apache.org
 
 1. you need AjaxFormSubmitBehavior(onkeyup)
 2. you'll have to add AjaxCallDecorator to it do fire only when the key
 is
 ENTER, i.e. event.keyCode === 13

 2010/10/19 Altuğ Bilgin Altıntaş alt...@gmail.com

  Hi;
 
  How can i submit a form via Ajax when user hit the enter key on a
 TextField
  ?
 
  I did below but it doesn't work.
 
  myTextField.add(new AjaxFormComponentUpdatingBehavior(onsubmit) {
 @Override
 protected void onUpdate(AjaxRequestTarget target) {
//...
 
 }
 
   });
 
  Thanks.
 

 
 

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/TextField-submit-via-Ajax-tp3002094p3264785.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: TextField submit via Ajax

2010-10-20 Thread Altuğ Bilgin Altıntaş
Hi Martin;

It works thanks; but my condition needs onkeydown anyway  now i am posting
the complete solution for others

Code goal : user enters some char in textfield and press enter, and data
comes via ajax.

final TextFieldString txtMy= new TextFieldString(txtMy, new Model())
;
txtMy.add(new AjaxFormComponentUpdatingBehavior(onkeydown) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//...
}

@Override
protected IAjaxCallDecorator getAjaxCallDecorator() {
return new AjaxCallDecorator() {
private static final long serialVersionUID = 1L;

@Override
public CharSequence decorateScript(CharSequence script)
{
return if(wicketKeyCode(event) == 13){ + script +
 return false;};
}
};
}
;
});

Altug.

2010/10/19 Martin Grigorov mgrigo...@apache.org

 1. you need AjaxFormSubmitBehavior(onkeyup)
 2. you'll have to add AjaxCallDecorator to it do fire only when the key is
 ENTER, i.e. event.keyCode === 13

 2010/10/19 Altuğ Bilgin Altıntaş alt...@gmail.com

  Hi;
 
  How can i submit a form via Ajax when user hit the enter key on a
 TextField
  ?
 
  I did below but it doesn't work.
 
  myTextField.add(new AjaxFormComponentUpdatingBehavior(onsubmit) {
 @Override
 protected void onUpdate(AjaxRequestTarget target) {
//...
 
 }
 
   });
 
  Thanks.
 



TextField submit via Ajax

2010-10-19 Thread Altuğ Bilgin Altıntaş
Hi;

How can i submit a form via Ajax when user hit the enter key on a TextField
?

I did below but it doesn't work.

myTextField.add(new AjaxFormComponentUpdatingBehavior(onsubmit) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
   //...

}

 });

Thanks.


Re: TextField submit via Ajax

2010-10-19 Thread Martin Grigorov
1. you need AjaxFormSubmitBehavior(onkeyup)
2. you'll have to add AjaxCallDecorator to it do fire only when the key is
ENTER, i.e. event.keyCode === 13

2010/10/19 Altuğ Bilgin Altıntaş alt...@gmail.com

 Hi;

 How can i submit a form via Ajax when user hit the enter key on a TextField
 ?

 I did below but it doesn't work.

 myTextField.add(new AjaxFormComponentUpdatingBehavior(onsubmit) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
   //...

}

  });

 Thanks.