If we are developing an Fusion Web application and we are thinking about Multilingual application , then the best option i came to know is to use Resource Bundle properties of ADF . When we use resource bundle we have to use labels of Fields and Validation message or any kind of other custom message from a XML file as Resource.xml.
So first you should know that how to configure resource bundle in an ADF Application and there are plenty of posts about configuring Properties or List ResourceBundle.
In this post i will show you that how to pass parameter in XML or how to use Parametrized resource .
Suppose i have a xml file for ResourceBundle reference Resource.xml--
and now i use it in managed bean to show a custom message and replace its parameters %s with any desired value then we code like this
Now run your code and see the updated message- Only %s %s %s %s%s allowed is now
So first you should know that how to configure resource bundle in an ADF Application and there are plenty of posts about configuring Properties or List ResourceBundle.
In this post i will show you that how to pass parameter in XML or how to use Parametrized resource .
Suppose i have a xml file for ResourceBundle reference Resource.xml--
- <?xml version="1.0" encoding="windows-1252" ?>
- <bundle>
- <label>
- <key>MessageCheck</key>
- <value>Only %s %s %s %s %s allowed</value>
- </label>
- </bundle>
and now i use it in managed bean to show a custom message and replace its parameters %s with any desired value then we code like this
- //To get String from XML key, resolvElDC is a method to resolve expression language
- //here replace parameter(%s) in string message with your values
- //Show FacesMessage
- FacesMessage msg = new FacesMessage(saveMsg);
- msg.setSeverity(FacesMessage.SEVERITY_INFO);
- FacesContext ctx = FacesContext.getCurrentInstance();
- ctx.addMessage(null, msg);
- // Code for resolvElDC method
- FacesContext fc = FacesContext.getCurrentInstance();
- Application app = fc.getApplication();
- ExpressionFactory elFactory = app.getExpressionFactory();
- ELContext elContext = fc.getELContext();
- return valueExp.getValue(elContext);
- }
Now run your code and see the updated message- Only %s %s %s %s%s allowed is now
No comments :
Post a Comment