inited = true;
}
- fireNativeStateChange(wrapper);
+ invokeIfPresent(wrapper, "onStateChange");
}
});
}
return connectorWrapper;
}
- private static native void fireNativeStateChange(
- JavaScriptObject connectorWrapper)
- /*-{
- if (typeof connectorWrapper.onStateChange == 'function') {
- connectorWrapper.onStateChange();
- }
- }-*/;
-
private static native JavaScriptObject createConnectorWrapper(
JavaScriptConnectorHelper h, ApplicationConnection c,
JavaScriptObject nativeState, JavaScriptObject registeredRpc,
return (JavaScriptConnectorState) connector.getState();
}
+ public void onUnregister() {
+ invokeIfPresent(connectorWrapper, "onUnregister");
+ }
+
+ private static native void invokeIfPresent(
+ JavaScriptObject connectorWrapper, String functionName)
+ /*-{
+ if (typeof connectorWrapper[functionName] == 'function') {
+ connectorWrapper[functionName].apply(connectorWrapper, arguments);
+ }
+ }-*/;
+
}
public JavaScriptExtensionState getState() {
return (JavaScriptExtensionState) super.getState();
}
+
+ @Override
+ public void onUnregister() {
+ super.onUnregister();
+ helper.onUnregister();
+ }
}
public JavaScriptComponentState getState() {
return (JavaScriptComponentState) super.getState();
}
+
+ @Override
+ public void onUnregister() {
+ super.onUnregister();
+ helper.onUnregister();
+ }
}
<td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/JavaScriptWidget[0]/domChild[3]</td>
<td>1. Parent element className: v-verticallayout v-layout v-vertical v-widget v-has-width</td>
</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::PID_SRemoveButton/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::PID_SRemoveButton</td>
+ <td>Remove componentDon't mess with me</td>
+</tr>
</tbody></table>
</body>
</html>
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.AbstractJavaScriptComponent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HasComponents;
import com.vaadin.ui.JavaScriptFunction;
protected void setup(VaadinRequest request) {
addComponent(log);
- ExampleWidget c = new ExampleWidget();
+ final ExampleWidget c = new ExampleWidget();
c.setCaption("Component caption");
addComponent(c);
+
+ Button removeButton = new Button("Remove component",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ removeComponent(c);
+ }
+ });
+ removeButton.setId("RemoveButton");
+ addComponent(removeButton);
}
@Override
}
});
+ this.onUnregister = function() {
+ document.getElementById('RemoveButton').appendChild(document.createTextNode("Don't mess with me"));
+ };
+
this.messageToClient = function(message) {
this.messageToServer(message + " processed");
}