Skip Headers
Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers
10g (10.1.3.1.0)

Part Number B25947-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

10.6 Overview of How SRDemo Pages Use the SRService

This section provides a brief overview of how each page in the SRDemo application uses the SRService application module's view object instances and service methods.

10.6.1 The SRList Page

10.6.1.1 Overview of Data Binding in the SRList Page

Figure 10-16 illustrates the data binding for SRList page.

Iterator Bindings to View Object Instances

ServiceRequestsByStatusIterator for ServiceRequestsByStatus view object instance

Page Definition Variables

None

Action Bindings to Built-in Operations

setCurrentRowWithKey, ExecuteWithParams related to the ServiceRequestsByStatusIterator iterator binding

Method Action Bindings to Custom Operations

None

InvokeActions Customizing Page Lifecycle

None

Figure 10-16 View Object for SRList Page

Image of ViewObject for SRList Page

10.6.1.2 Business Service Notes for the SRList Page

View Object Instances

ServiceRequestsByStatus is an instance of the entity-based view object ServiceRequestsByStatus, which extends the ServiceRequests view object and adds a named bind variable called StatusCode.

Application Module Custom Methods

None

10.6.2 The SRMain Page

10.6.2.1 Overview of Data Binding in the SRMain Page

Figure 10-17 illustrates the data binding for the SRMain page.

Iterator Bindings to View Object Instances
  • ServiceRequestsIterator for ServiceRequests view object instance

  • ServiceHistoriesIterator for ServiceHistories view object instance

Page Definition Variables

None

Action Bindings to Built-in Operations
  • setCurrentRowWithKey, Delete related to the ServiceRequestsIterator iterator binding

  • Create, DeleteNewHistory (for Delete built-in) related to the ServiceHistoriesIterator iterator binding

  • Commit related to the SRService data control

Method Action Bindings to Custom Operations

deleteServiceHistoryNotes invokes deleteServiceHistoryNotes() method on the SRService client interface

InvokeActions Customizing Page Lifecycle

None


Note:

The SRMain backing bean for the SRMain page (in the oracle.srdemo.view.backing package) is using the technique described in Section 10.5.4.3, "Using Custom ADF Page Lifecycle to Invoke an onPageLoad Backing Bean Method" to programmatically accomplish exactly the same thing that the SREdit page is doing declaratively.

Figure 10-17 Service Method and View Objects for the SRManage Page

Service method and View Objects for the SRManage Page

10.6.2.2 Business Service Notes for the SRMain Page

View Object Instances
  • ServiceRequests is an instance of the entity-based view object ServiceRequests. It joins data from the main ServiceRequest entity usage and three additional reference entity usages: CreatedByUser (User entity object), AssignedToUser (User entity object), and Product. The ServiceRequests view object is linked master/detail to the ServiceHistories view object.

  • ServiceHistories is an instance of the entity-based view object ServiceHistories. It joins data from the main ServiceHistory entity usage and an additional reference entity usage SystemUser (User entity object). It is an XML-only view object, with no custom Java class.

Application Module Custom Methods

As shown in Example 10-3, the deleteServiceHistoryNotes() method deletes service history note rows corresponding to the Key objects in the key set passed as an argument.

Example 10-3 DeleteServiceHistoryNotes Method in SRServiceImpl.java

public void deleteServiceHistoryNotes(Set keySet) {
  if (keySet != null) {
    ViewObject histories = getServiceHistories();
    for (Key k: (Set<Key>)keySet) {
      Row[] rowToDelete = histories.findByKey(k, 1);
      if (rowToDelete == null || rowToDelete.length == 0) {
        throw new JboException("Failed to find row with serialized key" + 
                               k.toStringFormat(false));
      }
      rowToDelete[0].remove();
      getDBTransaction().commit();
    }
  }
}

10.6.3 The SREdit Page

10.6.3.1 Overview of Data Binding in the SREdit Page

Figure 10-18 illustrates the data binding in the SREdit page.

Iterator Bindings to View Object Instances
  • ServiceRequestsIterator for ServiceRequests view object instance

  • ServiceRequestStatusListIterator for ServiceRequestStatusList view object instance

