Is there still a setNullRepresentation for fields?

Hi,

Im trying to extend FormFieldFactory so that i can set my TextFields to show an empty strig instead of a null value.

I thought i could do this by the following code



	protected class MBFormFieldFactory implements FormFieldFactory{
				
		/**
		 * for now we create all fields as TextFields. This needs to changed when implemented.
		 */
		public Field createField(Item item, Object propertyId, Component uiContext){
			Field f = DefaultFieldFactory.get().createField(item, propertyId, uiContext);			
			if(f instanceof TextField){
				// this doesnt work
				((TextField)f).setNullRepresentation("");
			}
			
			return f;
		}
		
	}

The setNullRepresentation function call cant be found. Im doing this in eclipse and if it exists it should be autoimported. Anyone know what im doing wrong or has this been removed from the API?

Best Regards
Marthin

Hi,

It’s
still there alright
.

Make sure that you have really imported the com.vaadin.ui.TextField and not some GWT or AWT or whatever class instead. That can easily happen with autoimports.

Eclipse can also sometimes go crazy with class paths, imports, or something. For example, the code completion can find a class just fine, and it can even be auto-imported, but the import line and all uses have an error saying that the class not there. Even if it is in the same package. In such very frustrating cases, the only thing that has helped was deleting the project from the workspace (but not from disk) and re-importing it. :wacko: (What? No (headbang) emoticon? )

But that’s very rare and you might have something different going on.

You were correct. Im not sure how, but Eclipse played a trick on me and pointed the reference to java.awt for the textbox =)

Thanks for the help!

/Marthin