import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util;
import com.vaadin.client.VConsole;
+import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.client.metadata.NoDataException;
import com.vaadin.client.metadata.Type;
import com.vaadin.client.metadata.TypeData;
import com.vaadin.shared.communication.ClientRpc;
+import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.shared.communication.SharedState;
import com.vaadin.shared.communication.URLReference;
private SharedState state;
private ServerConnector parent;
+ /**
+ * A map from client-to-server RPC interface class to the RPC proxy that
+ * sends outgoing RPC calls for that interface.
+ */
+ private Map<Class<?>, ServerRpc> rpcProxyMap = new HashMap<Class<?>, ServerRpc>();
+
/**
* Temporary storage for last enabled state to be able to see if it has
* changed. Can be removed once we are able to listen specifically for
}
}
+ /**
+ * Returns an RPC proxy object which can be used to invoke the RPC method on
+ * the server.
+ *
+ * @param <T>
+ * The type of the ServerRpc interface
+ * @param rpcInterface
+ * The ServerRpc interface to retrieve a proxy object for
+ * @return A proxy object which can be used to invoke the RPC method on the
+ * server.
+ */
+ public <T extends ServerRpc> T getRpcProxy(Class<T> rpcInterface) {
+ if (!rpcProxyMap.containsKey(rpcInterface)) {
+ rpcProxyMap.put(rpcInterface, RpcProxy.create(rpcInterface, this));
+ }
+ return (T) rpcProxyMap.get(rpcInterface);
+ }
+
@Override
public <T extends ClientRpc> Collection<T> getRpcImplementations(
String rpcInterfaceId) {
import com.vaadin.client.DirectionalManagedLayout;
import com.vaadin.client.Util;
import com.vaadin.client.VCaption;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.client.ui.AbstractComponentContainerConnector;
@Override
protected LayoutClickRpc getLayoutClickRPC() {
- return rpc;
+ return getRpcProxy(AbsoluteLayoutServerRpc.class);
};
};
}
};
- private AbsoluteLayoutServerRpc rpc;
-
/*
* (non-Javadoc)
*
@Override
protected void init() {
super.init();
- rpc = RpcProxy.create(AbsoluteLayoutServerRpc.class, this);
}
/**
import com.google.gwt.user.client.DOM;
import com.vaadin.client.EventHelper;
import com.vaadin.client.MouseEventDetailsBuilder;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.client.ui.AbstractComponentConnector;
public class ButtonConnector extends AbstractComponentConnector implements
BlurHandler, FocusHandler, ClickHandler, ShortcutActionTarget {
- private ButtonServerRpc rpc = RpcProxy.create(ButtonServerRpc.class, this);
- private FocusAndBlurServerRpc focusBlurProxy = RpcProxy.create(
- FocusAndBlurServerRpc.class, this);
-
private HandlerRegistration focusHandlerRegistration = null;
private HandlerRegistration blurHandlerRegistration = null;
public void onFocus(FocusEvent event) {
// EventHelper.updateFocusHandler ensures that this is called only when
// there is a listener on server side
- focusBlurProxy.focus();
+ getRpcProxy(FocusAndBlurServerRpc.class).focus();
}
@Override
public void onBlur(BlurEvent event) {
// EventHelper.updateFocusHandler ensures that this is called only when
// there is a listener on server side
- focusBlurProxy.blur();
+ getRpcProxy(FocusAndBlurServerRpc.class).blur();
}
@Override
// generally supported.
getState().enabled = false;
super.updateEnabledState(false);
- rpc.disableOnClick();
+ getRpcProxy(ButtonServerRpc.class).disableOnClick();
}
// Add mouse details
MouseEventDetails details = MouseEventDetailsBuilder
.buildMouseEventDetails(event.getNativeEvent(), getWidget()
.getElement());
- rpc.click(details);
+ getRpcProxy(ButtonServerRpc.class).click(details);
}
import com.vaadin.client.EventHelper;
import com.vaadin.client.MouseEventDetailsBuilder;
import com.vaadin.client.VTooltip;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.Icon;
private HandlerRegistration focusHandlerRegistration;
private HandlerRegistration blurHandlerRegistration;
- private CheckBoxServerRpc rpc = RpcProxy.create(CheckBoxServerRpc.class,
- this);
- private FocusAndBlurServerRpc focusBlurRpc = RpcProxy.create(
- FocusAndBlurServerRpc.class, this);
-
@Override
public boolean delegateCaptionHandling() {
return false;
public void onFocus(FocusEvent event) {
// EventHelper.updateFocusHandler ensures that this is called only when
// there is a listener on server side
- focusBlurRpc.focus();
+ getRpcProxy(FocusAndBlurServerRpc.class).focus();
}
@Override
public void onBlur(BlurEvent event) {
// EventHelper.updateFocusHandler ensures that this is called only when
// there is a listener on server side
- focusBlurRpc.blur();
+ getRpcProxy(FocusAndBlurServerRpc.class).blur();
}
@Override
MouseEventDetails details = MouseEventDetailsBuilder
.buildMouseEventDetails(event.getNativeEvent(), getWidget()
.getElement());
- rpc.setChecked(getWidget().getValue(), details);
+ getRpcProxy(CheckBoxServerRpc.class).setChecked(getWidget().getValue(),
+ details);
}
}
import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.Util;
import com.vaadin.client.VCaption;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractLayoutConnector;
import com.vaadin.client.ui.LayoutClickEventHandler;
@Override
protected LayoutClickRpc getLayoutClickRPC() {
- return rpc;
+ return getRpcProxy(CssLayoutServerRpc.class);
};
};
- private CssLayoutServerRpc rpc;
-
private Map<ComponentConnector, VCaption> childToCaption = new HashMap<ComponentConnector, VCaption>();
/*
@Override
protected void init() {
super.init();
- rpc = RpcProxy.create(CssLayoutServerRpc.class, this);
}
/*
import com.vaadin.client.UIDL;
import com.vaadin.client.VConsole;
import com.vaadin.client.VTooltip;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.ClickEventHandler;
import com.vaadin.shared.MouseEventDetails;
public class EmbeddedConnector extends AbstractComponentConnector implements
Paintable {
- EmbeddedServerRpc rpc;
-
@Override
protected void init() {
super.init();
- rpc = RpcProxy.create(EmbeddedServerRpc.class, this);
}
@Override
@Override
protected void fireClick(NativeEvent event,
MouseEventDetails mouseDetails) {
- rpc.click(mouseDetails);
+ getRpcProxy(EmbeddedServerRpc.class).click(mouseDetails);
}
};
import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL;
import com.vaadin.client.VCaption;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentContainerConnector;
import com.vaadin.client.ui.LayoutClickEventHandler;
@Override
protected LayoutClickRpc getLayoutClickRPC() {
- return rpc;
+ return getRpcProxy(GridLayoutServerRpc.class);
};
};
- private GridLayoutServerRpc rpc;
private boolean needCaptionUpdate = false;
@Override
public void init() {
super.init();
- rpc = RpcProxy.create(GridLayoutServerRpc.class, this);
getLayoutManager().registerDependency(this,
getWidget().spacingMeasureElement);
}
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.ClickEventHandler;
@Connect(com.vaadin.ui.Image.class)
public class ImageConnector extends AbstractComponentConnector {
- ImageServerRpc rpc;
-
@Override
protected void init() {
super.init();
- rpc = RpcProxy.create(ImageServerRpc.class, this);
getWidget().addHandler(new LoadHandler() {
@Override
@Override
protected void fireClick(NativeEvent event,
MouseEventDetails mouseDetails) {
- rpc.click(mouseDetails);
+ getRpcProxy(ImageServerRpc.class).click(mouseDetails);
}
};
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.vaadin.client.EventHelper;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.Icon;
private HandlerRegistration focusHandlerRegistration;
private HandlerRegistration blurHandlerRegistration;
- private FocusAndBlurServerRpc focusBlurRpc = RpcProxy.create(
- FocusAndBlurServerRpc.class, this);
-
@Override
public void init() {
super.init();
- getWidget().buttonRpcProxy = RpcProxy.create(ButtonServerRpc.class,
- this);
+ getWidget().buttonRpcProxy = getRpcProxy(ButtonServerRpc.class);
getWidget().client = getConnection();
getWidget().paintableId = getConnectorId();
}
public void onFocus(FocusEvent event) {
// EventHelper.updateFocusHandler ensures that this is called only when
// there is a listener on server side
- focusBlurRpc.focus();
+ getRpcProxy(FocusAndBlurServerRpc.class).focus();
}
@Override
public void onBlur(BlurEvent event) {
// EventHelper.updateFocusHandler ensures that this is called only when
// there is a listener on server side
- focusBlurRpc.blur();
+ getRpcProxy(FocusAndBlurServerRpc.class).blur();
}
}
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.Util;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.client.ui.AbstractFieldConnector;
public abstract class AbstractOrderedLayoutConnector extends
AbstractLayoutConnector {
- AbstractOrderedLayoutServerRpc rpc;
-
/*
* Handlers & Listeners
*/
@Override
protected LayoutClickRpc getLayoutClickRPC() {
- return rpc;
+ return getRpcProxy(AbstractOrderedLayoutServerRpc.class);
};
};
@Override
public void init() {
super.init();
- rpc = RpcProxy.create(AbstractOrderedLayoutServerRpc.class, this);
getWidget().setLayoutManager(getLayoutManager());
}
import com.vaadin.client.LayoutManager;
import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.ui.AbstractComponentContainerConnector;
import com.vaadin.client.ui.ClickEventHandler;
import com.vaadin.client.ui.PostLayoutListener;
@Override
protected void fireClick(NativeEvent event,
MouseEventDetails mouseDetails) {
- rpc.click(mouseDetails);
+ getRpcProxy(PanelServerRpc.class).click(mouseDetails);
}
};
private Integer uidlScrollLeft;
- private PanelServerRpc rpc;
-
@Override
public void init() {
super.init();
- rpc = RpcProxy.create(PanelServerRpc.class, this);
VPanel panel = getWidget();
LayoutManager layoutManager = getLayoutManager();
package com.vaadin.client.ui.progressindicator;
import com.google.gwt.user.client.Timer;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.shared.ui.Connect;
return (ProgressIndicatorState) super.getState();
}
- ProgressIndicatorServerRpc rpc = RpcProxy.create(
- ProgressIndicatorServerRpc.class, this);
-
private Timer poller = new Timer() {
@Override
public void run() {
- rpc.poll();
+ getRpcProxy(ProgressIndicatorServerRpc.class).poll();
}
};
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.LayoutManager;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentContainerConnector;
import com.vaadin.client.ui.ClickEventHandler;
public abstract class AbstractSplitPanelConnector extends
AbstractComponentContainerConnector implements SimpleManagedLayout {
- private AbstractSplitPanelRpc rpc;
-
@Override
protected void init() {
super.init();
- rpc = RpcProxy.create(AbstractSplitPanelRpc.class, this);
// TODO Remove
getWidget().client = getConnection();
position.length() - 2));
}
- rpc.setSplitterPosition(pos);
+ getRpcProxy(AbstractSplitPanelRpc.class).setSplitterPosition(
+ pos);
}
}, SplitterMoveEvent.TYPE);
@Override
protected void fireClick(NativeEvent event,
MouseEventDetails mouseDetails) {
- rpc.splitterClick(mouseDetails);
+ getRpcProxy(AbstractSplitPanelRpc.class)
+ .splitterClick(mouseDetails);
}
};
import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL;
import com.vaadin.client.VConsole;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.client.ui.AbstractComponentContainerConnector;
public class UIConnector extends AbstractComponentContainerConnector implements
Paintable, MayScrollChildren {
- private UIServerRpc rpc = RpcProxy.create(UIServerRpc.class, this);
-
private HandlerRegistration childStateChangeHandlerRegistration;
private final StateChangeHandler childStateChangeHandler = new StateChangeHandler() {
getWidget().addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
- rpc.resize(event.getHeight(), event.getWidth(),
- Window.getClientWidth(), Window.getClientHeight());
+ getRpcProxy(UIServerRpc.class).resize(event.getHeight(),
+ event.getWidth(), Window.getClientWidth(),
+ Window.getClientHeight());
if (getState().immediate) {
getConnection().sendPendingVariableChanges();
}
@Override
protected void fireClick(NativeEvent event,
MouseEventDetails mouseDetails) {
- rpc.click(mouseDetails);
+ getRpcProxy(UIServerRpc.class).click(mouseDetails);
}
};
import com.vaadin.client.LayoutManager;
import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.ui.AbstractComponentContainerConnector;
import com.vaadin.client.ui.ClickEventHandler;
import com.vaadin.client.ui.PostLayoutListener;
@Override
protected void fireClick(NativeEvent event,
MouseEventDetails mouseDetails) {
- rpc.click(mouseDetails);
+ getRpcProxy(WindowServerRpc.class).click(mouseDetails);
}
};
- private WindowServerRpc rpc;
-
boolean minWidthChecked = false;
@Override
@Override
protected void init() {
super.init();
- rpc = RpcProxy.create(WindowServerRpc.class, this);
getLayoutManager().registerDependency(this,
getWidget().contentPanel.getElement());
import java.util.Map.Entry;
import java.util.Set;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.extensions.AbstractExtensionConnector;
import com.vaadin.shared.Connector;
@Connect(SerializerTestExtension.class)
public class SerializerTestConnector extends AbstractExtensionConnector {
- private SerializerTestRpc rpc = RpcProxy.create(SerializerTestRpc.class,
- this);
+ private SerializerTestRpc rpc = getRpcProxy(SerializerTestRpc.class);
public SerializerTestConnector() {
registerRpc(SerializerTestRpc.class, new SerializerTestRpc() {
import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util;
import com.vaadin.client.VConsole;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.extensions.AbstractExtensionConnector;
import com.vaadin.shared.ui.Connect;
import com.vaadin.tests.extensions.HelloWorldExtension;
@Connect(HelloWorldExtension.class)
public class HelloWorldExtensionConnector extends AbstractExtensionConnector {
- HelloWorldRpc rpc = RpcProxy.create(HelloWorldRpc.class, this);
@Override
public HelloWorldState getState() {
VConsole.log(msg);
String response = Window.prompt(msg, "");
- rpc.onMessageSent(response);
+ getRpcProxy(HelloWorldRpc.class).onMessageSent(response);
}
}
package com.vaadin.tests.widgetset.client.minitutorials.v7a3;
import com.google.gwt.user.client.Timer;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.extensions.AbstractExtensionConnector;
import com.vaadin.shared.ui.Connect;
@Connect(Refresher.class)
public class RefresherConnector extends AbstractExtensionConnector {
- private RefresherRpc rpc = RpcProxy.create(RefresherRpc.class, this);
-
private Timer timer = new Timer() {
@Override
public void run() {
- rpc.refresh();
+ getRpcProxy(RefresherRpc.class).refresh();
}
};
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ServerConnector;
-import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.extensions.AbstractExtensionConnector;
import com.vaadin.client.ui.VOverlay;
import com.vaadin.shared.ui.Connect;
@Connect(CapsLockWarningWithRpc.class)
public class CapsLockWarningWithRpcConnector extends AbstractExtensionConnector {
- private CapsLockWarningRpc rpc = RpcProxy.create(CapsLockWarningRpc.class,
- this);
+ private CapsLockWarningRpc rpc = getRpcProxy(CapsLockWarningRpc.class);
@Override
protected void extend(ServerConnector target) {