When you work with master detail forms in JClient, you may want to allow the user to display multiple instances of the detail form at the same time. Or, you may want the user to be able to open and close the same detail form multiple times. In the first case, you need to create unique panel binding instances and set them on the application's binding container. In the second case, you can reuse the same panel binding but must release the view components so they can be rebound.
Opening Multiple Instances of the Same Form
When you want the user to open multiple instances of the same form, you will need to specify a unique panel binding name to avoid recreating new instances of the panel binding with a name that is already in use. For example, in your main frame you can define a method to supply unique panel binding names:
int count = 0;
private DCBindingContainer createDetailBinding()
{
String detail2BCName = "DetailFormUIModel"+count;
if (panelBinding.getBindingContext().get(detail2BCName) == null)
{
DCBindingContainerDef bcdef = DCBindingContainerDef.findDefObject("adf.pm.testcase.view.DetailFormUIModel");
DCBindingContainer bc = bcdef.createBindingContainer(panelBinding.getBindingContext());
bc.setName(detail2BCName);
panelBinding.getBindingContext().put(detail2BCName, bc);
++count; //make sure the next name is unused thus far.
return bc;
}
return null;
}
The event handler for the open window button needs to set the new panel binding on the binding context:
private void jButtonOpen_actionPerformed(ActionEvent e)
{
DetailForm df = new DetailForm();
df.setBindingContainer(createDetailBinding());
df.setVisible(true);
}
Finally, in the form to be displayed multiple times, get the binding context that contains the new panel binding instance:
public void setBindingContainer(DCBindingContainer ctr)
{
panelBinding = (JUPanelBinding)ctr;
setBindingContext(ctr.getBindingContext());
}
Opening and Reopening the Same Form Multiple Times
In the case where you want the user to be able to display a form, close
the form, and reopen it multiple times, the createDetailBinding()
method as shown above is simplier because it does not need to specify a
unique panel binding name.
private void createDetailBinding()
{
String detail2BCName = "Detail2FormUIModel";
if (panelBinding.getBindingContext().get(detail2BCName) == null)
{
DCBindingContainerDef bcdef = DCBindingContainerDef.findDefObject("adf.pm.testcase.view.Detail2FormUIModel"); //NOTE THE NAME.
DCBindingContainer bc = bcdef.createBindingContainer(panelBinding.getBindingContext());
bc.setName(detail2BCName);
panelBinding.getBindingContext().put(detail2BCName, bc);
}
}
In the detail form, the event handler for the close button needs to release the view components. This will allow the next form to reuse the panel binding so it can be rebound.
private void jButtonClose_actionPerformed(ActionEvent e)
{
panelToReuse1.getPanelBinding().release(DCDataControl.REL_VIEW_REFS);
panelBinding.release();
panelBinding.getBindingContext().remove(panelBinding.getName());
this.dispose();
}
About the JClient Application Code
About Data Binding in JClient Application
Opening a JClient Form with an Action Handler
Copyright © 1997, 2004, Oracle. All rights reserved.