PL-8937 Do not send Vaadin RPC call back to browser on each button click

This commit is contained in:
Yuriy Artamonov 2017-04-12 14:50:53 +04:00
parent 45ca81138b
commit 65deae4e01
5 changed files with 33 additions and 3 deletions

View File

@ -44,6 +44,7 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
protected PropertyChangeListener actionPropertyChangeListener;
protected boolean disableOnClick = false;
protected boolean useResponsePending = false;
public DesktopButton() {
impl = createImplementation();
@ -55,7 +56,7 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
return;
}
if (e.getWhen() <= responseEndTs) {
if (useResponsePending && e.getWhen() <= responseEndTs) {
return;
}
@ -213,4 +214,14 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
public boolean isDisableOnClick() {
return disableOnClick;
}
@Override
public boolean isUseResponsePending() {
return useResponsePending;
}
@Override
public void setUseResponsePending(boolean useResponsePending) {
this.useResponsePending = useResponsePending;
}
}

View File

@ -32,4 +32,15 @@ public interface Button extends Component, Component.HasCaption, Component.Belon
* @return true if the button is disabled when clicked.
*/
boolean isDisableOnClick();
/**
* @return true if button will ignore subsequent clicks on client side when it is waiting for server response
*/
boolean isUseResponsePending();
/**
* Determines if button will ignore subsequent clicks on client side when it is waiting for server response.
*
* @param useResponsePending whether to use response pending
*/
void setUseResponsePending(boolean useResponsePending);
}

View File

@ -24,7 +24,7 @@ import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.button.ButtonConnector;
import com.vaadin.shared.ui.Connect;
@Connect(value = CubaButton.class, loadStyle = Connect.LoadStyle.EAGER)
@Connect(value = CubaButton.class)
public class CubaButtonConnector extends ButtonConnector {
protected boolean pendingResponse = false;

View File

@ -156,4 +156,12 @@ public class WebButton extends WebAbstractComponent<CubaButton> implements Butto
public boolean isDisableOnClick() {
return component.isDisableOnClick();
}
public boolean isUseResponsePending() {
return component.isUseResponsePending();
}
public void setUseResponsePending(boolean useResponsePending) {
component.setUseResponsePending(useResponsePending);
}
}

View File

@ -21,5 +21,5 @@ import com.vaadin.shared.ui.button.ButtonState;
public class CubaButtonState extends ButtonState {
public boolean useResponsePending = true;
public boolean useResponsePending = false;
}