You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Andrea Del Bene (JIRA)" <ji...@apache.org> on 2017/11/28 16:46:00 UTC
[jira] [Commented] (WICKET-6448) Provide behavior that disables a
button after click
[ https://issues.apache.org/jira/browse/WICKET-6448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16269024#comment-16269024 ]
Andrea Del Bene commented on WICKET-6448:
-----------------------------------------
Hi,
as Martin suggested I also prefer to implement an AJAX listener to provide such feature. Here is a first implementation:
{code:java}
public class AjaxDisableComponentListener extends AjaxCallListener
{
/**
*
*/
private static final long serialVersionUID = -3772784701483881109L;
private static final String DISABLE_ENABLE_JS = ";document.getElementById('%s').disabled = %s;";
@Override
public CharSequence getBeforeHandler(Component component)
{
return String.format(DISABLE_ENABLE_JS, component.getMarkupId(), true);
}
@Override
public CharSequence getCompleteHandler(Component component)
{
return String.format(DISABLE_ENABLE_JS, component.getMarkupId(), false);
}
}
{code}
Those who need also an indicating picture can use AjaxIndicatorAppender.
> Provide behavior that disables a button after click
> ---------------------------------------------------
>
> Key: WICKET-6448
> URL: https://issues.apache.org/jira/browse/WICKET-6448
> Project: Wicket
> Issue Type: Bug
> Components: wicket-extensions
> Affects Versions: 8.0.0-M6
> Reporter: Kamil
> Assignee: Andrea Del Bene
> Attachments: block-comment-doublesubmit.png, showcase-preventClick.zip
>
>
> Wicket should provide a Behavior that can be assigned to (Ajax)Buttons and when clicked those buttons should be disabled via the HTML "disabled" attribute.
> For AjaxButtons the behavior should re-enable the button after processing the Ajax response.
> 1)Run the app
> 2)Click "submit" quickly several times
> 3)Watch the console
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)