Skip to main content

Posts

Showing posts from 2016

Stored Procedures in ADF

One of the common requirements for ADF programmers is to invoke Stored Procedures and Functions. Implementing this is so simple with few lines of code in Java classes used under business components. Following code snippets from fusion guide  will help execute different procedures with and without arguments. Execute stored procedure with No Arguments: public void callProcWithNoArgs() { getDBTransaction().executeCommand( "begin devguidepkg.proc_with_no_args; end;"); } Execute stored procedure with only IN arguments: Procedures often take arguments in order to process some business logic. Arguments are limited from none to many. In order to use stored procedures with argument mode we need to use JDBC PreparedStatement object. How To: Create connection Create a JDBC PreparedStatement with procedure details wrapped in a PL/SQL begin..end block. Assign the values to arguments if any. Execute the statement. Close the statement. protected void callStoredPr...

Handy code snippets: Oracle ADF

Get Binding Container: BindingContainer bind = BindingContext.getCurrent().getCurrentBindingsEntry(); Call and refresh Iterator from UI (Managed Bean): DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding iterBinding = bindings.findInteratorBinding("IteratorName"); iterBinding.executeQuery(); Get all rows from iterator: Row[] rows = iterBinding.getAllRowsInRange(); Call MethodAction:  BindingContainer binding = BindingContext.getCurrent().getCurrentBindingsEntry(); OperationBinding opBinding = binding.getOperationBinding("methodName"); opBinding.getParamsMap().put("params", "values"); opBinding.execute(); User details: // username ADFContext.getCurrent().getSecurityContext().getUserName(); //user role ADFContext.getCurrent().getSecurityContext().getUserRoles(); //check user in security group SecurityContext secContext = ADFContext.getCurrent().get...

Validation rules in ADF

Purpose:              Validation rules are used in almost all the applications which includes a database to make sure only valid data is committed to the database. You can define validations on your business service layer or directly on user interface.   As per fusion guide  there are three types of validation rules that can be used on entity objects: Attribute-level validation. Entity-level validation. Transaction-level validation. Attribute-level validation:          These validations are applied on attributes. Few examples might be upper and lower limit for salary, OrderDate should not be a date in the past and Length of attribute values.  How to: Select the attribute on EO. Edit Attribute. Validation. Define the check you want to perform under Rule Definition. Use Failure Handling to provide info to user. *Any conditions needed to perform/skip validation can be added in Validati...

ADF Create Vs CreateInsert

Three ways in ADF to create a new row: Create, CreateInsert and CreateWithParams As per fusion guide: What happens when you use Create ? // create a new row for the view object Row newRow = yourViewObject.createRow(); // mark the row as being "initialized", but not yet new newRow.setNewRowState(Row.STATUS_INITIALIZED); When CreateInsert is used? It performs this additional line of code to inert the row into the row set and make it available on the iterator. // insert the new row into the view object's default rowset yourViewObject.insertRow(newRow); When CreateWithParams is used? CreateWithParams does similar tasks as CreateInsert except that it gives the feasibility to define default values declaratively for the row attributes. Suggested usages:       - With ADF forms you can use Create or CreateInsert.       -  It is always safe to use CreateInsert when you have af:table as it will create a empty record and also puts it in recordse...

Issues installing Oracle 12c on Windows.

Oracle 12c comes in two packages and installing it is so easy but takes a lot of time to figure out a simple solution. Follow these steps for a smooth installation: 1. Download oracle12c(file1,file2) from oracle downloads page. 2. You will see two packages winx64_12102_SE2_database_1of2 winx64_12102_SE2_database_2of2 3. Extract winx64_12102_SE2_database_1of2 and winx64_12102_SE2_database_2of2 . 4. Copy all files from winx64_12102_SE2_database_2of2\database\stage\Components to winx64_12102_SE2_database_1of2\database\stage\Components. 5. Run setup in database as Administrator. Happy Coding :)