To understand your problem a bit better, are you saying you’ll have the 
following?

ArrayList full of GenericDTO, each with a map of attributes? Binding the 
ArrayList of GenericDTO to the dataProvider will then use a single instance of 
GenericDTO for each row.

It almost seems as if you want rows for attributes, not for each GenericDTO?

You may have to build a new list that contains all attributes you want to 
render, or look into building/porting the AdvancedDataGrid from Flex. That 
allows sub-rows (folders) for situations like this.

As for dataFields in Royale, you have a couple of options. You generally set 
dataField to a relative path within the row’s data instance. For example,  
dataField="someValue" or dataField="someObject.someOtherObject.someValue" in 
more complex object scenarios.

As you can see, binding isn’t used for dataField.

You can also use a custom itemRender to build whatever sub-component you want 
for each cell. For example, I have Lists/DataContainer where each row can be 
another List/DataContainer, etc.

As for all other controls, yes, you can bind directly to their text/value 
fields.

FYI, maps, in my experience, or at least with the tools I’m using, turn into 
AS3 generic Objects. I’m coming from a Flex source base, being ported to 
Royale. Maps now exist, and may be usable with deserialization.

From: [email protected] <[email protected]>
Sent: Tuesday, June 15, 2021 1:20 PM
To: [email protected]
Subject: [EXTERNAL] Support for GenericDTO


Hi everyone,

From previous royale (flex) docs. I can see that it is possible to bind ui 
forms to action script objects (DTO's). i.e actionscirpt classes with public 
getter and setter methods.

The ORM we are using accepts and returns data as custom generic data transfer 
objects (GenericDTO). This generic dto is implemented as a hashMap of pojo's 
(by pojo I mean a java class with public getter and setter methods))

See the example java code snippet below:



public class GenericDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    private Map<String, Attribute> attributes = null;

    private String name = null;

    public GenericDTO(String name) {

        notNull(name, "The name of the DTO cannot be null...");

        this.attributes = new HashMap<String, Attribute>();

        this.name = name;

    }

    public GenericDTO add(String name, Attribute attribute) {

        notNull(name, "Attribute name cannot be null");

        notNull(attribute, "Attribute with name: " + name + " is null!");

        this.attributes.put(name, attribute);

        return this;

    }

........

   // there are getter/setter method to return the HashMap of Attributes and 
name field.


   The attribute class is the base class of all data types. So we have 
StringType (for String), IntegerType (for Integer) that extend Attribute.

Class Attribute

public Object getInputValue();

public void setInputValue(final Object object);


Is it possible to bind the generic dto to royale ui controls ? e.g. for example 
I was able to bind an arrayList of ContactDTO successfully. This contactDTO had 
name and email as fields with public getter and setter methods as follows

 <j:DataGrid localId="dg1" dataProvider="{contacts}">
            <j:columns>
                 <j:DataGridColumn label="Name" dataField="name" 
columnWidth="200"/>
                <j:DataGridColumn label="Email" dataField="email" 
columnWidth="200"/>
            </j:columns>
        </j:DataGrid>


Assuming it is possible to create ActionScript (as3) versions of GenericDTO, 
Attribute (with subclasses StringType, IntegerType e.t.c). Implementing the 
appropriate get and set functions.

Is it possible to bind an arrayList of GenericDTO to a royale data grid as 
follows ?

 <j:DataGrid localId="dg1" dataProvider="{records}">
            <j:columns>
                <j:DataGridColumn label="Name" 
dataField="{attributes.name.inputValue}" columnWidth="200"/>
                <j:DataGridColumn label="Email" 
dataField="{attributes.email.inputValue}" columnWidth="200"/>
            </j:columns>
        </j:DataGrid>


i.e. use databinding expressions in the dataField of the data grid ?

How about other royale UI controls ? e.g textFields and numberFields in a UI 
form.


Regards,

Roman,

Reply via email to