Tuesday, February 28, 2012

How to make summary Column.How to calculate Sum of a column.

Hi
I have a af:table that displays information about Employee vacation. I want to sum the value of the column "ActualNumberOfDays".
Here is the table.

I will Explain how I calculated the total of the "Acutal days" column.
1- I Created a readonly view based on Query
SELECT     v_emv.ID emv_id,     v_emp.EMP_ID emp_id,     v_emp.EMP_NAME_AR ar_name_full,     v_emp.EMP_NUM,     v_vat.NAME_AR,     v_emv.START_DATE,     v_emv.END_DATE,     v_emv.NUMBER_OF_DAYS,     v_set.ACTUAL_END_DATE set_end_date,     v_emv.HOLIDAYS,     v_emv.VACATION_STATUS,     v_set.ACTUAL_NUMBER_OF_DAYS - NVL(v_set.ACTUAL_HOLIDAYS, 0) - NVL(v_set.MISSION_DAYS, 0) actual_number_of_days 
FROM     HRS_V_EMP_BASIC_INFO v_emp,     HRS_V_EMP_VACATIONS v_emv,     HRS_V_VACATION_TYPES v_vat,     HRS_V_EMP_VACATION_SETTLEMENTS v_set WHERE     v_emv.EMP_ID = v_emp.EMP_ID AND v_set.EMV_ID(+) = v_emv.ID AND v_emv.VAT_ID = v_vat.ID 

 2- in a managed bean , Add attribute  private int totalVacationDays; and in the accessor write these this code

  public int getTotalVacationDays() {
        totalVacationDays = 0;
        oracle.jbo.domain.Number total;
        int rowcount = 0;
        DCBindingContainer bc =
            (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding iter =
            bc.findIteratorBinding("empVacations1Iterator");
        iter.setRangeSize(-1);
        Row[] rows = iter.getAllRowsInRange();
        if (rows == null) {
            return 0;
        }
        rowcount = rows.length;
        for (int i = 0; i < rowcount; i++) {
            Row currentRow = rows[i];
            if (currentRow != null) {
                total =
                        (oracle.jbo.domain.Number)currentRow.getAttribute("ActualNumberOfDays");
                if (total != null) {
                    totalVacationDays += total.intValue();
                }
            }
        }
        return totalVacationDays;
    }

3- the last step is to add an af:outputText in somewhere in your page and set the value of this outputtest to the attribue "totalVacationDays" in the bean.Example : #{mybean.totalVacationDays}
and set the partialTriggers property of the outputtext to be the table that contains the column that you want to sum. This will help in case the user adds some filer on the data.



Sunday, October 16, 2011

How to create fixed list in ADF

1- create a read only view object based on a query
example:
SELECT 'Reject' DESCRIPTION
,'BCK' CODE
FROM DUAL
UNION ALL
SELECT 'Accept' DESCRIPTION
,'GM' CODE
FROM DUAL
2- in the base view object (your main view object that you want to add the fixed list) add a new Transient attribute for example "Manager_descision"
3- Create view accessor in the main view abject that referes to the readonly query VO
4- associat a LOV to your Transient  attribute that is based on your view accessor
 
Note that you must add list return value to retrun the value to the database attribute to save the returned value in the DB
5- in your page drag and drop the transient attribute from the data control to the page as selectOneChoceList

6- go to the page Bindings and select the attribute in the strucure window and right click to add attribute names and attribute values

6- save and run the page

Tuesday, June 14, 2011

The JRE was not found in directory

The JRE was not found in directory G:\weblogicServer\jdk160_21. (JAVA_HOME)
Please edit your environment and set the JAVA_HOME


this error occurred when deploying a page on jdeveloper. to solve this error go to tools menu and  select credentials and correct the path specified


Thursday, April 28, 2011

Deleting multi-selected rows from adf table

In this example i will selected rows using
1)  CTRL or SHIFT with mouse click
2)  Checkbox at the row
and press Delete button for ease of understanding i created 2 separate buttons in the examples.

