public String insert_master_detail() {
BindingContainer bindings = getBindings();
OperationBinding operationBinding =
bindings.getOperationBinding("Commit");
Object result = operationBinding.execute();
//Perform a commit on the master table binding on page view
if (operationBinding.getErrors().isEmpty()) {
//if transaction succeeded then continue adding data to detail
table
String amDeff = "model.AppModule";
String config = "AppModuleLocal";
ApplicationModule am =
Configuration.createRootApplicationModule(amDeff, config);
ViewObject vo = am.findViewObject("DetailTabke1");
//connect to the detail view using the application module
BindingContainer bc =
BindingContext.getCurrent().getCurrentBindingsEntry();
//get the current page bindings
JUCtrlAttrsBinding Code =
(JUCtrlAttrsBinding)bc.get("Code");
JUCtrlAttrsBinding Name =
(JUCtrlAttrsBinding)bc.get("Name");
//get list of data added to the master table that will be add to
the detailed table
NameValuePairs pairs = new NameValuePairs();
pairs.setAttribute("Code",
Code.getAttributeValue().toString());
Number n=new Number(1);
pairs.setAttribute("No", n);
pairs.setAttribute("Name",
Name.getAttributeValue().toString());
pairs.setAttribute("Status", "00020");
pairs.setAttribute("Typee", "051");
pairs.setAttribute("StartDate", "1430/01/01");
pairs.setAttribute("EndDate", "1430/01/01");
Row ActivityTaskRow = vo.createAndInitRow(pairs);
vo.insertRow(ActivityTaskRow);
//create a Name value attribute and calling createAndInitRow
with name value attributes for detailed table that will be
used to insert row in table
am.getTransaction().commit();
//commit the transaction and then release the connection
Configuration.releaseRootApplicationModule(am,true);
}
return null;
}
This code is added as an action to submit button and should be called after creating a new row in the master table.