OracleArea51

Sponsored By Chola Global Services LLC

Oracle Style Master Detail Page without using As and VL

E-mail
(2 votes, average 4.00 out of 5)

To implement Master detail Page, we need to implement following functionalities:
1. Query lines whenever you are querying Header information
2. While creating New record Foreign key values should be passed from header to lines
3. Whenever we are going to delete header record, lines should also be deleted.
4. Like Oracle Style Forms it used to show some lines in detail block, same thing I've also implemented, whenever you want to    create new record it will show you 5 blank rows.

To Query Lines with header, I wrote one method in which I'm querying both header as well as Lines to ensure that I'm not going to miss Query lines whenever I'm querying header.

following piece of code used to achieve this:

   public void initTableQuery(String s )
   {
      OAViewObject voh = getSuppliersVO1();
      OAViewObject vol = getSupplierSitesVO1();
      voh.setWhereClause(null);
      voh.setWhereClause("suppliersEO.Supplier_Id = "+s);
      voh.executeQuery();
      vol.setWhereClause(null);
      vol.setWhereClause("Supplier_id = "+s);
      vol.executeQuery();
  } 

To Show Five empty rows in detail block, whenever I'm creating new row in header along with that I'm creating creating five rows in lines VO.
     am.invokeMethod("createSupplier");
     for(int i =1;i<=5;i++)
      am.invokeMethod("createSupplierSite");

If I'm going to delete header along with that I'm deleting all the rows related to that header, In my case if I'm deleting Supplier along with supplier, supplier sites will also

be deleted.

   public void deleteSupplier()
   {
    OAViewObjectImpl voh = getSuppliersVO1();
    OAViewObjectImpl vol = getSupplierSitesVO1();
    SuppliersVORowImpl rowh = (SuppliersVORowImpl)voh.getCurrentRow();
    System.out.println(rowh.getSupplierId());
    if(rowh.getSupplierId()!= null)
    {
    rowh.remove();
    Row row[] = vol.getAllRowsInRange();
    for (int i=0;i<row.length;i++)
    {
      SupplierSitesVORowImpl rowi = (SupplierSitesVORowImpl)row[i];
      rowi.remove();
    }
   apply(); 
   createSupplier();
   for(int i= 1;i<=5;i++)
     createSupplierSite();
   }
   }

To Link lines with header I need to pass Supplier Id to Lines block, as I'm having 5 blank rows so I can not assign Supplier Id to supplier site, if user has not filled the data in particular line. I assumed that user has to fill Supplier Site name, if it is not filled that that row should not be saved in database. So I'm assigning supplier Id to only those rows where Supplier site name is not null.
This code handles two cases:
1. Insert: Supplier Id and Supplier Site Id will be generated from sequence, Supplier Id will be assigned to header and then same Supplier Id will be assigned to lines.
2. Update: Supplier Id is already is there i.e, Supplier already exists and we are adding new supplier site to supplier then we'll take Supplier Id and assign it to supplier site.
Supplier Id will be attached only to those lines which we r creating(new supplier sites)

  
 public void assignIdstoLines()
   {
    Number SupplierId;
    OADBTransaction transaction = getOADBTransaction();  
    OAViewObjectImpl vo = getSupplierSitesVO1();
    OAViewObjectImpl voh = getSuppliersVO1();
    System.out.println(voh.getCurrentRowIndex());
    SuppliersVORowImpl rowh = (SuppliersVORowImpl)voh.getCurrentRow();
    if(rowh.getSupplierId()!=null)
       SupplierId = rowh.getSupplierId();
    else
       SupplierId = transaction.getSequenceValue("AK.FWK_TBX_SUPPLIERS_S");
    rowh.setSupplierId(SupplierId);
    Row row[] = vo.getAllRowsInRange();
    for (int i=0;i<row.length;i++)
    {
     SupplierSitesVORowImpl rowi = (SupplierSitesVORowImpl)row[i];
     if (rowi.getSupplierId()== null)
     {     
     if(rowi.getSiteName()!=null && !("".equals(rowi.getSiteName().trim())))
     {
      rowi.setSupplierId(SupplierId);
      Number SupplierSiteId = transaction.getSequenceValue("AK.FWK_TBX_SUPPLIER_SITES_S");
      rowi.setSupplierSiteId(SupplierSiteId);
     } 
     }
    }
   }