Before start i assumed you already setup a Application with EO,VO and AM also using HR Connection

- Add a Transient Attribute to VO of Boolean type named "SelectedRow" We will use this to select row
Here the layout looks like



- Drag a Collection from DataControl as ADF Table to JSF page
- Dont Check RowSelection Checkbox
- Set the table RowSelection property to multiple
- Set EditingMode property to clickToEdit
- Surround your table with af:PanelCollection for look and feel give table a id "myTab"
- Add a toolbar in toolbar facet of Panelcollection
- Add 2 toolbar buttons to your toolbar
- Add partial triggers to your table reference both buttons on toolbar
- Create a backing bean
- Add a RichTable object to your bean with getter and setter methods.
- Set the binding property of the af:table to your Managed Bean
- Add Methods in Backing bean similar to the following code
- Link a method deleteAction to your "Delete Selected Rows" button and DeleteCheckedRows to other button.

Wednesday, April 27, 2011

Another user has changed the row with primary key oracle.jbo.Key[12 ].


  1.  make sure that you check "refresh after insert" and refresh after update" for the primary key column in you entity object.
  2. in the application module tab Click the Properties tab and select jbo.locking.mode. Double click the “pessimistic”value next to the property to open the field editor and type “optimistic” over the value.Press enter.
  3. if error still exist then you must set "refresh after insert" and refresh after update" as true for all attributes in the entity object

Detail entity with row key null cannot find or invalidate its owning entity.


  1. in the model project go to the association.
  2. double click on the association and expand the behavior node under relationship tab.
  3. make sure that the primary key column is set to DBsequance, if you have a sequence on the database or a function that generate the db sequence from a trigger

3- check on composition association and cascade update key attribute

Sunday, April 17, 2011

ADF Desktop Integration-enabled Excel Workbook


In Part 2 you created a basic Excel workbook, integrated with a Fusion Web application. In this part of the tutorial you add detail to that workbook to create one that is more functional.
Step 1: Creating the EditDept_LOV Workbook
  1. Right-click the ViewController project in the Navigator and select New... from the context menu. In the New Gallery expand the Client Tier node if it is not already expanded, and select ADF Desktop Integration. Microsoft Excel Workbook should be automatically highlighted in the Items pane, so clickOK to select it.
    alt text
  2. This first step - creating the EditDept_LOV workbook - involves exactly the same tasks as for creating the previous worksheet. Show more or lessRead more...
  3. Name the workbook EditDept_LOV_src.xlsx and click OK.
    alt text
  4. In the Application Navigator, double-click EditDept_LOV_src.xlsx to open Excel.
    alt text
  5. Excel opens, loading Oracle ADF Desktop Integration. In the Page Definition dialog, select theADFdi_view_EditTable_LOVPageDef page definition.
    alt text
  6. The ADFdi task pane displays in Excel, presenting the available bindings from the page definition.
  7. The page definition selected in the previous step (ADFdi_view_EditTable_LOVPageDef) contains several different types of bindings, in addition to the tree binding that you used in the previous part of this tutorial when creating the DepartmentsList workbook.Show more or lessRead more...
  8. When the worksheet displays, select a cell and in the Bindings tab, select DepartmentsView1 and click Insert Binding.
    alt text
  9. In the Select Component dialog, select ADF Table. Click OK.
    alt text
  10. In the Insert Component: ADF Table dialog, click OK to accept default values.
    alt text
  11. The Excel worksheet should look like this:
    alt text
    Notice that the first three columns are automatically generated in the context of an editable table for information purposes.
  12. Click the Save icon  to save the workbook.
