import oracle.jbo.client.Configuration;
import oracle.jbo.*;
import oracle.jbo.domain.Number;
public class Test { public static void main(String[] args) {
String _am = "test.TestModule", _cf = "TestModuleLocal";
ApplicationModule am = Configuration.createRootApplicationModule(_am,_cf);
ViewObject lines = am.findViewObject("TopLevelLineItemView");
/* * You can use createAndInitRow() to supply the needed
* foreign key value to order at line row create time. */
Row newLine = lines.createAndInitRow(new NameValuePairs(new String[]{"Orderid"}, newObject[]{new Number(12345)}));
newLine.setAttribute("Itemid", "CRU-1234");
newLine.setAttribute("Quantity", new Number(1));
lines.insertRow(newLine);
/* * Or else, you can get a row of the parent view */
ViewObject orders = am.findViewObject("OrderView");
/* * Just use the first order in the view as an example */
Row existingOrder = orders.first();
/* * Then get the details iterator via the View Link attribute accessor */
RowIterator linesIter = (RowIterator)existingOrder.getAttribute("LinesItemsForOrder");
/* * Then use this iterator to create the new Line */
newLine = linesIter.createRow();
linesIter.insertRow(newLine);
newLine.setAttribute("Itemid", "XYZ-1234");
newLine.setAttribute("Quantity", new Number(4));
am.getTransaction().postChanges();
/* * Everything worked, so rollback so we don't actually create the new rows */ am.getTransaction().rollback();
Configuration.releaseRootApplicationModule(am,true);
}
}
Wednesday, April 29, 2009
Subscribe to:
Posts (Atom)