Wednesday 5 December 2018

Reading properties from local.properties file in Hybris


 *  To get the property from local.properties file and use in class.
*  Here I want to show description when  training.product.description” property is   true in local.properties otherwise I don't want to show  
*  To get the property from local.properties file and use in class.
*  Here I want to show description when  training.product.description” property is true in local.properties otherwise I don't want to show description in the storefront.
*  We can do it in two ways, Check the below example, in the storefront.

*  We can do it in two ways, Check the below example,



TrainingProductDetailsController.java

Method 1:-
Here I am using Config class to get the property. Its looks very short and simple to do it.


import de.hybris.platform.util.Config;

private static final String TRAINING_PRODUCT_DESCRIPTION = "training.product.description";

final String descriptionCheck = Config.getParameter( TRAINING_PRODUCT_DESCRIPTION);

model.addAttribute("descriptionCheck", descriptionCheck);


Method 2:-
Here I am using ConfigurationService. It looks lengthy,
  
           import de.hybris.platform.servicelayer.config.ConfigurationService;
     
          private static final String ORDERPALCED_MESSAGE = "training.product.description";

            final String descriptionCheck= configurationService.getConfiguration().getProperty(ORDERPALCED_MESSAGE);
        model.addAttribute("descriptionCheck", descriptionCheck);



local.properties


training.product.description = true




*  Here I am writing the condition to display description.

JSP:- TrainingProductDetails.jsp


<c:if test="${descriptionCheck eq true }">
<td>${productData.description}</td>
</c:if>



3 comments:

  1. "mcafee is an antivirus software providers that secure your computer for virus , worms ,trojens and other mailcious program .it provides full range of
    security product like antivirus , firewall etc .you have to do mcafee antivirus download "

    ReplyDelete
  2. "Kaspersky Free is a completely free security solution that does not show any
    third-party advertisements. Kaspersky Free also does not collect your personal data.
    We value your privacy. Kaspersky Total Security is an overall good internet security suite. to click this link kaspersky antivirus"

    ReplyDelete