Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » How to get data out of formdata by fieldName
How to get data out of formdata by fieldName [message #1278725] Thu, 27 March 2014 15:18 Go to next message
Bertin Kiekebosch is currently offline Bertin Kiekebosch
Messages: 300
Registered: August 2011
Senior Member
Hi,

On the server I load formData. Now I have to get a particular value from this formdata but I only have the fieldname of the field I need. For example fieldname = "lastname"

If I call formdata.getFieldById(fieldname) I get an AbstractFormFieldData. Although with the debugger I can see it holds the value I need, I cannot get it.

Is there a way to get this value?

Regards Bertin
Re: How to get data out of formdata by fieldName [message #1279020 is a reply to message #1278725] Fri, 28 March 2014 02:06 Go to previous message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 657
Registered: October 2011
Senior Member
Your problem comes from the difference between AbstractFormFieldData and its subclass AbstractValueFieldData.

Here a possible snippet:

private Object getSingleValueFromFormData(AbstractFormData formData, String id) {
  AbstractFormFieldData fieldData = formData.getFieldById(id);
  if (fieldData instanceof AbstractValueFieldData) {
    return ((AbstractValueFieldData) fieldData).getValue();
  } 
  throw new IllegalArgumentException("the FormFieldData is not a ValueFieldData");
}
Previous Topic:Dynamic resizing of table columns
Next Topic:In table editing questions
Goto Forum:
  


Current Time: Thu Aug 21 12:22:03 EDT 2014

Powered by FUDForum. Page generated in 0.01644 seconds