Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers 10g (10.1.3.1.0) Part Number B25947-01 |
|
|
View PDF |
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.
Figure 10-16 illustrates the data binding for SRList
page.
ServiceRequestsByStatusIterator
for ServiceRequestsByStatus
view object instance
None
setCurrentRowWithKey
, ExecuteWithParams
related to the ServiceRequestsByStatusIterator
iterator binding
None
None
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
.
None
Figure 10-17 illustrates the data binding for the SRMain
page.
ServiceRequestsIterator
for ServiceRequests
view object instance
ServiceHistoriesIterator
for ServiceHistories
view object instance
None
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
deleteServiceHistoryNotes
invokes deleteServiceHistoryNotes()
method on the SRService
client interface
None
Note: TheSRMain 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. |
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.
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(); } } }
Figure 10-18 illustrates the data binding in the SREdit
page.
ServiceRequestsIterator
for ServiceRequests
view object instance
ServiceRequestStatusListIterator
for ServiceRequestStatusList
view object instance
None
setCurrentRowWithKey
related to the ServiceRequestsIterator
iterator binding
Commit
related to the SRService
data control
cancelEditsToCurrentServiceRequest
invokes cancelEditsToCurrentServiceRequest()
on the SRService
client interface
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}
").
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.
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.
Figure 10-19 illustrates the data binding in the SRSearch
page.
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
None
Execute
, Delete
, Create
related to the SearchServiceRequestsIterator
iterator binding
Find
, First
, Next
, Previous
, Last
, setCurrentRowWithKey
related to the SearchServiceRequestsResultsIterator
iterator binding
None
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}
)
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.
None
Figure 10-20 illustrates the data binding for the SRStaffSearch
page.
StaffListByEmailNameRoleIterator
for StaffListByEmailNameRole
view object instance
StaffListByEmailNameRole_Role
, StaffListByEmailNameRole_EmailAddress
, StaffListByEmailNameRole_TheFirstName
, StaffListByEmailNameRole_TheLastName
ExecuteWithParams
related to StaffListByEmailNameRoleIterator
iterator binding
None
None
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
.
None
Figure 10-21 illustrates the data binding in the SRManage
page.
StaffWithOpenRequestsIterator
for StaffWithOpenRequests
view object instance
ExpertiseAreasIterator
for ExpertiseAreas
view object instance
OpenOrPendingServiceRequestsIterator
for OpenOrPendingServiceRequests
view object instance
ServiceHistoriesForRequestIterator
for ServiceHistoriesForRequest
view object instance
None
setCurrentStaffRowWithKey
(for setCurrentRowWithKey
built-in) related to StaffWithOpenRequestsIterator
iterator binding
setCurrentProblemAndAssigneeRows
invokes setCurrentProblemAndAssigneeRows()
on the SRService
client interface
None
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.
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.
Figure 10-21 illustrates the data binding for the SRSkills
page.
StaffListIterator
for StaffList
view object instance
StaffExpertiseAreasIterator
for StaffExpertiseAreas
view object instance
ProductListIterator
for ProductList
view object instance
None
None
updateSkillsForCurrentStaff
invokes the updateSkillsForCurrentStaff()
method on the SRService
client interface
None
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.
As shown in Example 10-6, the updateSkillsForCurrentStaff()
method performs the following steps:
Clones the list of product ids
Creates a secondary RowSetIterator
to do programmatic iteration over the ExpertiseAreas
Removes rows for current user for products that are not in the list of products ids
Closes the secondary row set iterator when done iterating
Adds new rows for the keys that are left
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 passnull 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. |
Figure 10-23 illustrates the data binding for the SRCreate
page.
GlobalsIterator
for Globals
view object instance
ProductListIterator
for ProductList
view object instance
None
None
cancelNewServiceRequest
invokes the cancelNewServiceRequest
method on the SRService
client interface
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}
").
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. |
As shown in Example 10-7, the cancelNewServiceRequest()
method ensures there is a single blank row in the Globals
view object instance.
Figure 10-24 illustrates the data binding for the SRConfirmCreate
page.
GlobalsIterator
for Globals
view object instance
LoggedInUserIterator
for LoggedInUser
view object instance
None
None
cancelNewServiceRequest
invokes the cancelNewServiceRequest()
on the SRService
client interface
createServiceRequest
invokes the createServiceRequest()
on the SRService
client interface
None
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.
As shown in Example 10-8, the createServiceRequest()
method performs the following basic steps:
Gets the entity definition for ServiceRequest
Creates a new ServiceRequest
entity row (ServiceRequestImpl
class)
Accesses the current row in Globals
as a strongly-typed GlobalsRowImpl
Set the problem description and product ID for new service request
Commits the transaction
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(); }