Sunday 9 June 2019

Read Property files in jsff and java class in ADF project

Hi

We often have the requirement of reading properties from a file placed inside the ADF application itself . We use this mainly for easy access of properties that uses in many locations across the application.


Code to read property file  in java:

  InputStream st = null;
 Properties prop = new Properties();
 st =
    Thread.currentThread().getContextClassLoader().getResourceAsStream("/com/view/read.properties);

 try {
           prop.load(st);
          String personID=prop.getProperty("Employee") ;;

 
         }catch (Exception e) {
           logErrorStackTrace(e);
            }finally{
                try{
                    if (st !=null) {
                        st .close();
                    }
               
                }catch (Exception e) {
                    logErrorStackTrace(e);
                }
            }

*Must close the st  after usage

Code to read property file  in jsff:

Declaration / import :
 
 <c:set var="propfile"

           value="#{adfBundle['com.view.read']}"/> // read is the property file name

Usage:

            <af:outputText value="#{propfile.outputtext}"
                            id="ol1"/>


Thank You!!

Never stop learning ...

No comments:

Post a Comment

Hello World in Java and Go

Hello World: Java: public class HelloWorld { public static void main (String[] args) { System.out.println( "Hello, W...

Popular Posts