If you find any problem or you are not able to understand anything pls let me know.

How to use these Pages: Run search Page, query the data what ever supplier you want to select clink on that name it will take you to editable Page with details there you can modify anything. if you want to create new supplier click on button "Create New", it will take you to editable page.

Note: This code is just to give some idea how to develop Master detail Page, so few things I have not handelled in this. I have not put any validations.

Points: 0
Contact Author | Website :
 
Attachments:
Download this file (MD.zip)Oracle Style Master Detail Page[ ]27 Kb45 Downloads

Related Posts:

relatedArticles
Trackback(0)
Comments (4)add comment

Anshu Joshi said:

Anshu Joshi
...
...
Hi,

I have some doubts.
(1) How can I specify the type of request(GET or POST).

(2) When I create row in a view object,after this when I try to sort a column or press a GO button to query the data ,in table region,I get the error that table has pending changes.You can not apply the search.

What is the cause of the error and what action I should take to avoid the above error.

Any help is highly appreciated.


Thanks & Regards,
Anshu Joshi
 
August 25, 2009
Votes: +0

Reetesh Sharma said:

0
...
Hi Anshu,

As per my understanding and knowledge GET will be used when page will be loaded for very first time and after that it is POST.

You are getting this error because you created a row but not yet committed or rolled back.

Regards,
Reetesh Sharma
 
August 25, 2009
Votes: +1

Venkat Reddy Pulichintha said:

Venkat Reddy Pulichintha
...
Dear Reetesh Sharma

Really Good example. I appricate your cooperation and work.

Can you tell me where i have to write the code for item validation. like if supplier is exist while entering the supplier i want to show the message like this already exist please verify.

if you have any sample code pleaes send me other wise explain me where i have to write the code according that i will write the code.

Thanks
Venkat Pulichintha
 
August 26, 2009
Votes: +0

Reetesh Sharma said:

0
...
Hi,

Here is the sample code for checking for unique constarint, these type of validations should be placed in set methods

public void setEmployeeId(Number value)
{
// Because of the declarative validation that you specified for this attribute,
// BC4J validates that this can be updated only on a new line, and that this
// mandatory attribute is not null. This code adds the additional check
// of only allowing an update if the value is null to prevent changes while
// the object is in memory.
if (getEmployeeId() != null)
{
throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(), // EO name
getPrimaryKey(), // EO PK
"EmployeeId", // Attribute Name
value, // Attribute value
"AK", // Message product short name
"FWK_TBX_T_EMP_ID_NO_UPDATE"); // Message name
}
if (value != null)
{
// Employee id must be unique. To verify this, you must check both the
// entity cache and the database. In this case, it's appropriate
// to use findByPrimaryKey() because you're unlikely to get a match, and
// and are therefore unlikely to pull a bunch of large objects into memory.
// Note that findByPrimaryKey() is guaranteed to check all employees.
// First it checks the entity cache, then it checks the database.
OADBTransaction transaction = getOADBTransaction();
Object[] employeeKey = {value};
EntityDefImpl empDefinition = EmployeeEOImpl.getDefinitionObject();
EmployeeEOImpl employee =
(EmployeeEOImpl)empDefinition.findByPrimaryKey(transaction, new
Key(employeeKey));
if (employee != null)
{
throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(), // EO name
getPrimaryKey(), // EO PK
"EmployeeId", // Attribute Name
value, // Attribute value
"AK", // Message product short name
"FWK_TBX_T_EMP_ID_UNIQUE"); // Message name
}
}
// Note that this is the point at which the value is actually set on the EO cache
// (during the scope of setAttributeInternal processing). If you don't make this
// call after you perform your validation, your value will not be set correctly.
// Also, any declarative validation that you define for this attribute is executed
// within this method.
setAttributeInternal(EMPLOYEEID, value);
} // end setEmployeeId()


Let me know if it is not clear.

Regards,
Reetesh Sharma
 
August 26, 2009
Votes: +0

Write comment

busy