You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by james yong <i_...@yahoo.com.sg> on 2010/09/16 05:18:05 UTC
Re: Form/Enter Key Problem
Sorry for replying to an old post.
The problem can be solved by moving the submit field out of the form in the
html template
--james
Ballist1c wrote:
>
> Hey guys,
>
> I have created the following form (code below).
>
> The form works fine, when i enter a value into the txt field and mouse
> click on the AjaxFormSubmitLink... BUT if i type something into the
> TextField and press the enter key, the page loads 'something'... but does
> nothing.... and the form is broken till i do a hard refresh, usually i
> close the browser and start it up again. The application itself doesn't
> crash, and all the other AJAX on the page works fine.
>
> I want to know if anyone has had this problem before. I am pretty stuck
> on this one at the moment.
>
> One hack solution i was wondering if someone can help me out with, is to
> disable the auto-submit on Enter Key press... anyone know how to do that?
>
>
> Thanks guys!!!
> LEo1
>
>
> public class SearchInputPanel extends Form
> {
> TextField basicSearchString;
> DropDownChoice dodginess;
> AjaxFormSubmitLink addButton;
> Input input;
>
> /**
> * Creates a new instance of FormPanel
> */
> public SearchInputPanel(String id, MarkupContainer parent)
> {
> super(id, parent);
> }
>
> @Override
> public void setupComponents()
> {
> input = new Input();
> basicSearchString = new TextField("searchString", this);
> dodginess = new DropDownChoice("dodginess", this, Arrays.asList(new
> String[]{"1", "2", "3", "4", "5"}));
>
> addButton = new AjaxFormSubmitLink("add", this)
> {
> public void onSubmit(AjaxRequestTarget target)
> {
> //MessageManager.getInstance().getLatestMessages();
> //((BigBrotherCookieSession)
> getJumbuckCookieSession()).setSearchResults(MessageManager.getInstance().getNewMessages());
> target.addComponent(findParent(BasicSearchPanel.class));
> }
>
> public Form getJumbuckForm()
> {
> return SearchInputPanel.this.getForm();
> }
> };
> }
>
> @Override
> public void setupModels()
> {
> setModel(new CompoundPropertyModel(input));
> }
>
> @Override
> public void onSubmit()
> {
> BigBrotherCookieSession session = (BigBrotherCookieSession)
> getJumbuckCookieSession();
> session.addSearchString(input.getSearchString(),
> input.getDodginess());
>
> input.setSearchString("");
> }
>
> private static class Input implements IClusterable
> {
> private String searchString = "";
> private Long dodginess = 1L;
>
> public String getSearchString()
> {
> return searchString;
> }
>
> public void setSearchString(String searchString)
> {
> this.searchString = searchString;
> }
>
> public Long getDodginess()
> {
> return dodginess;
> }
>
> public void setDodginess(Long dodginess)
> {
> if (dodginess == null)
> this.dodginess = 1L;
> else
> this.dodginess = dodginess;
> }
> }
> }
>
>
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Form-Enter-Key-Problem-tp1869795p2541503.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Form/Enter Key Problem
Posted by Olivier Dutrieux <ol...@pasteur.fr>.
My solution is to AjaxFormValidatingBehavior on form :
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 CharSequence getEventHandler() {
AppendingStringBuffer handler = new AppendingStringBuffer();
handler.append(super.getEventHandler());
handler.append("; return false;"); // <---- very importante
return handler;
}
});
If that's can help.
Best regards
-----
Duto
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Form-Enter-Key-Problem-tp1869795p3298877.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org