Page Definition Variables

None

Action Bindings to Built-in Operations
  • setCurrentRowWithKey related to the ServiceRequestsIterator iterator binding

  • Commit related to the SRService data control

Method Action Bindings to Custom Operations

cancelEditsToCurrentServiceRequest invokes cancelEditsToCurrentServiceRequest() on the SRService client interface

InvokeActions Customizing Page Lifecycle

setRowToEditFromRequestParameter invokes the built-in setCurrentRowWithKey operation in prepare model phase (Refresh="prepareModel") when first navigating to the page (i.e. not processing a postback) and processScope.rowKeyStr attribute is not set (RefreshCondition="${adfFacesContext.postback == false and not empty processScope.rowKeyStr}").

Figure 10-18 Service Method and View Objects for the SREdit Page

Service Method and View Objects for the SREdit Page

10.6.3.2 Business Service Notes for the SREdit Page

View Object Instances
  • ServiceRequests is an instance of the entity-based view object ServiceRequests. It joins data from the main ServiceRequest entity usage and three additional reference entity usages: CreatedByUser (User entity object), AssignedToUser (User entity object), and Product.

  • ServiceRequestStatusList is an instance of the read-only view object ServiceRequestStatusList. Its data is provided by a static list supplied in the ServiceRequestStatusListImpl.java class. This class extends a SRStaticDataViewObjectImpl in the FrameworkExtensions project which provides the basic support for implementing a view object based on static data.

Application Module Custom Methods

As shown in Example 10-4, the cancelEditsToCurrentServiceRequest() method uses the refresh() method to cancel edits made in the current transaction to the current service request row.

Example 10-4 CancelEditsToCurrentServiceRequest Method in SRServiceImpl.java

public void cancelEditsToCurrentServiceRequest() {
  Row svReq = getServiceRequests().getCurrentRow();
  if (svReq != null) {
    svReq.refresh(Row.REFRESH_WITH_DB_FORGET_CHANGES);
  }
}

10.6.4 The SRSearch Page

10.6.4.1 Overview of Data Binding in the SRSearch Page

Figure 10-19 illustrates the data binding in the SRSearch page.

Iterator Bindings to View Object Instances
  • SearchServiceRequestsIterator for SearchServiceRequests view object instance (Forced to stay in find mode by AlwaysFind invokeAction).

  • SearchServiceRequestsResultsIterator for SearchServiceRequests view object instance

  • ServiceRequestStatusListIterator for ServiceRequestStatusList view object instance

Page Definition Variables

None

Action Bindings to Built-in Operations
  • Execute, Delete, Create related to the SearchServiceRequestsIterator iterator binding

  • Find, First, Next, Previous, Last, setCurrentRowWithKey related to the SearchServiceRequestsResultsIterator iterator binding

Method Action Bindings to Custom Operations

None

InvokeActions Customizing Page Lifecycle
  • AlwaysFind invokes the built-in Find operation (for the SearchServiceRequestsIterator iterator binding) in either prepare model or render model phases (Refresh="ifNeeded") when the SearchServiceRequestsIterator is not in find mode ( ${bindings.SearchServiceRequestsIterator.findMode == false})

  • insertBlankViewCriteriaRowIfThereAreNone invokes the built-in Create operation in either prepare model or render model phases (Refresh="ifNeeded") when the SearchServiceRequestsIterator is not in find mode ( ${bindings.SearchServiceRequestsIterator.findMode == false})

Figure 10-19 View Object for the SRSearch Page

Image shows view object for the SRSearch page

10.6.4.2 Business Service Notes for the SRSearch Page

View Object Instances
  • SearchServiceRequests is an instance of the entity-based view object ServiceRequests. It joins data from the main ServiceRequest entity usage and three additional reference entity usages: CreatedByUser (User entity object), AssignedToUser (User entity object), and Product.

  • ServiceRequestStatusList is an instance of the read-only view object ServiceRequestStatusList. Its data is provided by a static list supplied in the ServiceRequestStatusListImpl.java class. This class extends a SRStaticDataViewObjectImpl in the FrameworkExtensions project which provides the basic support for implementing a view object based on static data.

