Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Hi all,
I want to create this very simple logic... Disable a button for 3 seconds after clicked then enable again. It seems that this program has a way of making very simple logic ... complex for me.
Can anyone explain how this very basic feature can be implemented.
Solved! Go to Solution.
Something like this. The service is just a dummy for a longer running service.
You can use a autorefresh widget, enable the widget on click of button, configure it of 3 seconds, then on click of it enable the refresh and then the refresh widget can enable it again,
Okay, I will try to look into that. Thanks
May I ask, why 3 seconds?
Its because the button activates a lot of services and it need to align with a timer in order to update my data correctly. So I want to disable the use the possibility of executing the button again before its done.
Ok, that's what I thought. But in terms of a robust design, you can't assume the service execution will be always three seconds. There might be changes to the system, or an unusual load on the system which might cause this to be longer.
You could try to solve this on client side (see below), but remember there could be many users using the same mashup (which on client side you have no control over), also someone might call the service directly via REST API and won't use the mashups at all. So it might be better so solve that on server side, e.g. by setting a session variable or a thing property on service execution and when the service is called a second time while it is still running, this can be detected and execution simply be skipped. That way the users could click the button, but nothing would happen.
In case you want to solve client-side (i.e. in mashup code), the event you want to wait for is not when 3 seconds have passed, but when the service actually returns. So for this use case, you would rather bind to the "ServiceInvokeCompleted" event on the data tab of the service called by clicking the button than to have a fixed 3 second auto-reload.
Now you have an event, but then, the button takes a boolean input - you will have to use expression to convert events to a boolean input you can then bind to the button. What you can't do is to simply write two expressions, one to disable and one to enable the button, since you can only bind the "Disabled" property of the button once, plus you can't get the current state. A way of solving this would be to add a hidden (non-visible) checkbox which has a "State" property which can be an input to an expression. You wire the checkbox state to the buttons Disabled property and the expression would use the State and return the negated value.
Thanks for the detailed description. Is it possible you could provide me with a simple template of this functionality?
Something like this. The service is just a dummy for a longer running service.
Thanks. I'll have a look.