Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 124950

Summary: [Scripting usability] ability to use an expression as default parameter value
Product: z_Archived Reporter: Vladimir <vladperl>
Component: BIRTAssignee: Haojun Chu <hchu>
Status: VERIFIED FIXED QA Contact: Maggie Shen <lshen>
Severity: enhancement    
Priority: P3 CC: belcore_walter, bluesoldier, etiennel, jerlich, kvenkatraman, rkanguri, thibaudr, whe, zqian
Version: unspecifiedKeywords: plan
Target Milestone: 2.5.0 M6   
Hardware: All   
OS: All   
Whiteboard: Autoed
Bug Depends on:    
Bug Blocks: 264273    

Description Vladimir CLA 2006-01-23 17:20:46 EST
The ability to use an expression as default parameter value has been removed from designer. I believe in many cases it's useful to provide that functionality.
In many cases reports use current date and time (directly or indirectly) to define params values. Also sometimes needs to put in parameters values origin from user environment such as data related to browser or operating system.
Beside that values of parameters can be depend on other more complicated factors like values from other dataset or parameters.
Comment 1 Wenfeng Li CLA 2006-02-02 22:21:03 EST
A couple of alternatives:
1. Parameter selection list can specify the default value on that list.
2. Use custom parameter collection UI, where the default values can be completely customized.
3. support scripting on parameter objects, for example, allow script of getDefaultValue() and getSelectionList() on a parameter object.

Comment 2 belcore CLA 2006-03-08 06:38:55 EST
very important future.
I hope that this wil be correct into next version.
Comment 3 Etienne Lacombe CLA 2006-06-14 20:50:19 EDT
Any news on this? This is very important, specifically with dates parameters where one would want to default to Today and Yesterday!
Comment 4 Thibaud Raison CLA 2006-11-08 09:07:28 EST
Any news about this feature ?

For a DateTime parameter, when the defaultValue comes from a dataSet, there is no workaround to propose to the user a correct and dynamic default value in a text box.
It's really a problem.
Maybe it's coverred by another feture planned in 2.1.2 or 2.2 ?

Thnaks to explain.
Comment 5 Zhiqiang Qian CLA 2008-02-20 21:25:19 EST
*** Bug 219421 has been marked as a duplicate of this bug. ***
Comment 6 Zhiqiang Qian CLA 2008-04-08 03:35:55 EDT
*** Bug 222330 has been marked as a duplicate of this bug. ***
Comment 7 Rima Kanguri CLA 2009-01-23 13:37:13 EST
BIRT Designer
1) BIRT parameter dialog – Default value UI will be enhance to support expressions. When the expression builder is invoked from this page, it does not show  following  - 'Report parameters' ,  'Available Data Sets'  and ‘Available Column Bindings’ nodes, as they are not available in the default value scope. User can write expressions but has not access to data or other report parameters.

2) Scripting enhancement
Currently the report parameter script supports following method - "validate'
We will enhance the scripts to support following additional methods 
a) getDefaultValue()
// User can implement this method to return default value. Note we have another bugzilla planned to support multiple default values, this method should support multiple default values if the other change is made.

b) getSelectionValuelist()
// User can implement this method to provide the value list. This method is only called for 'list', 'combo' control parameter type 
If a user sets the default value and also implements the method, the  method value overrides the value set in parameter dialog

BIRT Engine
- We will use modified model 2, what that  means is the execution sequence is fixed and it is done once.
- During intialization of IGetParamterDefnTask - The getDefaultValue/getSelectionList() is called and the default value is generated one time and subsequently used when user calls engine API
Like IGetParameterDefnTask.getDefaultValue(String name);
- During intitalization of IRunTask/IRunAndRenderTask – The getDefaultValue/validate() is evaluated ones and used subsequently.

BIRT model
How does the user define the the validate()/getDefaultValue()/getSelectionValuelist(), as the expression or script?  If we define them as expressions, we need three expressions in the report: validate, defaultValue and selectValueList. Those expressions can’t share the common variable and functions with each other. If we define them as function, we can define them in one script segment. Those methods can share the variable and functions with each other. In current design, we define the “validate” as the expression, so if we prepare to define them as functions, MODEL need wrap the old validate expression to a new function.
[ Rima – I think we should adopt the new approach, i.e. to use script with 3 functions ]
Comment 8 Rima Kanguri CLA 2009-01-23 13:38:37 EST
Reassigning to engine team to make the changes first
Comment 9 Haojun Chu CLA 2009-03-06 05:05:07 EST
I've a question.
It's ok to apply getSelectionValueList() to a simple parameter. But for a cascading parameter group which binds to datasets, how to fit the SelectionValueList into the dataset values? Like the following:
Cascading Parameter:
Param A --> binds a dataset column
    Param B --> binds a datasetcolumn, also has a SelectionValueList
        Param C --> binds a dataset column

I don't have any idea to handle this. Do you have any idea? Or it's ok to disable Scripting on the cascading parameter?

Thanks,
Haojun
Comment 10 Haojun Chu CLA 2009-03-10 04:10:14 EDT
Fixed. Checked in on Mar 10.
Comment 11 Maggie Shen CLA 2009-03-17 01:17:16 EDT
verified on build 2.5.0 v20090317-0630.