Answered: ValueProvider+RequestFactory - how to access properties of nested object?

Hi everybody,

i'm trying to figure out how to display properties from related object in a grid.
Let's say I have entity object called "Song",that is relating to "Genre" object.

Now,what I want to achieve is to display list of "Song" objects on grid,but also include some of the details from related "Genre" object.
From what I read on GXT 3.0, valueProviders should be able to do that, but I haven't found out how to do it.

the "@Path" annotation is what you are looking for:
From the GWT docs:

"The @Path annotation may be used on the field or accessor method to specify a dotted property path or to bypass the implicit naming convention. For example:
class PersonEditor implements Editor<Person> {
// Corresponds to person.getManager().getName()
@Path("manager.name");
Label managerName;
}

I am having a very similar issue. I am using RequestFactory with Hibernate to populate a Sencha grid with a paging toolbar. By using the path annotation I was able to successfully populate the grid with data. I then tried to implement the paging toolbar which requires the use of RequestFactoryProxy and am now receiving a NullPointerException for the Columns in the grid that access nested objects. It seems that the use of the with() method within the context of RequestFactoryProxy doesn't work as expected.

In this case, we'll be able to use that ValueProvider to get and set the city of the address of the person as if we were writing these lines of code:

Code:

person.getAddress().getCity()
person.getAddress().setCity(...)

But what happens if the address is null? It can't magically know that you don't want that to be null, that you intend for it to have a non-null value, and it can't create a new Address object for you - in that case, what should getCity do? Even if we rebuild that (and this doesn't make sense to me) to return null, what can setCity do when the user types in a value, for example, in a grid?

There is no way for us to create those sub-objects in a consistent way - what if you need a StreetAddress subclass of the abstract Address class? What if Address is a RequestFactory proxy, and thus only an interface? What if you must use a non-default constructor to build Address? Any of these make it hard to generate code that builds your sub-objects for you.

If you want custom behavior in your ValueProvider, built a custom implementation of the interface. PropertyAccess is only for simple generated default behavior.