There are multiple places where we can add a property in Hybris. I will be writing a different post explaining how properties work in Hybris. In this post, I will show how to read these defined properties using Java.

Let’s assume, we have the following property:

thankyou.message = Thank you {0}!

If we want to read this property and pass a value to the argument {0}, then we would use the following code:

String messageWithArgument = config.getString("thankyou.message", "Thank you {0}!");

MessageFormat.format(messageWithArgument, "John"); // we would get back the value "Thank you John!"

There are two steps in reading the property with the argument. In the first line, we are getting the full message value and storing it in the variable messageWithArgument. Then we are passing the the value “John” for the argument {0}.

Categories: Hybris

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *