How can I get a list of entity fields/attributes?

How can I get a list of entity fields/attributes? For example, on my entity edit form to check which fields are filled.
Thanks.

Not exactly sure what you’re trying to do. The displayed fields are presumably specified in the XML of the screen so you could inject them individually and check them. If you’re using a FieldGroup, you could inject that and iterate over the fields.


    @Inject
    protected FieldGroup datesFieldGroup

    @Named("datesFieldGroup.startDate")
    protected DateField startDateField;

If what you’re trying to accomplish is just make sure certain fields are not empty and need to be filled in, you can set the required property of the field to true and specify a requiredMessage (you can do this either in the XML or on the injected Field). That way it will automatically not accept it if not filled in.

If you’re trying to do something programmatically (not exactly sure what that would be), one way would be to inject the datasource and do a getMetaClass().getProperties() on the datasource which returns a collection of MetaProperty.

Alternately you could do a getItem() or getItems() on the datasource and do some sort of bean introspection.

Thanks Jonathan! I got property list from metaclass and attribute values by names from datasource.
I’m trying to implement a mechanizm that will allow to work with object templates where some attributes are pre-filled with some values.
I haven’t found such mechanizm in Cuba platform.