Monday, March 30, 2015

Create and Insert Rows Programmatically in AMImpl ADF

 // This is the method in AMImpl

    public void addUser(BigDecimal userRefId,String exCode){
        String query="SELECT  userUtils.getUserID("+userRefId+") from dual";
        System.out.println("This is the USER_ID query"+query);
        BigDecimal userId=executeQuery(query);

        ADFContext adfCtx = ADFContext.getCurrent();
        Map sessionScope = adfCtx.getSessionScope();
        BigDecimal createdBy= new BigDecimal(sessionScope.get("UserId").toString());

        java.sql.Timestamp datetime = new java.sql.Timestamp(System.currentTimeMillis());
       

          AdminWBVOImpl adminWBVO = this.getAdminWBVO();
//create Row
        AdminWBVOImpl adminRow=(AdminWBVOImpl)adminWBVO .createRow();
// initialize Row
        adminRow.setUserId(userId);
        adminRow.setExCode(exCode);
        adminRow.setAttributeCode("ADD_USER");
        adminRow.setAttributeValue("N");
        adminRow.setCreatedBy(createdBy);
        adminRow.setCreationDate(datetime);
        adminRow.setLastUpdatedBy(createdBy);

//get the datetime timestamp programmatically
        adminRow.setLastUpdatedDate(datetime);

//Add the initilized ROW to the View Object 
        AdminWBVO.insertRow(adminRow);

//Commit the Transaction
        this.getDBTransaction().commit();
          }


    /**Method to Execute DB SQL Query using DBTransaction
       * @param query
       * @return
       */
      protected BigDecimal executeQuery(String query) {
          ResultSet rs;
          BigDecimal code = null;
          try {
              rs = getDBTransaction().createStatement(0).executeQuery(query);
              if (rs.next()) {
                  code = new BigDecimal( rs.getObject(1).toString());
              }

              rs.close();
              return code;

          } catch (SQLException e) {
              throw new JboException(e);
          }
      }

Execute SQL Query in AMImpl ADF

 
 http://www.awasthiashish.com/2014/03/executing-sql-query-in-adf-application.html

Tuesday, March 24, 2015

Configure and Read 'Resource Bundles' ADF


      <?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" 
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:c="http://java.sun.com/jsp/jstl/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
                            
    <c:set var="RB" value="#{adfBundle['com.fm.fmreq.bundle.vars']}"/>  
.....
.....
....
<af:goLink text="List" id="pt_l2" inlineStyle="font-size:x-large; color:Aqua;"
                 destination="#{RB['vijay_application']}" targetFrame="_blank"/>     


var.properties file:

vijay_application=http:/127.0.0.1:7101/App/faces/jspx/test_relation.jspx

vijay_doc=//home//fmapp//Attachments//ORL_USER_DOCUMENTATION_20100615.pdf


https://technology.amis.nl/2012/08/09/introduction-to-resource-bundles-in-adf-applications-for-centralizing-management-of-boilerplate-text/

http://learn-adf.blogspot.com/2012/03/access-resource-bundle-in-bean.html


Friday, March 20, 2015

Change the context root of an application ADF


Steps:

  1. Right Click on the UI project
  2. Go to Project Properties
  3. Select Java EE Application 
  4. Under Java EE Wen Context Root: <Give the name you want and save> 
     By default all the jspx pages have /faces/ in the url, you can rename the <url pattern> in web.xml , servlet mappings 

Thursday, March 19, 2015

Use JSTL Expression Language to compare strings in JSPX page ADF Faces

Add the libary to the JSP root:
 xmlns:fn="http://java.sun.com/jsp/jstl/functions

You can use the function fn  as below
#{fn:toUpperCase(row.bindings.Status.inputValue) == 'APPROVED'}

https://blogs.oracle.com/jdevotnharvest/entry/using_jstl_in_adf_faces
http://www.tutorialspoint.com/jsp/jstl_function_touppercase.htm

Thursday, March 12, 2015

Set defautt Timestamp to an attribute ADF

import java.sql.Timestamp;

         setCreationDate(new Timestamp(System.currentTimeMillis()));
         setLastUpdateDate(new Timestamp( System.currentTimeMillis()));

If you want to set the time in  EO attribute, use the expression adf.CurrentDateTime (for timestamp) or adf.CurrentDate (for date)

http://abakalidis.blogspot.com/2007/02/oracle-adf-accessing-current-date-and.html
http://adfgouravtkiet.blogspot.com/2012/11/how-to-set-default-values-for-entity.html

Wednesday, March 4, 2015

Recommendations : Application Development using Oracle ADF


Deck Component JDeveloper 12.1.3 ADF


Today I got to know a new cool Deck component which looks like train component. This component is good especially for Mobile Applications

http://jdevadf.oracle.com/adf-richclient-demo/faces/components/deck.jspx#!
http://www.awasthiashish.com/2014/07/using-afdeck-component-to-animate.html

Monday, March 2, 2015

How to access Variables/Context Param Value from Web.xml in backing bean ADF

 
How to configure the context params in Web.xml? 

  <context-param>
<param-name>APPL_SERVER_ID</param-name>
<param-value>0F4BC9301420146EE053A070390AA93B15769402038552357083879215854267</param-value>
</context-param>
--------------------------------------------------------------------------------------------------------------------------
How to get that value in backing bean?

import javax.servlet.ServletContext;
       
  ServletContext servContext = (ServletContext)ADFContext.getCurrent().getEnvironment().getContext();
            String applServerID = servContext.getInitParameter("APPL_SERVER_ID");
---------------------------------------------------------------------------------------------------------------------

Query on database to see the APPL_SERVER_ID on database:

select node_name,node_id,server_id from fnd_nodes