Step 2: Setting Workbook and Table Properties
  1. Click the Workbook Properties link in the Oracle ADF tab of the Excel ribbon.
    alt text
  2. In the Edit Workbook Properties, next to the WebAppRoot field, enterhttp://127.0.0.1:7101/ADFdi_BC as before, and click OK. This is the URL for the Fusion Web application with which the workbook is integrated.
    alt text
  3. In the Excel worksheet, select the top left cell of your table (i.e. B2), and click the properties icon in the ADF Components group of the Oracle ADF tab in the Excel ribbon.
    alt text
  4. In the Edit Component: ADF Table dialog, expand the RowActions node and click the more button next to the DeleteRowActionID field.
    alt text
  5. In the Select Binding dialog, select Delete (action) and click OK.
    alt text
  6. The RowActions set of properties defines the behavior of rows in the table in the worksheet. Show more or lessRead more...
  7. Repeat the previous step for the InsertBeforeRowActionID field and choose the CreateInsert(action). Click OK.
    alt text
  8. In the RowActions section, set the following additional values:
    DeleteRowEnabledTrue
    InsertRowEnabledTrue
    UpdateRowEnabledTrue
    The RowActions properties should look as follows:
    alt text
  9. In the BatchOptions section, set the CommitBatchActionID to Commit and click OK.
    alt text
  10. In the Edit Component dialog, click the more button  next to the Columns field.
    alt text
  11. Click the Add button to add a new column, then click the more button  next to the HeaderLabelfield.
    alt text
  12. In the Edit Expression dialog, expand the bindings > DepartmentsView1 > DepartmentsView > hints > LocationId > label field, click the Insert Into Expression button.
    alt text
    Click OK.
  13. You have just created a new column in the worksheet and bound it to the "LocationId" label. Show more or lessRead more...
  14. Click the more button  next to the UpdateComponent field.
    alt text
  15. In the Select subcomponent to create dialog, select TreeNodeList and click OK.
    alt text
  16. Expand the UpdateComponent node and click the more button  next to the List field.
    alt text
  17. In the Select Tree Binding Attribute, select LocationId and click OK.
    alt text
  18. Select column 6 and click the Remove button to remove the original LocationId column and replace it with this new column that supports a list of values.
    alt text
  19. Select column number 3 (DepartmentId) and expand the UpdateComponent node. Change theReadOnly property to True.
    alt text

  20. The application that you are designing requires that users should not be allowed to change Department Ids. Show more or lessRead more...
  21. With column number 3 (DepartmentId) still selected, click the more button in the CellStyleNamefield.
    alt text
  22. In the Edit Expression dialog, expand the Styles node.
    alt text
  23. Select _ADFDI_TableCellROStyle (this is the style that visually indicates that a column is read-only) and click Insert Into Expression.
    alt text
    Click OK and OK again to exit the Edit Component dialog.
  24. Save your Excel workbook.
Step 3: Defining a Query Ribbon Command
In this step you add a command item to the Excel ribbon at the top of the worksheet. Show more or lessRead more...
  1. In the Oracle ADF tab, click the Worksheet Properties button. Locate Ribbon Commands and click the more button.
    alt text
  2. In the WorksheetMenuItem Collection Editor click Add.
    alt text
  3. In the right-hand pane, click the more button  next to the Actions field.
    alt text
  4. In the Action Collection Editor dialog, click the Add button and select ADFmAction from the drop down list.
    alt text
  5. In the ADFmAction properties, click the more button  next to the ActionID field.
    alt text
  6. In the Select Binding dialog, select Execute and click OK.
    alt text
  7. Back in the Action Collection Editor, in the Design > Annotation field, type Run query .
    alt text
  8. In the Action Collection Editor dialog, click the Add button and select ComponentAction from the drop down list.
    alt text
  9. Click the more button  at the right-hand end of the Action field.
    alt text
  10. In the Choose Component Action dialog, select Download and click OK.
    alt text
  11. Then, back in the Action Collection Editor, in the Design > Annotation field, type Download and click OK.
    alt text
  12. Back in the WorksheetMenuItem Collection Editor, type Query in the Label field.
    alt text
    Click OK and OK again.
  13. "Query" is the label for the command item that appears on the Excel ribbon.Show more or lessRead more...
  14. Save your Excel workbook.
