Search code examples
javaxmlsap-commerce-cloud

How show a field of an entity into another entity


I have an issues with SAP Hybris backoffice-config.xml, I have create new entity with name LockerOpenEvent that have four attribute, I add a list view, advanced search and editor area, now my problem is the editor area. The problem is that a two field of another entity (Locker) not show into editor area, but the same field are visible into list view, what is the problem? I post the error into log and a tag of code of interest:

Error log when open the new entity(but into list view the two column appear):

 WARN  [hybrisHTTP25] [DataType] Qualifier [Locker] not found. Case insenitive resolution have found matching qualifier [locker]

Error log that make a problem of visualization when open editor area:

ERROR [hybrisHTTP36] [DefaultEditorAreaSectionRenderer] Property Locker.code was not found for type LockerOpenEvent

MyExtension of backoffice-config.xml

<context type="LockerOpenEvent">
    <context merge-by="type" component="listview" >
        <list-view:list-view
                xmlns:list-view="http://www.hybris.com/cockpitng/component/listView"
                refresh-after-object-creation="true">
            <list-view:column qualifier="Locker.code" width="200px" />
            <list-view:column qualifier="Locker.name" width="200px" />
            <list-view:column qualifier="timestamp" width="200px" />
            <list-view:column qualifier="user" width="200px" />
            <list-view:column qualifier="drawerCode" width="200px"  />
        </list-view:list-view>
    </context>

<context merge-by="type"  component="editor-area" parent="GenericItem">
        <editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea">
            <editorArea:tab name="hmc.tab.general" >
                <editorArea:section name="" >
                    <editorArea:attribute qualifier="user"/>
                    <editorArea:attribute qualifier="Locker.code"   />
                    <editorArea:attribute qualifier="Locker.name"  />
                    <editorArea:attribute qualifier="drawerCode" />
                    <editorArea:attribute qualifier="lockerDrawerOpeningEnum" editor="com.hybris.cockpitng.editor.nonoptionalenum" />
                </editorArea:section>
            </editorArea:tab>
        </editorArea:editorArea>
    </context>
</context>

Thanks a lot.


Solution

  • The warning you receive on the list view part is because the property is lower cased. Commerce does a fallback search on the lower case version, hence why you get a result in the list page. To get rid of this warning, you need to write the attributes with lowercase.

    <list-view:column qualifier="locker.code" width="200px" />
    <list-view:column qualifier="locker.name" width="200px" />
    

    For the editor area, it's a different story. Commerce does not support nesting out of the box. You need to add

    <editorArea:attribute qualifier="locker" />
    

    instead of Locker.code and Locker.name In the backoffice this will show you the locker object. A user can then navigate to the locker object and perform his changes there. (also the type is missing in your editor area config, not sure if that's on purpose)

    If you really want to show/edit the attribute on your LockerOpenEvent, you will need to create a dynamic attribute, and write the code so that the getter and setter manipulate the linked Locker object