System.out.println("* Found " + dirtyVisibleConnectors.size()
+ " dirty connectors to paint");
+ for (ClientConnector connector : dirtyVisibleConnectors) {
+ if (connector instanceof Component) {
+ ((Component) connector).updateState();
+ }
+ }
rootConnectorTracker.markAllComponentsClean();
outWriter.print("\"changes\":[");
if (null == sharedState) {
sharedState = createState();
}
+ return sharedState;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.Component#updateState()
+ */
+ public void updateState() {
// TODO This logic should be on the client side and the state should
// simply be a data object with "width" and "height".
if (getHeight() >= 0
&& (getHeightUnits() != Unit.PERCENTAGE || ComponentSizeValidator
.parentCanDefineHeight(this))) {
- sharedState.setHeight("" + getCSSHeight());
+ getState().setHeight("" + getCSSHeight());
} else {
- sharedState.setHeight("");
+ getState().setHeight("");
}
if (getWidth() >= 0
&& (getWidthUnits() != Unit.PERCENTAGE || ComponentSizeValidator
.parentCanDefineWidth(this))) {
- sharedState.setWidth("" + getCSSWidth());
+ getState().setWidth("" + getCSSWidth());
} else {
- sharedState.setWidth("");
+ getState().setWidth("");
}
- // TODO this should be in a listener called before sending state
ErrorMessage error = getErrorMessage();
if (null != error) {
- sharedState.setErrorMessage(error.getFormattedHtmlMessage());
+ getState().setErrorMessage(error.getFormattedHtmlMessage());
} else {
- sharedState.setErrorMessage(null);
+ getState().setErrorMessage(null);
}
-
- return sharedState;
}
/**
*/
private int tabIndex = 0;
- /**
- * Required field.
- */
- // TODO should be used directly from shared state, but requires a listener
- // for updating state before it is sent
- private boolean required = false;
-
/**
* The error message for the exception that is thrown when the field is
* required but empty.
* <code>false</code>.
*/
public boolean isRequired() {
- return required;
+ return getState().isRequired();
}
/**
* Is the field required.
*/
public void setRequired(boolean required) {
- this.required = required;
+ getState().setRequired(required);
requestRepaint();
}
@Override
public AbstractFieldState getState() {
- AbstractFieldState state = (AbstractFieldState) super.getState();
+ return (AbstractFieldState) super.getState();
+ }
- // TODO should be directly in state when listener for updates before
- // sending state is implemented
- state.setRequired(isRequired());
+ @Override
+ public void updateState() {
+ super.updateState();
// Hide the error indicator if needed
- // TODO these should be in a listener called before sending state
- state.setHideErrors(shouldHideErrors());
-
- return state;
+ getState().setHideErrors(shouldHideErrors());
}
@Override
*/
public ComponentState getState();
+ /**
+ * Called before the shared state is sent to the client. Gives the component
+ * an opportunity to set computed/dynamic state values e.g. state values
+ * that depend on other component features.
+ * <p>
+ * This method must not alter the component hierarchy in any way.
+ * </p>
+ *
+ * @since 7.0
+ */
+ public void updateState();
+
/* Component event framework */
/**