Wednesday, June 22, 2011

My ADF Presentation

Tuesday, June 21, 2011

Refresh Resource Bundle


  • Resource bundle can not be refreshed using ResourceBundle class. using following code do not clear the cache.
Class type = ResourceBundle.class;
Field cacheList = type.getDeclaredField("cacheList");
cacheList.setAccessible(true);
((Map)cacheList.get(ResourceBundle.class)).clear();
  • If you want to refresh resource bundle of your application you should need to use Resource bundle manager instead of Resource bundle class.
ResourceBundleManagerRT rt = (ResourceBundleManagerRT)ResourceBundleManagerRT.getResourceBundleManager();
 rt.flush();

Monday, June 20, 2011

Use external XML file for Resource Bundle


  • Create list resource bundle file for default and supported locale. And read label value from xml file.
  • This approach gives a facility to change label or message value, without compilation and redeployment of application.
  • To do this first crate a xml file containing key and value pair, so that you can use label according to their key.


 
 
 

  • This method also give an option to use single file for different application, which are used as a library.
  • Here you can write code to read xml file and assign key value pair to an object of resource bundle class.
public class MyResources extends ListResourceBundle {

    public MyResources() {
        super();
    }
  
  private static final Object[][] contents =
    { { "", "" }, { "", "" }, { "", "" } };

    protected Object[][] getContents() {
        try {
            File file = new File("C:\\Users\\admin\\Desktop\\locale\\Resource.xml");
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(file);
            doc.getDocumentElement().normalize();
            NodeList nList = doc.getElementsByTagName("label");

            for (int temp = 0; temp < nList.getLength(); temp++) {

                Node nNode = nList.item(temp);
                if (nNode.getNodeType() == Node.ELEMENT_NODE) {

                    Element eElement = (Element)nNode;

                    contents[temp][0] = getTagValue("key", eElement);
                    contents[temp][1] = getTagValue("value", eElement);

                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return contents;
    }

    private static String getTagValue(String sTag, Element eElement) {
        NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes();
        Node nValue = (Node)nlList.item(0);

        return nValue.getNodeValue();
    }

}

Friday, June 10, 2011

Jdeveloper 11g release 2 , with lots of new features


Oracle released a new version of Jdeveloper 11g, containing lots off new features and even rapid development of application. These new features take jdeveloper to another level and now can be compared with other J2EE IDE such as java bean and eclipse.


Main features of new jdeveloper are:

  • Hot deployment: There is no need now to run application after any change in application files. Now just save the changed file and refresh the page.
  • Skin Editor: This new editor for skin is very use full to create css for application. It made it easy to select different properties of a component and change their attributes.

You can also get installation guides for this new release and for new skin editor in this link : http://www.oracle.com/technetwork/developer-tools/jdev/documentation/index.html

Check for the related documents: http://download.oracle.com/docs/cd/E16162_01/index.htm

Wednesday, June 1, 2011

Call Jasper report using a link

In previous post jasper report is called with the help of java bean. Now we can use a link to call report as in previous method calling report from a .jsff page gives error.

To call report using link follow following steps: 

  • Add a go link to page which will call servlet and also pass parameters.
  • Add a command button to assign value to parameters.
  • Add value in destination like “/jasperservlet?deptno=#{bindings.DepartmentId1.inputValue}&reporttype=#{bindings.Filetype1.inputValue}”.
  • Here deptno and reporttype are parameters passed from url and will be used in servlet.
  • To get parameter value in servlet use following code.
Integer code = Integer.valueOf(request.getParameter("deptno"));
String reporttype = request.getParameter("reporttype");