a while back i really needed this to work properly. so what i did was use _javascript_.
add a hidden input to the form and initialize it with the name of the default button.
then each button becomes type="button" instead of type="submit" and onclick you do something like this.form.tracker=this.name; this.form.submit;"
that way your hidden input always contains the name of the button clicked, or default one if form was submitted using enter.
another thing to try is to set taborder on the form controls, maybe that way the button with lowest tab order becomes the default, but i havent tried it and dont know if its cross browser.
i suppose we could design a _javascript_ system like above for wicket. if you are willing to put in the time to do it i would be willing to help.
-Igor
On 2/8/06,
Gustavo Hexsel <[EMAIL PROTECTED]> wrote:
Hi all,
is there a way of setting which one is the default button when hitting Enter on a form? I've tried looking for Wicket or _javascript_ solutions, I can't seem to find something that will post the correct button on the form - it's always the first one in the markup.
The closest I've got was:
--------------------------------------
function submitEnter(myfield,e) {
var keycode;
if (window.event) {
keycode = window.event.keyCode;
} else if (e) {
keycode = e.which;
} else {
return true;
}
if (keycode == 13) {
document.forms['searchForm'].searchButton.click();
return false;
} else {
return true;
}
}
...
<button wicket:id="browseButton" type="submit">Browse</button>
...
<input wicket:id="searchTerm" maxlength="100" size="45" type="text" submitEnter(this, event);" />
...
<button wicket:id="searchButton" type="submit" id="searchButton">Search</button>
...
-----------------------
I've tried both <button> and <input type="submit">, both with the same result. Wicket still reports the post as being done from the other button. Below is the page's code that deals with the buttons:
add(new Button("searchButton") {
protected void onSubmit() {
search();
}
});
add(new Button("browseButton") {
protected void onSubmit() {
browse();
}
});
From there, I just have a log that prints info that came from the form (which seems to have been updated correctly).
I'm using Firefox 1.5, Wicket 1.1.
Are there any obvious mistakes? Is there a way to do this? I could resort to using _javascript_ to manipulate some hidden input...
Thanks!
[]s Gus
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmdlnk&kid3432&bid#0486&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
