cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort attributes in the unbound section of Admin tab in backoffice and hmc.

Former Member
0 Kudos
459

I need to sort the attributes which are present in the unbound section of Admin tab. They are getting rendered from unboundSectionRenderer. Is there a way to sort them or change the view in backoffice to show them vertically (similar to HMC).

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member625836
Active Contributor
0 Kudos

Hi ,

There is no such feature ootb, but you can achieve it very easily by extending default unbound section renderer:

 public class MyCustomUnboundSectionRenderer extends UnboundSectionRenderer
 {
 
         @Override
         protected Section prepareUnboundConfiguration(final WidgetInstanceManager widgetInstanceManager, final EditorArea config,
                 final DataType dataType)
         {
             final Section configuration = super.prepareUnboundConfiguration(widgetInstanceManager, config, dataType);
             final List<Attribute> attributes = configuration.getAttributeOrCustom().stream()
                     .filter(element -> element instanceof Attribute).collect(Collectors.toList());
     
             // perform some ordering on attributes
     
             configuration.getAttributeOrCustom().clear();
             configuration.getAttributeOrCustom().addAll(attributes);
     
             return configuration;
         }
 }
 

then register it as a spring bean (i.e. as myCustomUnboundSectionRenderer) and configure Editor Area properly:

 <context type="Item" component="editor-area">
     <editorArea:editorArea name="">
         <editorArea:tab name="hmc.administration" position="99">
             <editorArea:customSection name="hmc.unbound" spring-bean="myCustomUnboundSectionRenderer" merge-mode="replace"/>
         </editorArea:tab>
     </editorArea:editorArea>
 </context>

I didn't really check it, but should work like a charm.

Cheers, Jacek

Former Member
0 Kudos

Hi Jacek,

I am not able to declare the bean in the spring file. It is not recognizing UnboundSectionRenderer class as it is present in a jar (backoffice-widgets-6.2.0.2-RC1.jar) in the backoffice module.I have tried declaring the bean as bean id="trekUnboundSectionRenderer" class="com.loopintegration.trekbackoffice.editorarea.sections.TrekUnboundSectionRenderer" parent="unboundSectionRenderer" also as bean id="trekUnboundSectionRenderer" class="com.loopintegration.trekbackoffice.editorarea.sections.TrekUnboundSectionRenderer" parent="defautlUnboundSectionRenderer"

former_member625836
Active Contributor
0 Kudos

Hi,

Please paste me exact xml snippet that you use to define a bean and relative path to file it is defined in. I still believe that it should work, so it is possible that you have a mistake somewhere.

Cheers, Jacek

Former Member
0 Kudos

I have added the code in file myextension-web-spring.xml which is located in myextension/resources/web/webroot/WEB-INF and I have declared the below code snippet in it.

 <alias name="myCustomUnboundSectionRenderer" alias="unboundSectionRenderer"/>
 <bean id="myCustomUnboundSectionRenderer"
       class="com.hybris.myextension.editorarea.sections.MyCustomUnboundSectionRenderer"
       parent="defautlUnboundSectionRenderer">
 </bean>
former_member625836
Active Contributor
0 Kudos

It looks like you generated an extension with other template then ybackoffice. Please recreate the extension. Bean should be defined in extension/resources/extension-backoffice-spring.xml and source in extension/backoffice/src.

Former Member
0 Kudos

I did the following as well but now the issue lies with overriding the bean in myextension-backoffice-config.xml. I have overridden the editor area as but it is still referring to the OOTB renderer. I tried using merge-mode="replace" and merge-mode="append" with both editorarea:tab and editorarea:section. How to make sure it uses my custom renderer.