wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grigorov <mgrigo...@apache.org>
Subject Re: Showing label while processing request
Date Tue, 16 Oct 2012 06:58:32 GMT
Hi,

Isn't it better to disable the disable the button itself if it
shouldn't be clicked anymore ?

On Mon, Oct 15, 2012 at 6:06 PM, Anna Simbirtsev <asimbirtsev@gmail.com> wrote:
> Hi
>
> I want to show a label like "Processing.... Do not click submit button
> again." when AjaxSubmitLink is clicked.
>
> AjaxSubmitLink processes large volume of data, and is slow, and clicking
> the button twice, processes the records twice.
>
> I added the following, but it does not work.

I guess it doesn't work because you do the work in onClick() and the
response is returned after finishing the processing of the data.
I see two solutions:

1) disable the link with JavaScript right after clicking it, then make
the Ajax call and finally enable it again when the ajax returns
to do that use IAjaxCallDecorator to insert the JS to disable the link
when clicked, and success/failure script to re-enable it when ready

2) Do the processing in a separate thread at the server side and then
check whether the job is finished with ajax timer behavior and when
ready re-enable the link

>
> Label processing = new Label("processing", new Model<String>(""));
>         processing.setOutputMarkupPlaceholderTag(true);
>         form.add(processing);
>
> private AjaxSubmitLink makeBulkBalanceSubmitLink()
>     {
>         return  new AjaxSubmitLink("submitButton1") {
>
>             private static final long serialVersionUID = 1L;
>
>             protected void onSubmit(AjaxRequestTarget target, final Form<?>
> form)
>             {
>                   processing.setDefaultModelObject("Processing.... Do not
> click submit button again.");
>                   target.addComponent(processing);
>
>                   ....................
>                     setResponsePage(MyClass.class, params);



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Mime
View raw message