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(_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);
}
}
-igor
On 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;
@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=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
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=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
