|
Re: skip ODA lib script in design time [message #731953 is a reply to message #731826] |
Mon, 03 October 2011 14:42 |
|
Paulo,
Try wrapping in an if with this statement:
if(
!reportContext.getHttpServletRequest().getAttribute("attributeBean").isDesigner()){
}
Jason
On 10/3/2011 4:52 AM, Paulo wrote:
> Hello i Have this script in my Library on (before open) ODA
>
>
> importPackage( Packages.java.lang );
> importPackage( Packages.java.util );
> importPackage( Packages.javax.servlet.http);
>
> httpServletReq = reportContext.getHttpServletRequest();
> session = httpServletReq.getSession(); if (
> reportContext.getHttpServletRequest().getParameter("urlB") != null &&
> reportContext.getHttpServletRequest().getParameter("usrB") != null &&
> reportContext.getHttpServletRequest().getParameter("pasB") != null
> ) {
>
> this.setExtensionProperty("odaURL",
> reportContext.getHttpServletRequest().getParameter("DatabaseUrl"));
> this.setExtensionProperty("odaUser",
> reportContext.getHttpServletRequest().getParameter("DatabaseUserName"));
> this.setExtensionProperty("odaPassword",reportContext.getHttpServletRequest().getParameter("DatabasePassword"));
> }
>
> if ( reportContext.getHttpServletRequest().getParameter("DatabaseJndi")
> != null)
> {
>
> // set the birt variable jndi to the jndi url parameter
> this.setExtensionProperty("odaJndiName",
> reportContext.getHttpServletRequest().getParameter("DatabaseJndi"));
> }
> if ( session.getAttribute("sessionJndi") != null &&
> session.getAttribute("sessionJndiPrivilege") != null )
> { }
>
> // if all of this fail the birt report will try to execute with the
> development variables set on the report it self.
>
> true;
>
>
>
>
> it works fine on the web container getting the jndi connection from the
> session, but in design (Eclipe ou BIRT RCP DESIGNER ) time when on the
> data set - query the output columns it crash.
>
> Of course because of the reportContext.getHttpServletRequest not
> available in design time on the eclipse.
>
> Can some one please help me find a way of knowing when i'm in design
> time (ECLIPSE BIRT RCP DESIGNER) and skip this javascipt block , and not
> in the web container ?
>
>
> Thanks in advance
> Paulo Costa
>
>
>
|
|
|
|
|
|
|
Re: skip ODA lib script in design time [message #734093 is a reply to message #734034] |
Thu, 06 October 2011 16:11 |
|
When are you getting this type:
org.eclipse.birt.report.data.adapter.api.script.ReportContextObject
Specifically what script and how are you running it?
Jason
On 10/6/2011 8:52 AM, Taras Kopets wrote:
> Yesterday I found your post, which is very similar to one I had before
> and you already mentioned it (link to birt-exchange).
>
> I devoted some time yesterday investigating this issue and found out the
> solution which works.
>
> I found out that when error happens the
> reportContext.getClass().getName() is different.
>
> When reportContext class is
> org.eclipse.birt.report.data.adapter.api.script.ReportContextObject then
> I get the exception,
> and when reportContext class is
> org.eclipse.birt.report.engine.script.internal.ReportContextImpl then
> everything is fine and we can safely use reportContext methods.
>
> Maybe there is other elegant way to fix this, until then
> adding some more checks leads to working code without errors.
>
>
> // Packages.java.lang.System.out.println("---- reportContext class name
> ----");
> //
> Packages.java.lang.System.out.println(reportContext.getClass().getName());
> // Packages.java.lang.System.out.println("-------------- END
> ---------------");
> // OK - "org.eclipse.birt.report.engine.script.internal.ReportContextImpl"
> // FAIL -
> "org.eclipse.birt.report.data.adapter.api.script.ReportContextObject"
>
> if(reportContext.getClass().getName() !=
> "org.eclipse.birt.report.data.adapter.api.script.ReportContextObject") {
> // check if reportContext contains HttpServletRequest if
> (reportContext.getAppContext().containsKey('BIRT_VIEWER_HTTPSERVET_REQUEST'))
> {
> var request = reportContext.getHttpServletRequest();
> // check if request is valid
> if (request != null) {
> if (!request.getAttribute("attributeBean").isDesigner()) {
> var myresourcefolder = reportContext.getDesignHandle().getResourceFolder();
> this.setExtensionProperty("OdaConnProfileStorePath",
> myresourcefolder+"/profilestore.xml");
> this.setExtensionProperty("OdaConnProfileName",
> params["rpStrConnProfile"].value);
> }
> }
> }
> }
>
>
> I hope you can easily modify my example to resolve your issue.
> Let me know if this helps.
>
> Regards,
> Taras
|
|
|
|
Re: skip ODA lib script in design time [message #734118 is a reply to message #734112] |
Thu, 06 October 2011 18:09 |
|
Understood. I do not see an easy way around this.
On 10/6/2011 1:51 PM, Taras Kopets wrote:
> Hi Jason,
> This error happens when I edit dataSET in library.
> The script is used in "beforeOpen" of dataSOURCE in the same library.
>
> Edit dataset means: Open dataset, press "preview results" then "OK".
> When you press OK, you will get
> org.eclipse.birt.report.data.adapter.api.script.ReportContextObject
> possibly several times in a row.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03620 seconds