Step 4: Defining a Delete Rows Ribbon Command
    In this step you add another command item to the Excel ribbon at the top of the worksheet.Show more or lessRead more...
  1. In the Oracle ADF tab, click the Worksheet Properties button. Locate Ribbon Commands and click the more button.
    alt text
  2. In the WorksheetMenuItem Collection Editor click Add.
    alt text
  3. In the right-hand pane, click the more button  next to the Actions field.
    alt text
  4. Click the Add button and from the drop down list select Confirmation.
    alt text
  5. In the Data section, enter the following values:
    CancelButtonLabelCancel
    OKButtonLabelYes
    PromptAre you sure you want to delete these rows?
    TitleDelete Confirmation

    alt text
  6. Click the Add button and from the drop down list select ComponentAction.
    alt text
  7. In the ComponentAction properties, click the more button  next to the Action field.
    alt text
  8. In the Choose Component Action, select DeleteFlaggedRows.
    alt text
  9. Click OK and OK again.
  10. In the WorksheetMenuItem Collection Editor, type Delete Flagged in the Label field.
    alt text
    Click OK.
Step 5: Defining an Upload Ribbon Command
    In this step you add another command item to the Excel ribbon at the top of the worksheet.Show more or lessRead more...
  1. In the Oracle ADF tab, click the Worksheet Properties button. Locate Ribbon Commands and click the more button.
    alt text
  2. In the WorksheetMenuItem Collection Editor click Add.
    alt text
  3. In the right-hand pane, click the more button  next to the Actions field.
    alt text
  4. In the Action Collection Editor dialog, click the Add button and select ComponentAction from the drop down list.
    alt text
  5. In the ComponentAction properties, click the more button  next to the Action field.
    alt text
  6. In the Choose Component Action dialog, select Upload. Click OK.
    alt text
    Click OK again.
  7. In theWorksheetMenuItem Collection Editor, type Upload in the Label field and click OK.
    Click OK again.
  8. Save the workbook.
Step 6: Testing the EditDept_LOV Workbook
  1. Click the Oracle ADF tab in the Excel ribbon.
    alt text
  2. Click the Run button in the Test group.
  3. The workbook loads, displaying the ADF table, not yet populated with data.
    alt text
  4. Click the MyWorkbook tab, displayed in the Excel ribbon to the right of the Oracle ADF tab.
    alt text
  5. Notice the three command items that you have just created, in the Worksheet group.
    Click the Query button.
    alt text
  6. Retrieved data are then displayed in the worksheet.
    alt text
  7. Notice that the DepartmentId column is shaded in a different color from the other columns.Show more or lessRead more...
  8. At the bottom of the worksheet, after the last row, insert a new row, by right-clicking in an empty row and choosing Insert from the context menu. Type a new department name and select a city from the drop down list.
    alt text
  9. Notice that the new row is automatically flagged in the Changed column.
    alt text
  10. For an existing row, try changing the location from the drop down list.
    alt text
  11. Click the newly-created Upload command item in the Excel ribbon to save the changes.
    alt text
  12. On the Upload Options dialog check the Download all rows after successful upload checkbox.
    alt text
  13. Notice that the new row has been inserted, a Department Id has been generated, and the flags have been removed.
  14. Click in the Flagged column for the row you just inserted.
    alt text
  15. Click the Delete Flagged button.
    alt text
  16. In the Delete Confirmation dialog you created previously, click Yes.
    alt text
  17. The worksheet is updated.
    alt text
  18. Click the Stop button, to return to design mode.
    alt text
    You have created a fully-functioning workbook that is integrated with a Fusion Web application, and which allows you to insert, update and delete data from the database. The next part of this tutorial guides you through publishing your workbooks.