Hi,
I think Sven's solution is more generic.
Also it will be consistent with WICKET-5597
On Apr 13, 2015 5:20 PM, "Sven Meier" <[email protected]> wrote:
> Well, then we should change the type attribute as well, i.e. from "submit"
> to "button".
>
> Why not just use #setPreventDefault(true)? Because if JavaScript is
> disabled, the browser will still submit the form, without triggering the
> callback on the AjaxSubmitLink.
>
> Regards
> Sven
>
>
> Am 13.04.2015 um 18:01 schrieb andrea del bene:
>
>> The case pointed out by Don is slightly different as the AjaxSubmitLink
>> is attached to a <input type="submit"/> tag. Adding
>> 'attributes.setPreventDefault(true);' in updateAttributes actually
>> solves his problem.
>>
>> On 13/04/2015 14:32, Sven Meier wrote:
>>
>>> Hi Andrea,
>>>
>>> since WICKET-5597 AjaxSubmitLink already changes the button to prevent
>>> default submitting of the form:
>>>
>>> tag.put("type", "button");
>>>
>>> Have fun
>>> Sven
>>>
>>>
>>> Am 13.04.2015 um 14:19 schrieb Andrea Del Bene:
>>>
>>>> Due to WICKET-5197 I think we should add to
>>>> 'attributes.setPreventDefault(true);' to AjaxSubmitLink
>>>>
>>>>> Hi,
>>>>>
>>>>> Please create a quickstart app and attach it to a ticket at JIRA.
>>>>> Thanks!
>>>>> On Apr 12, 2015 9:43 PM, "Don Ferguson" <[email protected]>
>>>>> wrote:
>>>>>
>>>>> Dear Wicket Boffins,
>>>>>>
>>>>>> I have a Wicket 6 app that I’ve recently migrated to Wicket 7. In
>>>>>> the
>>>>>> app there is a form whose AjaxSubmitLink hides the form as part of the
>>>>>> submit. In Wicket7, this causes a ListenerInvocationNotAllowedException
>>>>>> to
>>>>>> be thrown, since the component that submitted the form is no longer
>>>>>> visible. What is the approved “wicket way” to do what I’m attempting?
>>>>>>
>>>>>> Thanks in advance.
>>>>>>
>>>>>> -Don
>>>>>>
>>>>>> Here’s a stripped down version of the code:
>>>>>>
>>>>>> JAVA:
>>>>>>
>>>>>> public class TestPage extends WebPage {
>>>>>> public TestPage() {
>>>>>> Form form = new Form("form");
>>>>>> form.add(new AjaxSubmitLink("submit") {
>>>>>> @Override
>>>>>> protected void onSubmit(AjaxRequestTarget target, Form<?>
>>>>>> form) {
>>>>>> super.onSubmit(target, form);
>>>>>> form.setVisible(false);
>>>>>> target.add(form);
>>>>>> }
>>>>>> });
>>>>>> add(form.setOutputMarkupPlaceholderTag(true));
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> HTML:
>>>>>> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="
>>>>>> http://wicket.apache.org">
>>>>>> <body>
>>>>>> <h3>Test Form Submit Hides Form</h3>
>>>>>>
>>>>>> <form wicket:id="form">
>>>>>> <h4>Form Element</h4>
>>>>>> <input type="submit" wicket:id="submit" value="Submit"/>
>>>>>> </form>
>>>>>>
>>>>>> </body>
>>>>>>
>>>>>> EXCEPTION THROWN ON SUBMIT:
>>>>>> org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException:
>>>>>>
>>>>>> Component rejected interface invocationComponent: [Form [Component id
>>>>>> =
>>>>>> form]] Listener: [RequestListenerInterface name=IFormSubmitListener,
>>>>>> method=public abstract void
>>>>>> org.apache.wicket.markup.html.form.IFormSubmitListener.onFormSubmitted()]
>>>>>>
>>>>>> at
>>>>>> org.apache.wicket.RequestListenerInterface.invoke(
>>>>>> RequestListenerInterface.java:212)
>>>>>> at
>>>>>> org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandle
>>>>>> r.invokeListener(ListenerInterfaceRequestHandler.java:241)
>>>>>> at
>>>>>> org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandle
>>>>>> r.respond(ListenerInterfaceRequestHandler.java:234)
>>>>>> …
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> 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]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>