How to invoke Application Module Method from Page?

How to invoke Application Module Method from Page?

Sometimes we need to perform some database operation like insert data to table or others, for that purpose we can use application module method   which easily get connection from database to perform database curd operation.

1. First create method to Application Module Impl class as follows-

    public String createDepartment(String id, String name, String mid, String lid) {
        String msg = "";
        String sql =
            "insert into DEPARTMENTS(DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values(?,?,?,?)";

        oracle.jdbc.OraclePreparedStatement pstmt =
            (oracle.jdbc.OraclePreparedStatement)this.getDBTransaction().createPreparedStatement(sql,
                                                                                                 0);

        int i = 1;


        try {
            pstmt.setString(i++, id);
            pstmt.setString(i++, name);
            pstmt.setString(i++, mid);
            pstmt.setString(i++, lid);
            int cnt = pstmt.executeUpdate();
            if (cnt > 0) {
                msg = "success";
            } else {
                msg = "failed";
            }
        } catch (Exception ex) {
            System.out.println("Exception to insert data" + ex);
            msg = "Error:" + ex.getMessage();
        }
        return msg;
    }

2. Then Select Application Module go to Java tab and click pencil icon to Client Interface Section.

 

  1. Add your method in Edit Client Interface popup Window

  1. Open your jspx page and drag-drop method from data control to jspx page as ADF Parameter Form.

Output

 

 

Sample Code

About Manish Pandey

Manish is a Project Leader at Jagran Prakashan Ltd, focused on Jdeveloper Fusion Web Application(specifically Oracle ADF). He shares his knowledge through the OTN Jdev/ADF Forum. He has written more than 50 article about Oracle ADF and Jdeveloper.

Leave a Reply

Your email address will not be published. Required fields are marked *

*