cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to get the hybris backoffice current tab name in backend

sapienthybris
Explorer
0 Likes
837
Hi Team,

As you know there are various tabs for any given entity in hybris back office.

For example if yo take product ,there are various tabs such as given below.

I have a code like this below

public class DefaultGroupVariantsProductStaticMsgRenderer extends AbstractEditorAreaPanelRenderer<ProductModel> {    

private static final Logger LOG = LogManager.getLogger(DefaultGroupVariantsProductStaticMsgRenderer.class);    

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

public DefaultGroupVariantsProductStaticMsgRenderer() {    }    

public void render(Component parent, AbstractPanel abstractPanel, ProductModel model, DataType dataType, WidgetInstanceManager widgetInstanceManager) {        

if (!(model instanceof GenericVariantProductModel)) { 

           LOG.error("Product is not Variant Type");

            return;       

 }        

final GenericVariantProductModel gvpModel = (GenericVariantProductModel) model; 

       this.widgetInstanceManager = widgetInstanceManager;

        if (gvpModel.getBaseProduct().isDefaultBase() == false) {   

         Div panel = new Div();  

          Label label = new Label(Labels.getLabel(GROUP_PRODUCT_VARIANTS_STATIC_MESSAGE)); 

           label.setParent(panel);     

       parent.appendChild(panel);   

     } 

   }}

Based on the tab thats is being selected I need to set the message GROUP_PRODUCT_STATIC_MESSAGE or GROUP_PRODUCT_VARIANTS_STATIC_MESSAGE in the label accordingly.

Please advise how can i get the tab name for example in this case "VARIANTS" ?

Accepted Solutions (0)

Answers (1)

Answers (1)

pavan_joshi1
Participant
0 Likes

We usually set this renderer in config file like below:

<editorArea:customPanel spring-bean="productMsgRenderer" /><br>

You can define two different renderer instances and pass attributes for the same.
OR

You can use same renderer instance with different custom attributes passed in config and captured in above Renderer class as below :

component.getAttribute("attr");<br>
OR

I think you could be able to parse the Component tree in below method to get the tab label name. Debug will help. Please try.

public void render(Component parent, AbstractPanel abstractPanel, ProductModel model, DataType dataType, WidgetInstanceManager widgetInstanceManager)<br>

Hope you got some heads up! Thanks!