Included in extensions library (default in Domino 9) there is an 'Object Data Source' feature. Its very handy thing but I cant find any documentation on this. I have a question on 'ignoreRequestParams' property ... what does it mean and how this can be used? By enabling this can URL params be automaticly bound to datasource object properties?
问题:
回答1:
The original two data sources (Domino Document and Domino View) both support a behavior that allows URL query string parameters to override property values. By default, the Document data source, for instance, looks for databaseName
, formName
, and documentId
in the query string; for any of these it finds, the corresponding property is set to the parameter value, regardless of what value that property may have been assigned in the XSP markup.
This behavior can be customized in two ways:
- If the
requestParamPrefix
property is given a non-empty string value, then each property will only be overridden if the URL contains a corresponding parameter that matches the specified prefix plus the property name -- e.g.blog_documentId
,comment_formName
. Values provided via the default parameters (without the matching prefix) will be ignored. - If the
ignoreRequestParams
property evaluates to true, then no properties of the data source will be overridden by the URL, regardless of any query string parameter values. The default value of this property is false, so you must set it to true on a specific data source instance if you want to ensure that the URL will never impact property values for that instance.
None of this behavior, however, has yet been implemented for the Object Data Source. As a result, any values set for the ignoreRequestParams
or requestParamPrefix
properties will have no effect on the behavior of any instance of this type of data source.
Perhaps the reason it has not been implemented is because the Object Data Source is entirely arbitrary, so there's no predefined assumption that any instance of it will support specific properties. You define, in the createObject
property of the data source instance, a "method binding" (SSJS function or Java method) that constitutes the business logic for creating the data object. So the resulting object can be anything you want, it can support whatever properties you want, and the logic that determines the initial values for those properties can be anything you want. So you're certainly free to refer to the intrinsic global variable param
within that method binding to take into account any URL parameters you wish when defining the initial state of the data source.
For instance, the following would be a perfectly valid method binding for the createObject
property of an instance of Object Data Source:
return {
firstName: (param.get("firstName") || ""),
lastName: (param.get("lastName") || ""),
email: (param.get("email") || "")
};
This would result in an object that you could bind data components to... for instance, if your var
for the data source was "registration":
#{registration.firstName}
Each property of the object would have a default value if the URL contained a parameter matching the property name.
Naturally, your logic could be far more complex than this: using view and key parameters (instead of a document ID) to retrieve a document and load in field values, querying non-Domino data based on a foreign key identified in the URL... with this type of data source, the sky's the limit precisely because nothing has been defined in advance.