on ‎2018 May 21 9:21 AM
Hi,
My requirement is to sort the enum values in backoffice. I have one attribute in product model that type is enum type, for this field need to show sorting enum in drop down list.
I tried to extended "DefaultEnumEditor" and overrided getAllValues(.. , ..) method and i have written sorting logic here. but how to override this class ?
Request clarification before answering.
Hi,
You can try to create your own 'com.hybris.cockpitng.editor.defaultenum.EnumValueResolver' which will override the default one (de.hybris.platform.platformbackoffice.editors.yenum.PlatformEnumValueResolver) and it would sort values before returning them. Another option is creating your own editor which would extend: com.hybris.cockpitng.editor.defaultenum.DefaultEnumEditor Thanks to this you would have the full control over values, order etc. After creating your own editor don't forget about using it in cockpit-config.xml (for example: ) I would suggest to get familiarize with this document: https://help.hybris.com/6.4.0/hcd/8bd4c25286691014b3f9876ca5816926.html#loio8bd4c25286691014b3f9876c... There is clear description how to create your own editor and how to use it
Regards,
Lukasz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for reply. Yes, I have followed 2nd approach and created com.hybris.cockpitng.editor.defaultenum.DefaultEnumEditor extended this class and override this method "getAllValues(final String valueType, final Object initialValue)" and implemented sorting logic here. this is defination.xml
my custom class: public class SortEnumImpl extends DefaultEnumEditor{ } but here not calling override class. Am I missing configuration here? Kindly help me here.
Thanks,
thanks a lot. its working. Here the sorting should be apply sorting all the enum. I have created definition.xml and configured id in "MapPropertyExtender"
definition.xml :
<editor-definition id="org.training.sortenum"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/editor-definition.xsd">
<type>java.lang.Enum(?:\((.*)\))?</type>
<editorClassName>org.training.sortenum.SortEnumImpl</editorClassName>
</editor-definition>
I configure the enum Id :
<bean class="com.hybris.cockpitng.core.util.impl.MapPropertyExtender"
lazy-init="false" init-method="extend" destroy-method="clean">
<property name="additionalProperties">
<map merge="true" key-type="java.lang.String" value-type="java.lang.String">
<entry key="java.lang.Enum(?:\((.*)\))?" value="org.training.sortenum"/>
</map>
</property>
</bean>
Somehow I feel, this should be OOTB handled. There should be a better way to sort the content. Overwriting editor to just do sort on the labels is too much.
Anyways it works though.
We had a similar case and wanted to disable alphabetic ordering, but rely on the implicit 'sequenceNumber' of the enum values (can be set via backoffice or impex via type EnumerationValue).
We disabled alphabetic auto-sorting and then the sequenceNumber sorting comes into effect:
either per enum:
<editorArea:editor-parameter>
<editorArea:name>autoSort</editorArea:name>
<editorArea:value>false</editorArea:value>
</editorArea:editor-parameter>or globally:
backoffice.cockpitng.defaultenumeditor.autosort=false
see https://help.sap.com/viewer/9b5366ff6eb34df5be29881ff55f97d2/v2105/en-US/8bab4178866910148f93f93b584... for details
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 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.