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:52 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!

Thursday, October 30, 2003

We can automatically figure out whether rows need to be updated or inserted from the XML message, but for delete we need an additional hint. This hint is the bc4j-action attribute. In the following simple example we read the XML message from a local String variable, then pass it to ViewObject.readXML. Notice the bc4j-action='remove' attribute on the <EmployeesRow> to indicate that we want that row to be deleted. At a minimum, the element representing the primary key attribute of the row -- in this case <Empno> -- must be present in the message to know which row to act on. In general, the XML message can have any number of elements which can represent inserts, updates, and deletes (with the appropriate bc4j-action='remove' marker), even at multiple levels of nesting. Here's the sample code.

package test;
import java.io.StringReader;
import oracle.jbo.ApplicationModule;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
import oracle.xml.parser.v2.DOMParser;
import org.w3c.dom.Element;
public class TestClient  {
  private static final String XML =
  "<Employees>"+
  "   <EmployeesRow bc4j-action='remove'>"+
  "     <Empno>7839</Empno>"+
  "   </EmployeesRow>"+
  "</Employees>";
  public static void main(String[] args) throws Throwable {
    String        amDef = "test.TestService";
    String        config = "TestServiceLocal";
    ApplicationModule am =
    Configuration.createRootApplicationModule(amDef,config);
    ViewObject vo = am.findViewObject("EmpView");
/*
* Parse the XML string into an XMLDocument
*/
    DOMParser d = new DOMParser();
    d.parse(new StringReader(XML));
    Element e = d.getDocument().getDocumentElement();
/*
* Have the VO read the XML message and act on it
*/
    vo.readXML(e,-1);
    am.getTransaction().commit();
    Configuration.releaseRootApplicationModule(am,true);
  }
}

9:29:24 AM    



© Copyright 2006 Steve Muench.