Parameters
Data Aware Forms are based on statements. As with other topics in this chapter, this is not form specific, instead it is a functionality inherited from the underlying com.sun.star.sdb.RowSet. Statements contain parameters where some values are not specified, and are not dependent on actual values in the underlying tables. Instead they have to be filled each time the row set is executed, that is, the form is loaded or reloaded.
A typical example for a statement containing a parameter is
SELECT * FROM SALES WHERE SALES.SNR = :salesman
There is a named parameter salesman
, which is filled before a row set based on a statement is executed. The orthodox method to use is the com.sun.star.sdbc.XParameters interface, exported by the row set.
However, forms allow another way. They export the com.sun.star.form.XDatabaseParameterBroadcaster interface that allows your component to add itself as a listener for an event which is triggered whenever the form needs parameter values.
In a form, filling parameters is a three-step procedure. Consider a form that needs three parameters for execution.
- The master-detail relationship is evaluated. If the form's parent is a com.sun.star.form.component.DataForm, then the
MasterFields
andDetailFields
properties are evaluated to fill in parameter values. For an example of how this relationship is evaluated, refer to chapter Sub Forms. - If there are parameter values left, that is, not filled in, the calls to the com.sun.star.sdbc.XParameters interface are examined. All values previously set through this interface are filled in.
- If there are still parameter values left, the com.sun.star.form.XDatabaseParameterListeners are invoked. Any component can add itself as a listener using the com.sun.star.form.XDatabaseParameterBroadcaster interface implemented by the form. The listeners then have the chance to fill in anything still missing.
Unfortunately, Apache OpenOffice Basic scripts currently cannot follow the last step of this procedure - there is a known implementation issue which prevents this.
Content on this page is licensed under the Public Documentation License (PDL). |