cancel
Showing results for 
Search instead for 
Did you mean: 

How to display STATIC message in the editor area based on certain condition in hybris backoffice

sapienthybris
Explorer
0 Kudos
754

I have the below snippet and for now I have configured the custom message inside the "<editorArea:custom>"

But I need this text / message to be picked up from the property file and it need to be displayed in the editor area based on certain condition, for example if the edited product has some attribute value as true or false.How can I do that ???

<context merge-by="type" parent="GenericItem" type="Product" component="editor-area" module="pcmbackoffice"
       principal="group1,group2">
   <editorArea:editorArea  xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea">
      <editorArea:essentials>
         <editorArea:essentialSection name="hmc.essential">
            <editorArea:custom>
               <editorArea:default>THIS IS A TEST. IT HAS SUCCEEDED.</editorArea:default>
            </editorArea:custom>
            <editorArea:attribute qualifier="code"/>
            <editorArea:attribute qualifier="batchCountry"/>
            <editorArea:attribute qualifier="name"/>
            <editorArea:attribute qualifier="shortName"/>
            <editorArea:attribute qualifier="manufacturerName"/>
            <editorArea:attribute qualifier="catalogVersion"/>
            <editorArea:attribute qualifier="approvalStatus"/>
         </editorArea:essentialSection>
      </editorArea:essentials>
   </editorArea:editorArea>
</context>

Accepted Solutions (0)

Answers (1)

Answers (1)

sapienthybris
Explorer
0 Kudos

Hi khajamohiddin

Thanks a lot for your prompt response and I was able to achieve the same by following your steps.

I did the following stuff

xx-backoffice-config.xml

<context merge-by="type" parent="GenericItem" type="Product" component="editor-area" module="pcmbackoffice"principal="grp1,grp2">
<editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea">
<editorArea:essentials>
<editorArea:essentialSection name="hmc.essential">
<editorArea:customPanel name="groupProductStaticMsgRenderer" spring-bean="groupProductStaticMsgRenderer" />
<editorArea:attribute qualifier="code"/>
<editorArea:attribute qualifier="batchCountry"/>
<editorArea:attribute qualifier="name"/>
<editorArea:attribute qualifier="shortName"/>
<editorArea:attribute qualifier="manufacturerName"/>
<editorArea:attribute qualifier="catalogVersion"/>
<editorArea:attribute qualifier="approvalStatus"/>
</editorArea:essentialSection>
</editorArea:essentials>
</editorArea:editorArea>
</context>

xx-backoffice-spring.xml

<alias name="defaultGroupProductStaticMsgRenderer" alias="groupProductStaticMsgRenderer" />
<bean id="defaultGroupProductStaticMsgRenderer" class="com.xx.backoffice.renderers.GroupProductStaticMsgRenderer" parent="abstractEditorAreaComponentRenderer"/>

Java class :

public class GroupProductStaticMsgRenderer extends AbstractEditorAreaPanelRenderer<ProductModel> {
private static final Logger LOG = LogManager.getLogger(GroupProductStaticMsgRenderer.class);

public static final String GROUP_PRODUCT_STATIC_MESSAGE = "hmc.group.product.alert";
private WidgetInstanceManager widgetInstanceManager;

public GroupProductStaticMsgRenderer() {
}

public void render(Component parent, AbstractPanel abstractPanel, ProductModel model, DataType dataType, WidgetInstanceManager widgetInstanceManager) {
if (!(model instanceof ProductModel)) {
this.widgetInstanceManager = widgetInstanceManager;
final GenericVariantProductModel source = (GenericVariantProductModel) model;
if (source.getBaseProduct().isDefaultBase() == true) {
Div panel = new Div();
Label label = new Label(Labels.getLabel(GROUP_PRODUCT_STATIC_MESSAGE));
label.setParent(panel);
parent.appendChild(panel);
}
}
}

}