/**
* Gets the <code>String</code> representation of the contents of the
* Item. The format of the string is a space separated catenation of the
- * <code>String</code> representations of the Properties contained by
- * the Item.
+ * <code>String</code> representations of the values of the Properties
+ * contained by the Item.
*
* @return <code>String</code> representation of the Item contents
*/
for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) {
final Object propertyId = i.next();
- // TODO do not use Property.toString()
- retValue += getItemProperty(propertyId).toString();
+ retValue += getItemProperty(propertyId).getValue();
if (i.hasNext()) {
retValue += " ";
}
// Discards buffer by overwriting from datasource
newValue = dataSource.getValue();
- if (String.class == getType()) {
+ if (String.class == getType() && newValue != null) {
newValue = newValue.toString();
}
readThroughMode = readThrough;
if (!isModified() && readThroughMode && dataSource != null) {
Object newValue = dataSource.getValue();
- if (String.class == getType()) {
+ if (String.class == getType() && newValue != null) {
newValue = newValue.toString();
}
setInternalValue(newValue);
}
Object result = dataSource.getValue();
- if (String.class == getType()) {
+ if (String.class == getType() && result != null) {
result = result.toString();
}
return result;
try {
if (dataSource != null) {
Object newValue = dataSource.getValue();
- if (String.class == getType()) {
+ if (String.class == getType() && newValue != null) {
newValue = newValue.toString();
}
setInternalValue(newValue);
final Property p = getContainerProperty(itemId,
getItemCaptionPropertyId());
if (p != null) {
- caption = p.toString();
+ Object value = p.getValue();
+ if (value != null) {
+ caption = value.toString();
+ }
}
break;
}
}
/**
- * TODO temporary method to help eliminate the use of toString()
+ * Returns the value of the <code>Property</code> in human readable textual
+ * format.
*
- * @return
+ * This method exists to help migration from previous Vaadin versions by
+ * providing a simple replacement for {@link #toString()}. However, it is
+ * normally better to use the value of the label directly.
+ *
+ * @return String representation of the value stored in the Property
+ * @since 7.0
*/
public String getStringValue() {
if (dataSource == null) {
throw new IllegalStateException(DATASOURCE_MUST_BE_SET);
}
- // TODO do not use Property.toString()
- return dataSource.toString();
+ Object value = dataSource.getValue();
+ return (null != value) ? value.toString() : null;
}
/**
t.addListener(new Listener() {
public void componentEvent(Event event) {
status.addComponent(new Label(event.getClass().getName()));
- // TODO should not use Property.toString()
+ // TODO should not use Field.toString()
status.addComponent(new Label("selected: "
+ event.getSource().toString()));
}
t.addListener(new Listener() {
public void componentEvent(Event event) {
status.addComponent(new Label(event.getClass().getName()));
- // TODO should not use Property.toString()
+ // TODO should not use Field.toString()
status.addComponent(new Label("selected: "
+ event.getSource().toString()));
}
tf.addListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
- // TODO should not use Property.toString()
- l.log("Value change:" + event.getProperty().toString());
+ l.log("Value change:" + event.getProperty().getValue());
}
});
textField.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
- log.log("TF value now:" + event.getProperty());
+ log.log("TF value now:" + event.getProperty().getValue());
}
});
tree.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
- log.log("Tree value now:" + event.getProperty());
+ log.log("Tree value now:" + event.getProperty().getValue());
}
});
tree.setImmediate(true);
if (transferable instanceof TableTransferable) {
TableTransferable tr = (TableTransferable) transferable;
System.out.println("From table row" + tr.getPropertyId());
- // TODO should not use Property.toString()
- data = tr.getSourceContainer().getItem(tr.getItemId())
- .getItemProperty(tr.getPropertyId()).toString();
-
+ Object value = tr.getSourceContainer()
+ .getItem(tr.getItemId())
+ .getItemProperty(tr.getPropertyId()).getValue();
+ data = (null != value) ? value.toString() : null;
}
if (data == null) {
- data = "-no Text data flawor-";
+ data = "-no Text data flavor-";
}
tree3.addItem(data);
AbstractSelect.AbstractSelectTargetDetails dropTargetData = (AbstractSelect.AbstractSelectTargetDetails) dropEvent
public void drop(DragAndDropEvent event) {
/*
* We know transferrable is from table, so it is of type
- * DataBindedTransferrable
+ * DataBoundTransferrable
*/
DataBoundTransferable tr = (DataBoundTransferable) event
.getTransferable();
// if the source is from table (not from tree1 itself),
// transfer Name property and use it as an identifier in
// tree1
- // TODO should not use Property.toString()
- String name = sourceContainer.getItem(itemId)
- .getItemProperty("Name").toString();
+ Object nameValue = sourceContainer.getItem(itemId)
+ .getItemProperty("Name").getValue();
+ String name = (null != nameValue) ? nameValue.toString()
+ : null;
tree1.addItem(name);
tree1.setChildrenAllowed(name, false);
c.addComponent(tf);
tf.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
- // TODO should not use Property.toString()
main.addComponent(new Label(name + " send text:"
+ tf.getStringValue()));
}