FormItem.setValue(new Object()) supported?

Hi,
using latest v 3.0,
I need to set a List of Pojo Java Objects to a formItem and get it back later.

code looks like:

class Selection(){
String name;
String type;
…
}

Selection selections = new Selections …
new TextItem(“test”).setValue(selections);

((Selection)test.getValue();

This is even not possible with one Selection Object.

API says, that type java.lang.Object is supported, is this correct?

I also tried to pass JSONString, but doesn’t work.
Will JavaScriptObject work?

How would you suggest to achieve this?

Thanks,

FormItems are fundamentally designed as editors for simple atomic values such as Strings, Booleans, Dates, etc.

If you want to assign a more complex object value to a form item, this could be achieved using custom formatters and parsers. Ultimately the value will need to be converted to JavaScript when the app is running in the browser. This is handled automatically for some Java objects, but you couldn’t pass in a completely arbitrary data type and have it be understood.

Before we discuss this further though - what is your use case here? There may be a better way to get to where you want to go!

Regards
Isomorphic Software

Hello,

thanks for quick response.

I am going to try this AutoBean and OverlayType mechanism of GWT to pass json objects as strings.

My use case is the following:
A complex custom textitem, which will open a window to choose an object, when you click on its icon is in place.

If user clicks on another selectitem, the object has to be taken and depending on the type, the value has to be taken as criteria to use for an optiondatasource fetch.

Depending, on the type of the textitem selection and if there was a user selection on the selectitem, validation will take place and the value from textitem or selectitem will be taken, depending on the type for add operation

Sorry, we really don’t understand the purpose of this. If you need help, please explain in terms of user-level goals and we can suggest a best approach.

Is not a user experience, but a technical one.

If user clicks on a FormItem, a Window pops up,
where the user can select multiple instances, which have multiple values .

These values should be stored like a List of Map/Pojo,
so that other components can access its value of the FormItem.

That use case does not seem to imply use of GWT overlay types. We’re not sure now what problem you’ve run into trying to implement this use case, but you can look at the CanvasItem examples to see FormItems storing Objects and Arrays of Objects as their value.

Hi,

Task to do:
As you said, currently, we are using a simple TextItem, which has to story a List of Map, which is no good solution.
Solutions 1 to 3:

For this we deserialize/serialize json objects on client<->Server.

This we want to abadom. So we switched to a CanvasItem and called storeValue(new RecordList).
On Client it looks fine,
but when getting the value on the server ( it’s a customSQL value field),
a string is returned, but no List of Map.

Another possible solution:
We tried calling performCustomOperation and passed the values as Record, which will be a list of map on the server, too.

The question:
The nicest would be solution 2, so would you expect it to be a string in the value on the server? - Is there a nice helper function to convert string [{“key” : “value”}], so String to RecordList available?

Thanks,

We’re assuming that you’re using a DataSource here, and calling methods like “saveValue()” on the form to save the modified value.
If so - it sounds like you need to

  • define a dataSource for the list of records to be applied to the field
  • define a dataSource for the form as a whole
  • for the field in question set “multiple” to true and set the “type” to the first dataSource.

This means that the field in question will be expected to contain an array of records and if you have a custom CanvasItem on your form for that field which ultimately uses ‘storeValue’ to store out a list of Records they should be correctly serialized when sent to the server and therefore available in your back-end code.
This is a similar pattern to the “master-detail” example in the showcase, though of course without your custom editor, etc.

If you still can’t get it working, it’d probably be worth putting together a simple test case demonstrating what you have so far, and describing exactly where the problems are.

Regards
Isomorphic Software