Page 1 of 1

How to Bring Child Object's Property to Selection ListView?

Posted: Mon Apr 14, 2014 3:44 am
by pokemon007
I have a Deal object that contains a list of DealProduct objects. DealProduct contains a Deal and a Product object. The UI should allow users to select product from product list.

Code: Select all

    @ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}, targetEntity = Product.class)
    @JoinColumn(name = "PRODUCT_ID")
    @AdminPresentation(friendlyName = "DealProduct_Product", order = 2, prominent = true, gridOrder = 2)
    @AdminPresentationToOneLookup(customCriteria = SELECT_PRODUCT)
    protected Product product;


The products in the list view (grid view) does not contain any defaultSku properties such as name. What do I need to do to bring default sku's properties to selection list view?

Note: I've extended AdminBasicOperationsController's showSelectCollectionItem to handle customCriteria so the list can be filtered based on the customCriteria. Should I do something in this method to bring defaultSku to the view?

Thank you in advance!

-Charlie

Re: How to Bring Child Object's Property to Selection ListView?

Posted: Tue Apr 22, 2014 11:45 am
by phillipuniverse
You'll need to annotate DealProduct with @AdminPresentationClass(populateToOneFields = PopulateToOneFieldsEnum.TRUE), as well as add an override to not exclude the defaultSku.name:

Code: Select all

@AdminPresentationMergeOverrides({
    @AdminPresentationMergeOverride(name = "defaultSku.name", mergeEntries =
        @AdminPresentationMergeEntry(propertyType = PropertyType.AdminPresentation.EXCLUDED, booleanOverrideValue = false))
})


Marking the product property with @AdminPresentationToOneLookup will exclude any fields attached to it, including defaultSku.name. The override will switch that field specifically back to non-excluded, while keeping all of the other fields in their excluded state.

Re: How to Bring Child Object's Property to Selection ListView?

Posted: Wed May 14, 2014 3:10 am
by pokemon007
This doesn't work. It does include sku name in DealProduct list view (grid view) of Deal form, but it's shown on Add DealProduct form which is not desired. Add DealProduct form should only show Product with "Look up" button that brings up product list to select to the deal. The worst part is that the grid view of product list the Product "Look up" button brings up is not affected, that is, it doesn't include any sku property. Still only includes default category, url and manufacturer. This last one is the only thing I want to include sku name.

Anyway we can control the grid view of the item list that "Look up" button brings up?

Thanks.

-Charlie