Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label Resource Bundle. Show all posts
Showing posts with label Resource Bundle. Show all posts

Sunday 5 February 2017

Change live application language/resource in Oracle ADF, Change XML Resource file at runtime


Hello All

I have posted about using external XML file as List resource bundle earlier , the aim of resource file is to read application static text from some source so that we can change that without compiling and redeploying application

Next requirement is to change application language , sometimes we need support multiple langauge in ADF application and it requires change in all static text so for this I am going to use separate XML resource file for different language and in this post I'll show that how to update resource file in a live running application

Monday 23 January 2017

Using external XML file as list resource bundle in ADF Application


Hello All

In this post I am talking about using external XML file as list resource bundle in ADF Application

Using this approach we need not to hard code component's label and messages , all labels and messages will be read from XML file and no need to open application to change any resource , In short we can update resources without compiling and redeploying application

Wednesday 31 October 2012

Passing parameter in XML Resource and Use it in Managed Bean, Using parameterised Resource Bundle in ADF

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--

  1. <?xml version="1.0" encoding="windows-1252" ?>
  2. <bundle>
  3. <label>
  4.     <key>MessageCheck</key>
  5.     <value>Only %s %s %s %s %s allowed</value>
  6.  </label>
  7. </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




  1. //To get String from XML key, resolvElDC is a method to resolve expression language
  2. String message = resolvElDC("#{bundle['MessageCheck']}").toString();
  3. //here replace parameter(%s) in string message with your values
  4. String saveMsg = message.format(message, ",", "/", "@", "_", "%");
  5. //Show FacesMessage
  6. FacesMessage msg = new FacesMessage(saveMsg);
  7. msg.setSeverity(FacesMessage.SEVERITY_INFO);
  8. FacesContext ctx = FacesContext.getCurrentInstance();
  9. ctx.addMessage(null, msg);
  10. // Code for resolvElDC method
  11. public Object resolvElDC(String data) {
  12.     FacesContext fc = FacesContext.getCurrentInstance();
  13.     Application app = fc.getApplication();
  14.     ExpressionFactory elFactory = app.getExpressionFactory();
  15.     ELContext elContext = fc.getELContext();
  16.     ValueExpression valueExp = elFactory.createValueExpression(elContext, data, Object.class);
  17.     return valueExp.getValue(elContext);
  18. }

Now run your code and see the updated message- Only %s %s %s %s%s allowed is now
 
FacesMessage Oracle ADF