Application Module Custom Methods

None

10.6.5 The SRStaffSearch Page

10.6.5.1 Overview of Data Binding in the SRStaffSearch Page

Figure 10-20 illustrates the data binding for the SRStaffSearch page.

Iterator Bindings to View Object Instances

StaffListByEmailNameRoleIterator for StaffListByEmailNameRole view object instance

Page Definition Variables

StaffListByEmailNameRole_Role, StaffListByEmailNameRole_EmailAddress, StaffListByEmailNameRole_TheFirstName, StaffListByEmailNameRole_TheLastName

Action Bindings to Built-in Operations

ExecuteWithParams related to StaffListByEmailNameRoleIterator iterator binding

Method Action Bindings to Custom Operations

None

InvokeActions Customizing Page Lifecycle

None

Figure 10-20 View Objects for the SRStaffSearch Page

Image shows view objects for the SRStaffSearch page

10.6.5.2 Business Service Notes for the SRStaffSearch Page

View Object Instances

StaffListByEmailNameRole is an instance of the entity-based view object StaffListByEmailNameRole, which extends the StaffList view object and adds name bind variables EmailAddress, Role, TheFirstName, and TheLastName.

Application Module Custom Methods

None

10.6.6 The SRManage Page

10.6.6.1 Overview of Data Binding in the SRManage Page

Figure 10-21 illustrates the data binding in the SRManage page.

Iterator Bindings to View Object Instances
  • StaffWithOpenRequestsIterator for StaffWithOpenRequests view object instance

  • ExpertiseAreasIterator for ExpertiseAreas view object instance

  • OpenOrPendingServiceRequestsIterator for OpenOrPendingServiceRequests view object instance

  • ServiceHistoriesForRequestIterator for ServiceHistoriesForRequest view object instance

Page Definition Variables

None

Action Bindings to Built-in Operations

setCurrentStaffRowWithKey (for setCurrentRowWithKey built-in) related to StaffWithOpenRequestsIterator iterator binding

Method Action Bindings to Custom Operations

setCurrentProblemAndAssigneeRows invokes setCurrentProblemAndAssigneeRows() on the SRService client interface

InvokeActions Customizing Page Lifecycle

None

Figure 10-21 Service Method and View Objects for the SRManage Page

Service Method and View Objects for the SRManage Page

10.6.6.2 Business Service Notes for the SRManage Page

View Object Instances
  • StaffWithOpenRequests is an instance of the read-only view object StaffWithOpenRequests. It queries information from the USERS and SERVICE_REQUESTS tables. It is an XML only view object, with no related Java class. This view object is linked master/detail with the ExpertiseAreas and OpenOrPendingServiceRequests view objects.

  • ExpertiseAreas is an instance of the entity-based view object ExpertiseAreas. It joins information from the primary ExpertiseArea entity usage and a reference Product entity usage. It is an XML only view object, with no related Java class.

  • OpenOrPendingServiceRequests is an instance of the read-only view object OpenOrPendingServiceRequests. It queries information from the SERVICE_REQUESTS table. It is an XML only view object, with no related Java class. This view object is linked master/detail with the ServiceHistories view object.

  • ServiceHistoriesForRequest is an instance of the entity-based view object ServiceHistories. It joins data from the main ServiceHistory entity usage and an additional reference entity usage SystemUser (User entity object). It is an XML-only view object, with no custom Java class.

Application Module Custom Methods

As shown in Example 10-5, the setCurrentProblemAndAssigneeRows() method uses a helper method to set the current row in the StaffWithOpenRequests view object instance and the OpenOrPendingServiceRequests view object instance based on the serialized string keys passed in.

Example 10-5 SetCurrentProblemAndAssigneeRows Method in SRServiceImpl.java

public void setCurrentProblemAndAssigneeRows(String requestKeyStr, 
                                               String staffKeyStr) {
    setRowWithKeyString(getStaffWithOpenRequests(), staffKeyStr);
    setRowWithKeyString(getOpenOrPendingServiceRequests(), requestKeyStr);
  }

10.6.7 The SRSkills Page

10.6.7.1 Overview of Data Binding in the SRSkills Page

