'Enter' is bound to the default Button on your page. You can prevent the
submit by adding some javascript, which intercepts the onKeyPress() 

public static final String JS_SUPPRESS_ENTER = "if(event.keyCode==13 ||
                                     window.event.keyCode==13){return
false;}else{return true;}";
  

public void onComponentTag(Component component, ComponentTag tag) {
    tag.put("onkeydown", JS_SUPPRESS_ENTER);
    tag.put("onkeypress", JS_SUPPRESS_ENTER);
}

hope that helps.
Santiago




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://www.nabble.com/Form-Enter-Key-Problem-tp14408121p14413071.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to