Well the error messages kind of gives it away, doesn't it?

But to explain further: setDefaultFormProcessing(false) doesn't mean the
button can be placed outside a a form. It means that the default
validation and submit behavior of the form is not executed when pressing
the button. Why do you want to use AjaxButton? Outside a form AjaxLink
does the job as you already discovered... 

On Thu, Mar 28, 2013, at 18:45, eugenebalt wrote:
> I have the below block of code. A Link or an AjaxLink works perfectly
> here
> inside a WebMarkupContainer. But when I use an AjaxButton (with a
> setDefaultFormProcessing=False), I get an error. Thanks
> 
>               AjaxButton linkCopy = new AjaxButton("linkCopy") {
> 
>                       @Override
>                       protected void onSubmit(AjaxRequestTarget arg0, Form<?> 
> arg1) {
>                               // TODO Auto-generated method stub
>                               
>                       }                       
>               };
>               linkCopy.setDefaultFormProcessing(false);
>               wmcMarkup.add(linkCopy);
> 
> Error:
> java.lang.IllegalStateException: form was not specified in the
> constructor
> and cannot be found in the hierarchy of the component this behavior is
> attached to
>       at
> org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.getForm(AjaxFormSubmitBehavior.java:92)
>       at
> org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.getEventHandler(AjaxFormSubmitBehavior.java:108)
>       at
> org.apache.wicket.ajax.markup.html.form.AjaxButton$1.getEventHandler(AjaxButton.java:131)
>       at
> org.apache.wicket.ajax.AjaxEventBehavior.onComponentTag(AjaxEventBehavior.java:111)
>       at
> org.apache.wicket.behavior.AbstractAjaxBehavior.onComponentTag(AbstractAjaxBehavior.java:134)
>       at org.apache.wicket.Component.renderComponentTag(Component.java:4009)
>       at org.apache.wicket.Component.renderComponent(Component.java:2610)
> 
> 
> 
> 
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AjaxButton-doesn-t-work-in-WebMarkupContainer-tp4657633.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to