Dive into BC4J and ADF

Send me a mail
 Dive into BC4J and ADF    Click to see the XML version of this web page.   (Updated: 6/3/2006; 11:49:51 AM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper 10g

Search blog with Google:
 

Search BC4J JavaDoc:
 

October 2003
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Sep   Nov

Get Firefox!

Wednesday, October 29, 2003

Merrill writes in with the following question:

I have a view link between 2 view objects in a one to one relationship.If the destination row is null and I insert a new row for the destination, how do I get the source to acknowledge that a new row has been inserted. In other words, when I use the accessor to get the destination view object row it is null even after a new row has been inserted.

The short answer is, "You need to make sure the jbo.viewlink.consistent property is set to the value true in your configuration." You also should be running the JDeveloper 9.0.3.3 maintenance release because there were problems with this functionality working correctly in all scenarios before this latest release.

Here's a OneToOneViewLink.zip archive containing the OneToOneViewLink.jpr project and supporting files. The TestClient.java class illustrates a simple console client program that shows how this feature works.

/**
 * This example illustrates inserting a new "ThingOneRow" and a new
 * "ThingTwoRow" and since ThingOneRow is viewlinked one-to-one with
 * ThingTwoRow, I can use the view link accessor on the ThingOneRow
 * to retrieve the related ThingTwoRow.

 */
public class TestClient {
  public static void main(String[] args)  {
    String _am = "test.TestModule", _cf = "TestModuleLocal";
    ApplicationModule am = Configuration.createRootApplicationModule(_am,_cf);
    ViewObject thingOneVO = am.findViewObject("ThingOne");
    ViewObject thingTwoVO = am.findViewObject("ThingTwo");
    /*
     * Create a new ThingOneRow using strongly typed row interface
     */
    ThingOneRow newOne = (ThingOneRow)thingOneVO.createRow();
    newOne.setId(new Number(10));
    newOne.setName("Sample1");
    /*
     * Create a new ThingTwoRow using strongly typed row interface
     * Note that we're setting the "ThingOneId" == 10 so it's related
     * to the new ThingOneRow we're creating by the foreign key.
     */
    ThingTwoRow newTwo = (ThingTwoRow)thingTwoVO.createRow();
    newTwo.setId(new Number(11));
    newTwo.setName("Sample2");
    newTwo.setThingOneId(new Number(10));
    /*
     * Use the view link accessor attribute to return a the
     * one-to-one related ThingTwoRow that's related to this ThingOneRow.
     */   
    ThingTwoRow relatedTwo = (ThingTwoRow)newOne.getThingTwo();
    if (relatedTwo == null) {
      System.out.println("You must set jbo.viewlink.consistent = true in\n"+
                         "your configuration for this to work for new rows.");
    }
    else {
      System.out.println("The name of my 1-to-1 associated thing two is " +
                          relatedTwo.getName());
    }
    Configuration.releaseRootApplicationModule(am,true);
  }
}

7:45:13 PM    



© Copyright 2006 Steve Muench.