Figure 10-21 illustrates the data binding for the SRSkills page.

Iterator Bindings to View Object Instances
  • StaffListIterator for StaffList view object instance

  • StaffExpertiseAreasIterator for StaffExpertiseAreas view object instance

  • ProductListIterator for ProductList view object instance

Page Definition Variables

None

Action Bindings to Built-in Operations

None

Method Action Bindings to Custom Operations

updateSkillsForCurrentStaff invokes the updateSkillsForCurrentStaff() method on the SRService client interface

InvokeActions Customizing Page Lifecycle

None

Figure 10-22 Service Method and View Objects for the SRSkills Page

Service Method and View Objects for the SRSkills Page

10.6.7.2 Business Service Notes for the SRSkills Page

View Object Instances
  • StaffList is an instance of the entity-based view object StaffList. It queries information from the primary entity usage SystemUser (User entity object). This view object is linked master/detail with the ExpertiseAreas view object.

  • StaffExpertiseAreas is an instance of the entity-based view object ExpertiseAreas. It joins information from the primary ExpertiseArea entity usage and a reference Product entity usage. It is an XML only view object, with no related Java class.

  • ProductList is an instance of the entity-based view object ProductList. It queries data from the primary entity usage Products (Product entity object). It is an XML only view object, with no related Java class.

Application Module Custom Methods

As shown in Example 10-6, the updateSkillsForCurrentStaff() method performs the following steps:

  1. Clones the list of product ids

  2. Creates a secondary RowSetIterator to do programmatic iteration over the ExpertiseAreas

  3. Removes rows for current user for products that are not in the list of products ids

  4. Closes the secondary row set iterator when done iterating

  5. Adds new rows for the keys that are left

  6. Commits the transaction.

Example 10-6 UpdateSkillsForCurrentStaff Method in SRServiceImpl.java

public void updateSkillsForCurrentStaff(List productIds) {
    if (productIds != null && productIds.size() > 0) {
      // 1. Cone the list of product ids
      List<Number> copyOfProductIds = (List<Number>)Utils.cloneList(productIds);
      ViewObject skills = getStaffExpertiseAreas();
      // 2. Create a secondary rowset iterator for iteration
      RowSetIterator rsi = skills.createRowSetIterator(null);
      // 3. Remove rows for current user for products not in list of products
      while (rsi.hasNext()) {
        Row r = rsi.next();
        Number productId = (Number)r.getAttribute("ProdId");
        // if the existing row is in the list, we're ok, so remove from list.
        if (copyOfProductIds.contains(productId)) {
          copyOfProductIds.remove(productId);
        }
        // if the existing row is in not list, remove it.
        else {
          r.remove();
        }
      }
      // 4. Close the secondary row set iterator when we're done
      rsi.closeRowSetIterator();
      // 5. Add new rows for the keys that are left
      for (Number productIdToAdd: copyOfProductIds) {
        Row newRow = skills.createRow();
        skills.insertRow(newRow);
        newRow.setAttribute("ProdId", productIdToAdd);
      }
      // 6. Commit the transaction
      getDBTransaction().commit();
    }
  }

Note:

Since the iterator bindings in the ADF Model layer bind by default to the default row set iterator for the default rowset of the view object instance to which they are related, it's best practice to create a secondary row set iterator to perform programmatic iteration of a view object's row set in your application business logic. This way you do not affect the current row that the user sees in the user interface. The secondary iterator can have a developer-assigned name, but if you pass null the system assigns it a name. Since you'll typically always be closing it as soon as you're done iterating, using the system-assigned name is fine.

10.6.8 The SRCreate Page

10.6.8.1 Overview of Data Binding in the SRCreate Page

Figure 10-23 illustrates the data binding for the SRCreate page.

Iterator Bindings to View Object Instances
  • GlobalsIterator for Globals view object instance

  • ProductListIterator for ProductList view object instance

Page Definition Variables

None

Action Bindings to Built-in Operations

None

Method Action Bindings to Custom Operations

cancelNewServiceRequest invokes the cancelNewServiceRequest method on the SRService client interface

InvokeActions Customizing Page Lifecycle

