private final Type type;
private final String name;
- private String signature;
public Method(Type type, String name) {
this.type = type;
this.name = name;
- // Cache derived signature value
- signature = type.getSignature() + "." + name;
}
public Type getType() {
* @return the unique signature of this method
*/
public String getSignature() {
- return signature;
+ return type.getSignature() + "." + name;
+ }
+
+ /**
+ * Gets the string that is internally used when looking up generated support
+ * code for this method. This is the same as {@link #getSignature()}, but
+ * without any type parameters.
+ *
+ * @return the string to use for looking up generated support code
+ *
+ * @since 7.2
+ */
+ public String getLookupKey() {
+ return type.getBaseTypeName() + "." + name;
}
@Override
public class Property {
private final Type bean;
private final String name;
- private final String signature;
public Property(Type bean, String name) {
this.bean = bean;
this.name = name;
- // Cache derived signature value
- signature = bean.getSignature() + "." + name;
}
public Object getValue(Object bean) throws NoDataException {
* @return the unique signature of this property
*/
public String getSignature() {
- return signature;
+ return bean.getSignature() + "." + name;
+ }
+
+ /**
+ * Gets the string that is internally used when looking up generated support
+ * code for this method. This is the same as {@link #getSignature()}, but
+ * without any type parameters.
+ *
+ * @return the string to use for looking up generated support code
+ *
+ * @since 7.2
+ */
+ public String getLookupKey() {
+ return bean.getBaseTypeName() + "." + name;
}
@Override
}
public static Type getReturnType(Method method) throws NoDataException {
- Type type = get().returnTypes.get(method.getSignature());
+ Type type = get().returnTypes.get(method.getLookupKey());
if (type == null) {
throw new NoDataException("There is no return type for "
+ method.getSignature());
}
public static Invoker getInvoker(Method method) throws NoDataException {
- Invoker invoker = get().invokers.get(method.getSignature());
+ Invoker invoker = get().invokers.get(method.getLookupKey());
if (invoker == null) {
throw new NoDataException("There is no invoker for "
+ method.getSignature());
public static Invoker getConstructor(Type type) throws NoDataException {
Invoker invoker = get().invokers.get(new Method(type, CONSTRUCTOR_NAME)
- .getSignature());
+ .getLookupKey());
if (invoker == null) {
throw new NoDataException("There is no constructor for "
+ type.getSignature());
}
public static String getDelegateToWidget(Property property) {
- return get().delegateToWidget.get(property.getSignature());
+ return get().delegateToWidget.get(property.getLookupKey());
}
public static JsArrayString getDelegateToWidgetProperites(Type type) {
- return get().delegateToWidgetProperties.get(type.getSignature());
+ return get().delegateToWidgetProperties.get(type.getBaseTypeName());
}
public void setDelegateToWidget(Class<?> clazz, String propertyName,
String delegateValue) {
Type type = getType(clazz);
- delegateToWidget.put(new Property(type, propertyName).getSignature(),
+ delegateToWidget.put(new Property(type, propertyName).getLookupKey(),
delegateValue);
JsArrayString typeProperties = delegateToWidgetProperties.get(type
- .getSignature());
+ .getBaseTypeName());
if (typeProperties == null) {
typeProperties = JavaScriptObject.createArray().cast();
- delegateToWidgetProperties.put(type.getSignature(), typeProperties);
+ delegateToWidgetProperties.put(type.getBaseTypeName(),
+ typeProperties);
}
typeProperties.push(propertyName);
}
public void setReturnType(Class<?> type, String methodName, Type returnType) {
- returnTypes.put(new Method(getType(type), methodName).getSignature(),
+ returnTypes.put(new Method(getType(type), methodName).getLookupKey(),
returnType);
}
}
public void setInvoker(Class<?> type, String methodName, Invoker invoker) {
- invokers.put(new Method(getType(type), methodName).getSignature(),
+ invokers.put(new Method(getType(type), methodName).getLookupKey(),
invoker);
}
public static Type[] getParamTypes(Method method) throws NoDataException {
- Type[] types = get().paramTypes.get(method.getSignature());
+ Type[] types = get().paramTypes.get(method.getLookupKey());
if (types == null) {
throw new NoDataException("There are no parameter type data for "
+ method.getSignature());
public void setParamTypes(Class<?> type, String methodName,
Type[] paramTypes) {
this.paramTypes.put(
- new Method(getType(type), methodName).getSignature(),
+ new Method(getType(type), methodName).getLookupKey(),
paramTypes);
}
public static ProxyHandler getProxyHandler(Type type)
throws NoDataException {
- ProxyHandler proxyHandler = get().proxyHandlers
- .get(type.getSignature());
+ ProxyHandler proxyHandler = get().proxyHandlers.get(type
+ .getBaseTypeName());
if (proxyHandler == null) {
throw new NoDataException("No proxy handler for "
+ type.getSignature());
}
public void setProxyHandler(Class<?> type, ProxyHandler proxyHandler) {
- proxyHandlers.put(getType(type).getSignature(), proxyHandler);
+ proxyHandlers.put(getType(type).getBaseTypeName(), proxyHandler);
}
public static boolean isDelayed(Method method) {
- return get().delayedMethods.contains(method.getSignature());
+ return get().delayedMethods.contains(method.getLookupKey());
}
public void setDelayed(Class<?> type, String methodName) {
- delayedMethods.add(getType(type).getMethod(methodName).getSignature());
+ delayedMethods.add(getType(type).getMethod(methodName).getLookupKey());
}
public static boolean isLastOnly(Method method) {
- return get().lastOnlyMethods.contains(method.getSignature());
+ return get().lastOnlyMethods.contains(method.getLookupKey());
}
public void setLastOnly(Class<?> clazz, String methodName) {
lastOnlyMethods
- .add(getType(clazz).getMethod(methodName).getSignature());
+ .add(getType(clazz).getMethod(methodName).getLookupKey());
}
/**
}
public void setSerializerFactory(Class<?> clazz, Invoker factory) {
- serializerFactories.put(getType(clazz).getSignature(), factory);
+ serializerFactories.put(getType(clazz).getBaseTypeName(), factory);
}
public static JSONSerializer<?> findSerializer(Type type) {
Invoker factoryCreator = get().serializerFactories.get(type
- .getSignature());
+ .getBaseTypeName());
if (factoryCreator == null) {
return null;
}
--- /dev/null
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.serialization;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.tests.widgetset.server.GenericWidgetComponent;
+
+@Widgetset(TestingWidgetSet.NAME)
+public class GenericWidgetHandling extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final GenericWidgetComponent component = new GenericWidgetComponent();
+ component.setId("label");
+ component.setGenericText("The generic text is strong in this one");
+ addComponent(component);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Tests that a connector works even if its widget is of a generic type";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // Also 12900 if someone happens to care
+ return Integer.valueOf(12873);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.serialization;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class GenericWidgetHandlingTest extends MultiBrowserTest {
+
+ @Test
+ public void testWidgetInit() {
+ openTestURL();
+ WebElement label = vaadinElementById("label");
+
+ Assert.assertEquals("The generic text is strong in this one",
+ label.getText());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.widgetset.client;
+
+import com.google.gwt.user.client.ui.Label;
+
+public class GenericWidget<T> extends Label {
+ public void setGenericText(T value) {
+ setText(String.valueOf(value));
+ }
+}
--- /dev/null
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.widgetset.client;
+
+import com.vaadin.client.ui.AbstractComponentConnector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.tests.widgetset.server.GenericWidgetComponent;
+
+@Connect(GenericWidgetComponent.class)
+public class GenericWidgetConnector extends AbstractComponentConnector {
+ @Override
+ public GenericWidget<String> getWidget() {
+ return (GenericWidget<String>) super.getWidget();
+ }
+
+ @Override
+ public GenericWidgetState getState() {
+ return (GenericWidgetState) super.getState();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.widgetset.client;
+
+import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.shared.annotations.DelegateToWidget;
+
+public class GenericWidgetState extends AbstractComponentState {
+ @DelegateToWidget
+ public String genericText;
+}
--- /dev/null
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.widgetset.server;
+
+import com.vaadin.tests.widgetset.client.GenericWidgetState;
+import com.vaadin.ui.AbstractComponent;
+
+public class GenericWidgetComponent extends AbstractComponent {
+
+ @Override
+ protected GenericWidgetState getState() {
+ return (GenericWidgetState) super.getState();
+ }
+
+ public void setGenericText(String genericText) {
+ getState().genericText = genericText;
+ }
+}