A customer has a system where some master row has a view-linked detail that will either have one row or zero rows in it. He asked me how you could automatically create a detail row in the case that there wasn't one already there. We sat down and worked out the following code to implement the solution in an overridden processComponentEvents() method of his data page's DataForwardAction class:
protected void processComponentEvents(DataActionContext ctx) throws Exception { super.processComponentEvents(ctx); DCBindingContainer bc = ctx.getBindingContainer(); DCIteratorBinding iter = bc.findIteratorBinding("EmpView2Iterator"); /* if current row in detail iterator is null... */ if (iter.getCurrentRow() == null) { /* Invoke a "Create" action binding to create a blank one */ ((JUCtrlActionBinding)bc.findCtrlBinding("Create")).invoke(); } }
10:50:44 AM
|