on 2016 Jul 27 8:48 AM
I have two items, ItemA and ItemB and there is one to many relation between them. I have a requirement to display the attribute of ItemB in ItemA.
<itemtype code="ItemA"
jaloclass="com.xyz.core.staff.jalo.StaffInformation">
<deployment table="staffinformation" typecode="20707" />
<attributes>
<attribute type="java.lang.String" qualifier="name">
<modifiers optional="false" />
<persistence type="property" />
</attribute>
</attributes>
</itemtype>
<itemtype code="ItemB" extends="AbstractContactDetails"
jaloclass="com.xyz.core.contact.jalo.EContactInfo">
<attributes>
<attribute type="java.lang.String" qualifier="emailAddress">
<modifiers unique="true" />
<persistence type="property" />
</attribute>
</attributes>
</itemtype>
<relation code="ItemAToItemB" autocreate="true"
generate="false" localized="false">
<sourceElement qualifier="itemA" type="ItemA"
cardinality="one">
<modifiers />
</sourceElement>
<targetElement qualifier="itemB" type="ItemB"
cardinality="many">
<modifiers partof="true" />
</targetElement>
</relation>
So i need to display emailAddress in list view of ItemA
I tried accessing attribute through qualifier of targetElement i.e itemB.emailAddress and also tried giving base config for ItemB.
But it didnt worked. Please Suggest
Thanks,
Since you want to render an attribute from the target item in a relation, you do not need any custom renderer. You can do it as follows:
<context type="ItemA" component="listview">
<list:list-view xmlns:list="http://www.hybris.com/cockpitng/component/listView">
<list:column qualifier="name"/>
<list:column qualifier="itemB"/>
</list:list-view>
</context>
<context type="ItemB" component="base">
<y:base xmlns:y="http://www.hybris.com/cockpit/config/hybris">
<y:labels>
<y:label>emailAddress</y:label>
</y:labels>
</y:base>
</context>
Given below is the screenshot of what you see in backoffice:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
could you share your configuration of the List View that does not work? You can always use a custom cell renderer for a column and code it in Java.
Cheers, Wojtek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All, If you want to fetch the value from other type other than the context one then, you may have to write renderer class to fetch the value of that attribute. For instance in above code you have to write one java class which implements WidgetComponentRenderer and the spring name can be used to define that
<list:list-view xmlns:list="http://www.hybris.com/cockpitng/component/listView">
<list:column qualifier="name">
<list:column qualifier="emailAddress" spring-bean="emailAddressRenderer" label="Email Address" />
</list:list-view>
</context>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any suggestions for the above question? I am also facing the same issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.