I am new to the smart gwt framework. My problem is, when I am working with ItemFields, there is no way how to get text from that particlar itemField. My goal is to fill the firstName ItemField, grab the text, and send it to the service, that I implemented.

How can I get string from that ItemField? How is that, that there is no getText Method?

for example

final TextItem firstName = new TextItem("firstName", "First name");
*******************************************************************

public void onClick(ClickEvent event) {
    String name = firstName.????????;
    contactForm.greetings(name, new CallbackHandler());
}
});
有帮助吗?

解决方案

This should work for you:

getValueAsString()
  Return the value tracked by this form item.

So the code would be:

String name = firstName.getValueAsString();

其他提示

From Doc you can use following code:

String name = firstName.getEnteredValue()
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top