Change-Id: If535c5603116be204e11936f9186ce3856b74b03tags/7.5.0.rc1
@@ -48,6 +48,7 @@ import com.vaadin.client.ui.UnknownComponentConnector; | |||
import com.vaadin.shared.communication.ClientRpc; | |||
import com.vaadin.shared.communication.ServerRpc; | |||
import com.vaadin.shared.ui.Connect; | |||
import elemental.json.JsonValue; | |||
public class ConnectorBundle { | |||
@@ -579,7 +580,7 @@ public class ConnectorBundle { | |||
frameworkHandledTypes.add(Set.class); | |||
frameworkHandledTypes.add(Byte.class); | |||
frameworkHandledTypes.add(Character.class); | |||
frameworkHandledTypes.add(Void.class); | |||
} | |||
private boolean serializationHandledByFramework(JType setterType) { |
@@ -80,6 +80,8 @@ public class RendererVisitor extends TypeVisitor { | |||
JType presentationType = getPresentationType(type, logger); | |||
bundle.setPresentationType(type, presentationType); | |||
bundle.setNeedsSerialize(presentationType); | |||
logger.log(Type.DEBUG, "Presentation type of " + type + " is " | |||
+ presentationType); | |||
} |
@@ -0,0 +1,25 @@ | |||
/* | |||
* Copyright 2000-2014 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.components.grid; | |||
import com.vaadin.tests.widgetset.client.SimpleTestBean; | |||
import com.vaadin.ui.Grid.AbstractRenderer; | |||
public class BeanRenderer extends AbstractRenderer<SimpleTestBean> { | |||
public BeanRenderer() { | |||
super(SimpleTestBean.class, ""); | |||
} | |||
} |
@@ -22,6 +22,7 @@ import com.vaadin.data.util.IndexedContainer; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.tests.widgetset.TestingWidgetSet; | |||
import com.vaadin.tests.widgetset.client.SimpleTestBean; | |||
import com.vaadin.ui.Grid; | |||
import com.vaadin.ui.Grid.SelectionMode; | |||
import com.vaadin.ui.Label; | |||
@@ -31,6 +32,7 @@ public class CustomRenderer extends AbstractTestUI { | |||
private static final Object INT_ARRAY_PROPERTY = "int array"; | |||
private static final Object VOID_PROPERTY = "void"; | |||
private static final Object BEAN_PROPERTY = "pojo"; | |||
static final Object ITEM_ID = "itemId1"; | |||
static final String DEBUG_LABEL_ID = "debuglabel"; | |||
@@ -42,6 +44,8 @@ public class CustomRenderer extends AbstractTestUI { | |||
container.addContainerProperty(INT_ARRAY_PROPERTY, int[].class, | |||
new int[] {}); | |||
container.addContainerProperty(VOID_PROPERTY, Void.class, null); | |||
container.addContainerProperty(BEAN_PROPERTY, SimpleTestBean.class, | |||
null); | |||
Item item = container.addItem(ITEM_ID); | |||
@@ -50,14 +54,25 @@ public class CustomRenderer extends AbstractTestUI { | |||
.getItemProperty(INT_ARRAY_PROPERTY); | |||
propertyIntArray.setValue(new int[] { 1, 1, 2, 3, 5, 8, 13 }); | |||
@SuppressWarnings("unchecked") | |||
Property<SimpleTestBean> propertyPojo = item | |||
.getItemProperty(BEAN_PROPERTY); | |||
SimpleTestBean bean = new SimpleTestBean(); | |||
bean.setValue(42); | |||
propertyPojo.setValue(bean); | |||
Label debugLabel = new Label(INIT_DEBUG_LABEL_CAPTION); | |||
debugLabel.setId(DEBUG_LABEL_ID); | |||
Grid grid = new Grid(container); | |||
grid.getColumn(INT_ARRAY_PROPERTY).setRenderer(new IntArrayRenderer()); | |||
grid.getColumn(VOID_PROPERTY).setRenderer( | |||
new RowAwareRenderer(debugLabel)); | |||
grid.getColumn(BEAN_PROPERTY).setRenderer(new BeanRenderer()); | |||
grid.setSelectionMode(SelectionMode.NONE); | |||
addComponent(grid); | |||
addComponent(debugLabel); | |||
} |
@@ -52,6 +52,13 @@ public class CustomRendererTest extends MultiBrowserTest { | |||
findDebugLabel().getText()); | |||
} | |||
@Test | |||
public void testBeanRenderer() throws Exception { | |||
openTestURL(); | |||
assertEquals("SimpleTestBean(42)", findGrid().getCell(0, 2).getText()); | |||
} | |||
private GridElement findGrid() { | |||
List<GridElement> elements = $(GridElement.class).all(); | |||
return elements.get(0); |
@@ -27,6 +27,7 @@ public class EncodeResultDisplayTest extends SingleBrowserTest { | |||
int logRow = 0; | |||
Assert.assertEquals("Void: null", getLogRow(logRow++)); | |||
Assert.assertEquals("SimpleTestBean: {\"value\":5}", | |||
getLogRow(logRow++)); | |||
Assert.assertEquals("List: [\"Three\",\"Four\"]", getLogRow(logRow++)); |
@@ -57,6 +57,9 @@ public class EncoderResultDisplayConnector extends AbstractExtensionConnector { | |||
new Type(List.class.getName(), new Type[] { TypeData | |||
.getType(String.class) })); | |||
reportEncode(new SimpleTestBean(5)); | |||
reportEncode(Void.class.getSimpleName(), null, | |||
TypeData.getType(Void.class)); | |||
} | |||
private void reportEncode(Object value) { |
@@ -0,0 +1,39 @@ | |||
/* | |||
* Copyright 2000-2014 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.grid; | |||
import com.vaadin.client.connectors.AbstractRendererConnector; | |||
import com.vaadin.client.renderers.Renderer; | |||
import com.vaadin.client.widget.grid.RendererCellReference; | |||
import com.vaadin.shared.ui.Connect; | |||
import com.vaadin.tests.widgetset.client.SimpleTestBean; | |||
@Connect(com.vaadin.tests.components.grid.BeanRenderer.class) | |||
public class PojoRendererConnector extends | |||
AbstractRendererConnector<SimpleTestBean> { | |||
public static class BeanRenderer implements Renderer<SimpleTestBean> { | |||
@Override | |||
public void render(RendererCellReference cell, SimpleTestBean bean) { | |||
cell.getElement().setInnerText(bean.toString()); | |||
} | |||
} | |||
@Override | |||
public BeanRenderer getRenderer() { | |||
return (BeanRenderer) super.getRenderer(); | |||
} | |||
} |