You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Robert Murphy <ro...@westringtechnologies.com> on 2022/09/28 17:22:06 UTC
Feature request: AjaxButton that can be used as type reset or type button in addition to current type submit
Forgive me if there is already an AjaxButton as described below:
Currently AjaxButton must be in a form or have a form instance passed into its constructor and has an onSubmit(...) method and is of type="submit" (by omitting type attribute, standards consider it a submit).
Proposal:
* add method onClick(...) to AjaxButton, if AjaxButton is in a form or a form has been set on it, and it is of type submit, protected onClick(...) is never called
* AjaxButton can be used outside of a form, protected onSubmit(...) will never be called on an AjaxButton that is not in a form (unless a form it is not a descendant of has been passed into the constructor)
* When AjaxButton is not in a form, type will be explicitly, automatically, set to type="button" unless template has type="reset" or AttributeModifier is used to set type to reset or a form instance has been passed into the constructor
* If AjaxButton is in a form or has had a form passed to it constructor, but type="button" in template or type set to button via ajaxbutton.add(new AttributeModifier("type","button")) then onSubmit(...) will never be called, onClick(...) will be called instead.
Purpose: There are many instances where developers use AjaxLink but from an ADA Compliance standpoint that is frowned upon if not used for loading content or navigating content. Links (<a/>) should link to something (go to another page, load additional content into the current page, jump to another location on the current page, etc), Buttons (<button/>) should do something (submit a form, remove or hide an element, reset a form or field, start a client side process, etc). You should never use an <a/> to reset a form, that is what <button type="reset"/> is for, you should never use an <a/> to start a client side program, that is what <button type="button"/> is for. This is important from a semantic markup standpoint, accessibility tools should be able to figure out how to present things without analyzing CSS and JavaScript
The AjaxButton should behave exactly like an AjaxLink when it is included in a template where it is not a descendant of a form or where its type has been set to reset or button.
Robert Murphy | Software Developer - Rocky Mountain ATV/MC
Rocky Mountain ATV/MC - 502.291.2076<tel:+15022912076>
Address - 77 E 800 N, Spanish Fork, UT 84660<https://goo.gl/maps/ERSNZK8AK5Bf1Xnh9>
Website - www.rockymountainatvmc.com<https://www.rockymountainatvmc.com/>
Re: Feature request: AjaxButton that can be used as type reset or type button in addition to current type submit
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
You can use AjaxLink with <button />.
Wicket will automatically set its type to "button" -
https://github.com/apache/wicket/blob/7a87b09e6f96f2fceccb497fa873595c726e5efb/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java#L126
.
If you have a form in the page then you should use AjaxButton. In addition
you could use #setDefaultFormProcessing(false) for the reset functionality.
On Wed, Sep 28, 2022 at 8:46 PM Robert Murphy <
robert.murphy@westringtechnologies.com> wrote:
> Forgive me if there is already an AjaxButton as described below:
>
> Currently AjaxButton must be in a form or have a form instance passed into
> its constructor and has an onSubmit(...) method and is of type="submit" (by
> omitting type attribute, standards consider it a submit).
> Proposal:
>
> * add method onClick(...) to AjaxButton, if AjaxButton is in a form or
> a form has been set on it, and it is of type submit, protected onClick(...)
> is never called
> * AjaxButton can be used outside of a form, protected onSubmit(...)
> will never be called on an AjaxButton that is not in a form (unless a form
> it is not a descendant of has been passed into the constructor)
> * When AjaxButton is not in a form, type will be explicitly,
> automatically, set to type="button" unless template has type="reset" or
> AttributeModifier is used to set type to reset or a form instance has been
> passed into the constructor
> * If AjaxButton is in a form or has had a form passed to it
> constructor, but type="button" in template or type set to button via
> ajaxbutton.add(new AttributeModifier("type","button")) then onSubmit(...)
> will never be called, onClick(...) will be called instead.
> Purpose: There are many instances where developers use AjaxLink but from
> an ADA Compliance standpoint that is frowned upon if not used for loading
> content or navigating content. Links (<a/>) should link to something (go to
> another page, load additional content into the current page, jump to
> another location on the current page, etc), Buttons (<button/>) should do
> something (submit a form, remove or hide an element, reset a form or field,
> start a client side process, etc). You should never use an <a/> to reset a
> form, that is what <button type="reset"/> is for, you should never use an
> <a/> to start a client side program, that is what <button type="button"/>
> is for. This is important from a semantic markup standpoint, accessibility
> tools should be able to figure out how to present things without analyzing
> CSS and JavaScript
>
> The AjaxButton should behave exactly like an AjaxLink when it is included
> in a template where it is not a descendant of a form or where its type has
> been set to reset or button.
>
> Robert Murphy | Software Developer - Rocky Mountain ATV/MC
>
> Rocky Mountain ATV/MC - 502.291.2076<tel:+15022912076>
> Address - 77 E 800 N, Spanish Fork, UT 84660<
> https://goo.gl/maps/ERSNZK8AK5Bf1Xnh9>
> Website - www.rockymountainatvmc.com<https://www.rockymountainatvmc.com/>
>
>