clearServiceRequestFieldsIfNotInTrain invokes the cancelNewServiceRequest method action binding during prepare model phase (Refresh="prepareModel") when the page is not handling postback events and the requestScope.processChoice attribute is not set (RefreshCondition="${adfFacesContext.postback == false and empty requestScope.processChoice}").

Figure 10-23 Service Method and View Objects for the SRCreate Page

Service Method and View Objects for the SRCreate Page

10.6.8.2 Business Service Notes for the SRCreate Page

View Object Instances
  • ProductList is an instance of the entity-based view object ProductList. It queries data from the primary entity usage Products (Product entity object). It is an XML only view object, with no related Java class.

  • Globals is an instance of the transient view object Globals. It contains transient attributes to temporarily store information about ProductId, ProductName, and ProductDescription across pages.


Note:

A transient view object is one that has no SQL query and all transient attributes. It can contain rows that are populated either programmatically by your application module business logic or declaratively using action bindings for built-in operations in the ADF Model layer. For users familiar with Oracle Forms, this is similar to what you know as a "non database block" in Forms.

Application Module Custom Methods

As shown in Example 10-7, the cancelNewServiceRequest() method ensures there is a single blank row in the Globals view object instance.

Example 10-7 CancelNewServiceRequest Method in SRServiceImpl.java

public void cancelNewServiceRequest() {
  ViewObject globals = getGlobals();
  globals.clearCache();
  globals.insertRow(globals.createRow());
}

10.6.9 The SRConfirmCreate Page

10.6.9.1 Overview of Data Binding in the SRConfirmCreate Page

Figure 10-24 illustrates the data binding for the SRConfirmCreate page.

Iterator Bindings to View Object Instances
  • GlobalsIterator for Globals view object instance

  • LoggedInUserIterator for LoggedInUser view object instance

Page Definition Variables

None

Action Bindings to Built-in Operations

None

Method Action Bindings to Custom Operations
  • cancelNewServiceRequest invokes the cancelNewServiceRequest() on the SRService client interface

  • createServiceRequest invokes the createServiceRequest() on the SRService client interface

InvokeActions Customizing Page Lifecycle

None

Figure 10-24 Service Method and View Objects for the SRConfirmCreate Page

Service Method and View Objects for the SRConfirmCreate Page

10.6.9.2 Business Service Notes for the SRCreate Page

View Object Instances
  • Globals is an instance of the transient view object Globals. It contains transient attributes to temporarily store information about ProductId, ProductName, and ProductDescription across pages.

  • LoggedInUser is an instance of the entity-based view object LoggedInUser. It queries data from the primary entity usage Users (User entity object). The LoggedInUser view object is linked master/detail with the ServiceRequestsByStatus view object.

Application Module Custom Methods

As shown in Example 10-8, the createServiceRequest() method performs the following basic steps:

  1. Gets the entity definition for ServiceRequest

  2. Creates a new ServiceRequest entity row (ServiceRequestImpl class)

  3. Accesses the current row in Globals as a strongly-typed GlobalsRowImpl

  4. Set the problem description and product ID for new service request

  5. Commits the transaction

  6. Returns an Integer representing the database-trigger assigned SR number for the new service request.

Example 10-8 CreateServiceRequest Method in SRServiceImpl.java

public Integer createServiceRequest() {
  // 1. Get the entity definition for ServiceRequest
  EntityDefImpl svcReqDef = ServiceRequestImpl.getDefinitionObject();
  // 2. Create a new ServiceRequest entity row
  ServiceRequestImpl newReq = 
    (ServiceRequestImpl)svcReqDef.createInstance2(getDBTransaction(),null);
  // 3. Access the current row in Globals as a strongly-typed GlobalsRowImpl
  GlobalsRowImpl globalsRow = (GlobalsRowImpl)getGlobals().getCurrentRow();
  // 4. Set the problem description and product id for new service request
  newReq.setProblemDescription(globalsRow.getProblemDescription());
  newReq.setProdId(globalsRow.getProductId());
  // 5. Commit the transaction
  getDBTransaction().commit();
  // 6. Return an integer representing the database-assigned SR Number
  return newReq.getSvrId().getSequenceNumber().intValue();
}