|
|
Re: Changing the &XML Data Source File dynamically [message #652387 is a reply to message #652353] |
Thu, 03 February 2011 17:33 |
|
Mike,
You can set any datasource property in the beforeOpen like:
extensionProperties.odaURL = "jdbc:mysql://localhost/mysql";
where odaURL is the property you are interested in changing.
You can use the xml view if you are not sure what the property name is.
But if the datasource is already opened like for the parameter this
approach will not work.
Jason
On 2/3/2011 11:23 AM, Mike Wulkan wrote:
> On further thought, I'm not sure how this can work as parameters are
> obviously processed after the datasource is opened since the default
> values for some of these parameters are taken from the data.
>
> So is it even possible to provide the name of the datasource in the
> Report Parameters?
|
|
|
|
Re: Changing the &XML Data Source File dynamically [message #919043 is a reply to message #918302] |
Fri, 21 September 2012 16:20 |
|
Sure. There are several ways this can be done. One way is to add a parameter for the property. Then the property binding expression for the property set it to params["yourparam"].value or use a beforeOpen script like:
this.property = params["yourparam"].value; Then in the run and render task just make sure to set the parameter value like task.setParameterValue("yourparam", "youpropertyvalue"); If you do not want to use a parameter put the value in the appcontext like task.getAppContext().put("yourpropname", "yourpropvalue" ); then in the beforeOpen script use this.property =reportContext.getAppContext().get("yourpropname");
Jason
|
|
|
Re: Changing the &XML Data Source File dynamically [message #919054 is a reply to message #919043] |
Fri, 21 September 2012 16:37 |
Randy Evered Messages: 16 Registered: July 2012 |
Junior Member |
|
|
Jason,
That will allow me to choose the data source from within Java (if the Data Source already exists)? Sweet! I am not sure if I was clear what I needed or not (LOL sounds too easy).
What is "property"? Do I need to specify another property name, or a generic "property" will work? I am a bit new to properties and parameters. Although I have been reading about parameters.
Thanks for your help!
Randy
[Updated on: Fri, 21 September 2012 16:39] Report message to a moderator
|
|
|
Re: Changing the &XML Data Source File dynamically [message #919099 is a reply to message #919054] |
Fri, 21 September 2012 17:24 |
|
You can look at the xml view of the report and find the property of the data source/set you want to change. It will have a name like odaURL. This is the property I mean. You will see all the settable properties in the property binding toc entry when you open the data set/source in the designer. You can use code like:
this.setProperty("propertyname", "propertyvalue); if the property does not have a native setter method in the beforeOpen script.
Jason
|
|
|
Re: Changing the &XML Data Source File dynamically [message #919338 is a reply to message #919099] |
Fri, 21 September 2012 23:03 |
Randy Evered Messages: 16 Registered: July 2012 |
Junior Member |
|
|
Jason,
Would this work too (on the report side)?
path = reportContext.getAppContext().get( "myParameter" );
this.getDataSource( "Data Source" ).setPrivateDriverProperty( "HOME", path );
If I set myParameter in the appContext in Java, and HOME is the property of the Data Source? They had it in the beforeFactory section.
I am just looking around at DevShare in birt-exchange because I am stuck on EMF ODA queryText problem.
I got it from: http: //www.spudsoft.co.uk/2011/10/lsned43-how-to-have-relative-path-in-a-flat-file-data-source-in-birt/
Thanks,
Randy
[Updated on: Fri, 21 September 2012 23:10] Report message to a moderator
|
|
|
|
|
|
Re: Changing the &XML Data Source File dynamically [message #925383 is a reply to message #924520] |
Thu, 27 September 2012 17:09 |
|
If you put this in your JavaScript for the report:
path = reportContext.getAppContext().get("dataSource");
reportContext.getDesignHandle().findDataSource("ExampleEcore").setProperty("resource", path);
in Java you should be putting dataSource in like:
runTask.getAppContext().put("dataSource", "yourdatasource");
Jason
|
|
|
|
Re: Changing the &XML Data Source File dynamically [message #934152 is a reply to message #933173] |
Fri, 05 October 2012 18:02 |
|
What error are you getting? In the beforeFactory add something like the following:
var tst = reportContext.getDesignHandle().findDataSource("ExampleEcore").getProperty("resource");
var path = reportContext.getAppContext().get("dataSource");
importPackage( Packages.java.io );
out = new PrintWriter( new FileWriter( "c:/temp/debugreport.txt", true ) );
out.println( "Prop " + tst + "-- appcontext value " + path);
out.close();
Jason
|
|
|
Powered by
FUDForum. Page generated in 0.06659 seconds