Re: [Wicket-user] submit through Enter will ignore AjaxSubmitButton

2006-10-28 Thread deafwolf
I write the code like this

searchString.add(new AbstractBehavior(){
private static final long serialVersionUID = 1L;

@Override
public void onComponentTag(Component component, ComponentTag tag) {
tag.put(onkeydown, if(event.keyCode==13)
{searchForm_search.click();return false;});
}
});

now, I can click the Enter when focus on TextField to submit form by ajax.
But I still can't understand why the second code I had write can work well.
I think there's some subtle difference between the two code render in IE6.

Thank you very much.

deafwolf



 this is a browser feature

 what you can do is add the behavior below to all textfields in the form

 /**
  * Behavior that traps the enter key press
  *
  * @author ivaynberg
  */
 public class EnterKeyTrap extends AbstractBehavior implements
 IHeaderContributor {
@Override
public void onComponentTag(Component component, ComponentTag tag) {
tag.put(onkeydown, return ekt(event)!=13);
}

public void renderHead(Response response) {
response.write(JavascriptUtils.SCRIPT_OPEN_TAG);
response.write(function
 ekt(e){if(typeof(e.keyCode)==\undefined\){return
 e.which;}else{return e.keyCode;}});
response.write(JavascriptUtils.SCRIPT_CLOSE_TAG);
}
 }

 -igor

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


[Wicket-user] submit through Enter will ignore AjaxSubmitButton

2006-10-27 Thread deafwolf
hello,

I have wrote a form on the page,
it only have one TextField and one IndicatingAjaxSubmitButton,
I input some text in the TextField and click Enter,
the page will refresh but not submit, the button work well.

I'm using wicket1.2.2, this problem happen in IE6.
In FireFox, click Enter will submit the form through button.

final SearchBean bean = new SearchBean();
Form form = new Form(searchForm, new Model(bean));
add(form);
form.add(new RequiredTextField(searchString, new PropertyModel(bean,
searchString)));
form.add(new IndicatingAjaxSubmitButton(search, form) {
private static final long serialVersionUID = 1L;

@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
SearchBean temp = (SearchBean) form.getModelObject();
InfoSearchListPanel panel = new InfoSearchListPanel(
HomePage.PANEL_ID, temp.getSearchString());
getPage().replace(panel);
target.addComponent(panel);
}
});


BUT,
I write another form, the code looks like above,
click Enter will submit the form through button in IE6.

Form form = new Form(infoForm, new Model(info));
add(form);
form.add(new RequiredTextField(date, new PropertyModel(info, date),
Date.class));//I have replace the id from chinese to english
form.add(new RequiredTextField(title, new PropertyModel(info, title))
.add(StringValidator.maximumLength(200)));
final RequiredTextField labelField = new RequiredTextField(label,
new PropertyModel(info, label));
labelField.add(StringValidator.maximumLength(40));
form.add(labelField);
DropDownChoice labelChoice = new DropDownChoice(labelChoice, new Model(
tempString), dao.labelList(), new IChoiceRenderer() {
private static final long serialVersionUID = 1L;

public Object getDisplayValue(Object arg0) {
return arg0;
}

public String getIdValue(Object arg0, int arg1) {
return arg0.toString();
}
});
form.add(labelChoice);
form.add(new TextField(keywords, new PropertyModel(info, keywords))
.add(StringValidator.maximumLength(200)));
form.add(new TextArea(content, new PropertyModel(info, content)));
form.add(new IndicatingAjaxSubmitButton(save, form) {
private static final long serialVersionUID = 1L;

@Override
protected void onError(AjaxRequestTarget target, Form form) {
target.addComponent(feedback);
}

@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
Info info = (Info) form.getModelObject();
dao.save(info);
getPage().replace(backPanel);
target.addComponent(backPanel);
}
});

Why this? I don't think the two copy of code has any essential difference,
this problem is too strange.

best regard

deafwolf

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] submit through Enter will ignore AjaxSubmitButton

2006-10-27 Thread Igor Vaynberg
this is a browser featurewhat you can do is add the behavior below to all textfields in the form/*** Behavior that traps the enter key press* * @author ivaynberg*/public class EnterKeyTrap extends AbstractBehavior implements IHeaderContributor {
 @Override public void onComponentTag(Component component, ComponentTag tag) {  tag.put(onkeydown, return ekt(event)!=13); } public void renderHead(Response response) {
  response.write(_javascript_Utils.SCRIPT_OPEN_TAG);  response.write(function ekt(e){if(typeof(e.keyCode)==\undefined\){return e.which;}else{return e.keyCode;}});  response.write
(_javascript_Utils.SCRIPT_CLOSE_TAG); }}-igorOn 10/27/06, deafwolf [EMAIL PROTECTED]
 wrote:hello,I have wrote a form on the page,it only have one TextField and one IndicatingAjaxSubmitButton,
I input some text in the TextField and click Enter,the page will refresh but not submit, the button work well.I'm using wicket1.2.2, this problem happen in IE6.In FireFox, click Enter will submit the form through button.
final SearchBean bean = new SearchBean();Form form = new Form(searchForm, new Model(bean));add(form);form.add(new RequiredTextField(searchString, new PropertyModel(bean,searchString)));
form.add(new IndicatingAjaxSubmitButton(search, form) {private static final long serialVersionUID = 1L;@Overrideprotected void onSubmit(AjaxRequestTarget target, Form form) {
SearchBean temp = (SearchBean) form.getModelObject();InfoSearchListPanel panel = new InfoSearchListPanel(HomePage.PANEL_ID, temp.getSearchString());
getPage().replace(panel);target.addComponent(panel);}});BUT,I write another form, the code looks like above,click Enter will submit the form through button in IE6.
Form form = new Form(infoForm, new Model(info));add(form);form.add(new RequiredTextField(date, new PropertyModel(info, date),Date.class));//I have replace the id from chinese to english
form.add(new RequiredTextField(title, new PropertyModel(info, title)).add(StringValidator.maximumLength(200)));final RequiredTextField labelField = new RequiredTextField(label,
new PropertyModel(info, label));labelField.add(StringValidator.maximumLength(40));form.add(labelField);DropDownChoice labelChoice = new DropDownChoice(labelChoice, new Model(
tempString), dao.labelList(), new IChoiceRenderer() {private static final long serialVersionUID = 1L;public Object getDisplayValue(Object arg0) {return arg0;
}public String getIdValue(Object arg0, int arg1) {return arg0.toString();}});form.add(labelChoice);form.add(new TextField(keywords, new PropertyModel(info, keywords))
.add(StringValidator.maximumLength(200)));form.add(new TextArea(content, new PropertyModel(info, content)));form.add(new IndicatingAjaxSubmitButton(save, form) {
private static final long serialVersionUID = 1L;@Overrideprotected void onError(AjaxRequestTarget target, Form form) {target.addComponent(feedback);}
@Overrideprotected void onSubmit(AjaxRequestTarget target, Form form) {Info info = (Info) form.getModelObject();dao.save(info);getPage().replace(backPanel);
target.addComponent(backPanel);}});Why this? I don't think the two copy of code has any essential difference,this problem is too strange.best regarddeafwolf
-Using Tomcat but need to do more? Need to support web services, security?Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimohttp://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___Wicket-user mailing listWicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user