Here is how I submit a form from a text field when the user presses the
enter key. I haven't tried this on an AjaxSubmitLink.

                        textField.add(new AjaxFormSubmitBehavior("onkeypress")
                        {
                                protected void onSubmit(AjaxRequestTarget 
target)
                                {
                                        // do something
                                }
                                protected void onError(AjaxRequestTarget target)
                                {
                                }
                                protected IAjaxCallDecorator 
getAjaxCallDecorator()
                                {
                                        return new AjaxCallDecorator()
                                        {
                                                public CharSequence 
decorateScript(CharSequence script)
                                                {
                                                        return 
"if(window.event.keyCode == 13){" + script + "};";
                                                }
                                        };
                                }
                        });

and then add onsubmit="return false;" in your form markup

<form onsubmit="return false;" ...>

> -----Original Message-----
> From: Ryan O'Hara [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 01, 2008 1:12 PM
> To: [email protected]
> Subject: FeedbackPanel not displaying message
>
>
> I'm having trouble getting messages to display in the FeedbackPanel.
> Also, any idea how to get the form to submit after the user presses
> enter/return in a textfield (when using AjaxSubmitLink)?  Any ideas?
> Below is my code.
>
>         //feedbackPanel
>          FeedbackPanel feedbackPanel = new FeedbackPanel
> ("feedbackPanel");
>          feedbackPanel.add(new AttributeModifier("class", true, new
> Model("feedbackPanel")));
>          feedbackPanel.setFilter(new ContainerFeedbackMessageFilter
> (form));
>          form.add(feedbackPanel);
>          form.add(new TextField("name"));
>
>          //submit button
>
>          AjaxSubmitLink submit = new AjaxSubmitLink("submit") {
>              public void onSubmit(AjaxRequestTarget target, Form form) {
>                  try {
>                      groupsDisplay.add(new AttributeModifier("class",
> true, new Model("groupsDisplay")));
>                      target.addComponent(groupsDisplay);
>                      info("Groups for " + name + ".");
>                  } catch (Exception e) {
>                      error("Unable to get groups for " + name + ".");
>                  }
>              }
>          };
>          form.add(submit);
>
> Thanks,
> Ryan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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

Reply via email to