@@ -28,10 +28,10 @@ public class ComponentInStateComponent extends AbstractComponent { | |||
} | |||
public void setOtherComponent(Component component) { | |||
getState().setOtherComponent(component); | |||
getState().otherComponent = component; | |||
} | |||
public Component getOtherComponent() { | |||
return (Component) getState().getOtherComponent(); | |||
return (Component) getState().otherComponent; | |||
} | |||
} |
@@ -50,10 +50,10 @@ public class MyComponent extends AbstractComponent { | |||
} | |||
public void setText(String text) { | |||
getState().setText(text); | |||
getState().text = text; | |||
} | |||
public String getText() { | |||
return getState().getText(); | |||
return getState().text; | |||
} | |||
} |
@@ -0,0 +1,47 @@ | |||
package com.vaadin.tests.minitutorials.v7a3; | |||
import org.json.JSONArray; | |||
import org.json.JSONException; | |||
import com.vaadin.server.ExternalResource; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.ui.JavaScript; | |||
import com.vaadin.ui.JavaScriptFunction; | |||
import com.vaadin.ui.Link; | |||
import com.vaadin.ui.Notification; | |||
import com.vaadin.ui.Notification.Type; | |||
import com.vaadin.ui.UI; | |||
public class JSAPIUI extends UI { | |||
@Override | |||
public void init(VaadinRequest request) { | |||
JavaScript.getCurrent().addFunction("com.example.api.notify", | |||
new JavaScriptFunction() { | |||
@Override | |||
public void call(JSONArray arguments) throws JSONException { | |||
try { | |||
String caption = arguments.getString(0); | |||
if (arguments.length() == 1) { | |||
// only caption | |||
Notification.show(caption); | |||
} else { | |||
// type should be in [1] | |||
Notification.show(caption, | |||
Type.values()[arguments.getInt(1)]); | |||
} | |||
} catch (JSONException e) { | |||
// We'll log in the console, you might not want to | |||
JavaScript.getCurrent().execute( | |||
"console.error('" + e.getMessage() + "')"); | |||
} | |||
} | |||
}); | |||
addComponent(new Link( | |||
"Send message", | |||
new ExternalResource( | |||
"javascript:(function(){com.example.api.notify(prompt('Message'),2);})();"))); | |||
} | |||
} |
@@ -20,13 +20,5 @@ import com.vaadin.shared.ComponentState; | |||
import com.vaadin.shared.Connector; | |||
public class ComponentInStateState extends ComponentState { | |||
private Connector otherComponent; | |||
public Connector getOtherComponent() { | |||
return otherComponent; | |||
} | |||
public void setOtherComponent(Connector otherComponent) { | |||
this.otherComponent = otherComponent; | |||
} | |||
public Connector otherComponent; | |||
} |
@@ -35,7 +35,7 @@ public class ComponentInStateStateConnector extends AbstractComponentConnector { | |||
} | |||
public ComponentConnector getOtherComponent() { | |||
return (ComponentConnector) getState().getOtherComponent(); | |||
return (ComponentConnector) getState().otherComponent; | |||
} | |||
@Override |
@@ -46,7 +46,7 @@ public class MyComponentConnector extends AbstractComponentConnector { | |||
public void onStateChanged(StateChangeEvent stateChangeEvent) { | |||
super.onStateChanged(stateChangeEvent); | |||
final String text = getState().getText(); | |||
final String text = getState().text; | |||
getWidget().setText(text); | |||
} | |||
@@ -4,14 +4,6 @@ import com.vaadin.shared.ComponentState; | |||
public class MyComponentState extends ComponentState { | |||
private String text; | |||
public String getText() { | |||
return text; | |||
} | |||
public void setText(String text) { | |||
this.text = text; | |||
} | |||
public String text; | |||
} |
@@ -2,8 +2,6 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a2; | |||
import java.util.List; | |||
import com.google.gwt.core.client.GWT; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.client.ComponentConnector; | |||
import com.vaadin.client.ConnectorHierarchyChangeEvent; | |||
import com.vaadin.client.ui.AbstractComponentContainerConnector; | |||
@@ -17,7 +15,7 @@ public class WidgetContainerConnector extends | |||
@Override | |||
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { | |||
List<ComponentConnector> children = getChildComponents(); | |||
VWidgetContainer widget = (VWidgetContainer) getWidget(); | |||
VWidgetContainer widget = getWidget(); | |||
widget.clear(); | |||
for (ComponentConnector connector : children) { | |||
widget.add(connector.getWidget()); | |||
@@ -26,8 +24,8 @@ public class WidgetContainerConnector extends | |||
} | |||
@Override | |||
protected Widget createWidget() { | |||
return GWT.create(VWidgetContainer.class); | |||
public VWidgetContainer getWidget() { | |||
return (VWidgetContainer) super.getWidget(); | |||
} | |||
@Override |