mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-04 20:28:00 +08:00
PL-8937 Do not send Vaadin RPC call back to browser on each button click
This commit is contained in:
parent
45ca81138b
commit
65deae4e01
@ -44,6 +44,7 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
|
|||||||
|
|
||||||
protected PropertyChangeListener actionPropertyChangeListener;
|
protected PropertyChangeListener actionPropertyChangeListener;
|
||||||
protected boolean disableOnClick = false;
|
protected boolean disableOnClick = false;
|
||||||
|
protected boolean useResponsePending = false;
|
||||||
|
|
||||||
public DesktopButton() {
|
public DesktopButton() {
|
||||||
impl = createImplementation();
|
impl = createImplementation();
|
||||||
@ -55,7 +56,7 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getWhen() <= responseEndTs) {
|
if (useResponsePending && e.getWhen() <= responseEndTs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,4 +214,14 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
|
|||||||
public boolean isDisableOnClick() {
|
public boolean isDisableOnClick() {
|
||||||
return disableOnClick;
|
return disableOnClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUseResponsePending() {
|
||||||
|
return useResponsePending;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUseResponsePending(boolean useResponsePending) {
|
||||||
|
this.useResponsePending = useResponsePending;
|
||||||
|
}
|
||||||
}
|
}
|
@ -32,4 +32,15 @@ public interface Button extends Component, Component.HasCaption, Component.Belon
|
|||||||
* @return true if the button is disabled when clicked.
|
* @return true if the button is disabled when clicked.
|
||||||
*/
|
*/
|
||||||
boolean isDisableOnClick();
|
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);
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ import com.vaadin.client.communication.StateChangeEvent;
|
|||||||
import com.vaadin.client.ui.button.ButtonConnector;
|
import com.vaadin.client.ui.button.ButtonConnector;
|
||||||
import com.vaadin.shared.ui.Connect;
|
import com.vaadin.shared.ui.Connect;
|
||||||
|
|
||||||
@Connect(value = CubaButton.class, loadStyle = Connect.LoadStyle.EAGER)
|
@Connect(value = CubaButton.class)
|
||||||
public class CubaButtonConnector extends ButtonConnector {
|
public class CubaButtonConnector extends ButtonConnector {
|
||||||
|
|
||||||
protected boolean pendingResponse = false;
|
protected boolean pendingResponse = false;
|
||||||
|
@ -156,4 +156,12 @@ public class WebButton extends WebAbstractComponent<CubaButton> implements Butto
|
|||||||
public boolean isDisableOnClick() {
|
public boolean isDisableOnClick() {
|
||||||
return component.isDisableOnClick();
|
return component.isDisableOnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUseResponsePending() {
|
||||||
|
return component.isUseResponsePending();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseResponsePending(boolean useResponsePending) {
|
||||||
|
component.setUseResponsePending(useResponsePending);
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,5 +21,5 @@ import com.vaadin.shared.ui.button.ButtonState;
|
|||||||
|
|
||||||
public class CubaButtonState extends ButtonState {
|
public class CubaButtonState extends ButtonState {
|
||||||
|
|
||||||
public boolean useResponsePending = true;
|
public boolean useResponsePending = false;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user