/**
* @deprecated As of 7.1. See #11411.
*/
@Deprecated
public static JsonObject encodeState(ClientConnector connector, SharedState state) {
UI uI = connector.getUI();
ConnectorTracker connectorTracker = uI.getConnectorTracker();
Class<? extends SharedState> stateType = connector.getStateType();
JsonValue diffState = connectorTracker.getDiffState(connector);
boolean supportsDiffState = !JavaScriptConnectorState.class
.isAssignableFrom(stateType);
if (diffState == null && supportsDiffState) {
// Use an empty state object as reference for full
// repaints
try {
SharedState referenceState = stateType.newInstance();
EncodeResult encodeResult = JsonCodec.encode(referenceState,
null, stateType, uI.getConnectorTracker());
diffState = encodeResult.getEncodedValue();
} catch (Exception e) {
getLogger()
.log(Level.WARNING,
"Error creating reference object for state of type {0}",
stateType.getName());
}
}
EncodeResult encodeResult = JsonCodec.encode(state, diffState,
stateType, uI.getConnectorTracker());
if (supportsDiffState) {
connectorTracker.setDiffState(connector,
(JsonObject) encodeResult.getEncodedValue());
}
return (JsonObject) encodeResult.getDiff();