Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Redirecting BIRT Response to 404(Redirecting BIRT Response to 404)
Redirecting BIRT Response to 404 [message #699603] Thu, 21 July 2011 21:58 Go to next message
paula.mcdowell is currently offline paula.mcdowell
Messages: 16
Registered: June 2011
Junior Member
Hi, there. I'm using BIRT 2.6.2. In my report design, I have added javascript in my initialize to call a Java object passing it the HttpServletRequest from the report context. The java object does some validation with the HttpServletRequest. I'd like to redirect the user to a 404 Error if the request does not past the validation. Is there a way to do this?

Thank you in advance for you time,
Paula
Re: Redirecting BIRT Response to 404 [message #699940 is a reply to message #699603] Fri, 22 July 2011 15:09 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I am not certain this will work for you but you could set a global
variable in the script and then add a text element with script in it to
auto forward based on the global variable. Take a look at the attached
example. Look at the parameter validation script and the text element.

Jason

On 7/21/2011 5:58 PM, paula.mcdowell wrote:
> Hi, there. I'm using BIRT 2.6.2. In my report design, I have added
> javascript in my initialize to call a Java object passing it the
> HttpServletRequest from the report context. The java object does some
> validation with the HttpServletRequest. I'd like to redirect the user to
> a 404 Error if the request does not past the validation. Is there a way
> to do this?
> Thank you in advance for you time,
> Paula
Re: Redirecting BIRT Response to 404 [message #701991 is a reply to message #699940] Mon, 25 July 2011 20:41 Go to previous messageGo to next message
paula.mcdowell is currently offline paula.mcdowell
Messages: 16
Registered: June 2011
Junior Member
Jason,
This works great for forwarding to another page. Thank you, thank you. The problem is it's still executing the database query. I have a scripted datasource.

I added a global variable as you suggested, and I check it in the initialize event of my report. At that point, if validRequest is false, I want to forward to the error page and stop the backed processing of the report.

Is there anyway to stop the report from executing? I've noticed this thread,696694. I've tried to drop the datasource in the beforeOpen event, but this did not work. Database query was still executed.

Thanks for all your help,
Paula
Re: Redirecting BIRT Response to 404 [message #702016 is a reply to message #701991] Mon, 25 July 2011 21:12 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Drop the table that uses the dataset in the beforeFactory script. If no
report item uses the data the query should not run. Name the table in
the general properties and drop it like:

reportContext.getDesignHandle().findElement("mytable").drop();

Jason

On 7/25/2011 4:41 PM, paula.mcdowell wrote:
> Jason,
> This works great for forwarding to another page. Thank you, thank you.
> The problem is it's still executing the database query. I have a
> scripted datasource.
>
> I added a global variable as you suggested, and I check it in the
> initialize event of my report. At that point, if validRequest is false,
> I want to forward to the error page and stop the backed processing of
> the report.
>
> Is there anyway to stop the report from executing? I've noticed this
> thread,696694. I've tried to drop the datasource in the beforeOpen
> event, but this did not work. Database query was still executed.
>
> Thanks for all your help,
> Paula
Re: Redirecting BIRT Response to 404 [message #702732 is a reply to message #702016] Tue, 26 July 2011 18:22 Go to previous messageGo to next message
paula.mcdowell is currently offline paula.mcdowell
Messages: 16
Registered: June 2011
Junior Member
I got this to work, Jason. Thank you. Another un-related question. And let me know if you want me to start a new thread. Can I instantiate an inner class from the BIRT events?

Re: Redirecting BIRT Response to 404 [message #702840 is a reply to message #702732] Tue, 26 July 2011 21:54 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

what do you mean inner class? Any class in the cp? If so the answer is
yes. If you want to do this from script use the importPackage command.
Assume you have a class in my.package.MyObject use:

importPackage(Packages.my.package);
var tst = new MyObject();

Jason

On 7/26/2011 2:22 PM, paula.mcdowell wrote:
> I got this to work, Jason. Thank you. Another un-related question. And
> let me know if you want me to start a new thread. Can I instantiate an
> inner class from the BIRT events?
>
>
Re: Redirecting BIRT Response to 404 [message #702842 is a reply to message #702840] Tue, 26 July 2011 21:59 Go to previous messageGo to next message
paula.mcdowell is currently offline paula.mcdowell
Messages: 16
Registered: June 2011
Junior Member
Jason,
Yes, sorry. An inner class on the classpath. Let me try this.

Thanks!
Paula
Re: Redirecting BIRT Response to 404 [message #702863 is a reply to message #702842] Tue, 26 July 2011 22:32 Go to previous messageGo to next message
paula.mcdowell is currently offline paula.mcdowell
Messages: 16
Registered: June 2011
Junior Member
Jason,
Moreso like OuterClass.InnerClass innerObject = outerObject.new InnerClass();

Can I instantiate this type of object in the BIRT event handler?

Thank you,
Paula
Re: Redirecting BIRT Response to 404 [message #703400 is a reply to message #702863] Wed, 27 July 2011 14:04 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Paula,

I am not sure I understand what you are trying to do.

Jason

On 7/26/2011 6:32 PM, paula.mcdowell wrote:
> Jason,
> Moreso like OuterClass.InnerClass innerObject = outerObject.new
> InnerClass();
>
> Can I instantiate this type of object in the BIRT event handler?
>
> Thank you,
> Paula
Re: Redirecting BIRT Response to 404 [message #704588 is a reply to message #703400] Thu, 28 July 2011 20:27 Go to previous messageGo to next message
paula.mcdowell is currently offline paula.mcdowell
Messages: 16
Registered: June 2011
Junior Member
Jason,
I'll do my best to explain. And really I have a work around, but I was wondering if inner classes can be created in BIRT scripts.

I have a class A that has method getRows which executes a prepared statement. I iterate through the result set creating objects of class B. What is returned from A.getRows() is an ArrayList of B. B is a public inner class of class A. In Java, I would instance class B as follows:
A.B b = a.new B();

Since my getRows is a List of A.B, I need to be able to create this object in the BIRT script. I really hope I've added some clarity.

Thank you for your time,
Paula
Re: Redirecting BIRT Response to 404 [message #705226 is a reply to message #704588] Fri, 29 July 2011 15:29 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Paula,

Thanks for the clarification. I am not certain Rhino (Which is the
script engine BIRT uses) supports this. As a work around you could
always use a Java event handler and do it in a java class.

Jason

On 7/28/2011 4:27 PM, paula.mcdowell wrote:
> Jason,
> I'll do my best to explain. And really I have a work around, but I was
> wondering if inner classes can be created in BIRT scripts.
>
> I have a class A that has method getRows which executes a prepared
> statement. I iterate through the result set creating objects of class B.
> What is returned from A.getRows() is an ArrayList of B. B is a public
> inner class of class A. In Java, I would instance class B as follows:
> A.B b = a.new B();
>
> Since my getRows is a List of A.B, I need to be able to create this
> object in the BIRT script. I really hope I've added some clarity.
>
> Thank you for your time,
> Paula
Re: Redirecting BIRT Response to 404 [message #708489 is a reply to message #705226] Tue, 02 August 2011 21:49 Go to previous messageGo to next message
paula.mcdowell is currently offline paula.mcdowell
Messages: 16
Registered: June 2011
Junior Member
Thanks a bunch for your time and expertise, Jason.
Re: Redirecting BIRT Response to 404 [message #714549 is a reply to message #703400] Wed, 10 August 2011 19:49 Go to previous messageGo to next message
paula.mcdowell is currently offline paula.mcdowell
Messages: 16
Registered: June 2011
Junior Member
Thanks, Jason.

Is there anyway to get at the HttpServletResponse from the BIRT event handlers? Calling a Java Class, I'd like to authenticate the request. I can easily pass the HttpServletRequest to my Java Class, but I'm missing the HttpServletResponse.

Thanks for your time,
Paula
Re: Redirecting BIRT Response to 404 [message #714866 is a reply to message #714549] Thu, 11 August 2011 14:37 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I do not know of a way to to get the response object, but you can always
forward to another page using some script in text element (client side
script). You could do this conditionally based on a server side variable.

<script type="text/javascript">


function forward() {
var temp = new String(location.href);

location.replace("http://www.google.com");

return false;
}
if( <VALUE-OF>params["forward"].value</VALUE-OF> ){
forward();
}
</script>


Jason

On 8/10/2011 3:49 PM, paula.mcdowell wrote:
> Thanks, Jason.
>
> Is there anyway to get at the HttpServletResponse from the BIRT event
> handlers? Calling a Java Class, I'd like to authenticate the request. I
> can easily pass the HttpServletRequest to my Java Class, but I'm missing
> the HttpServletResponse.
>
> Thanks for your time,
> Paula
Re: Redirecting BIRT Response to 404 [message #726092 is a reply to message #699603] Fri, 16 September 2011 14:30 Go to previous messageGo to next message
marc.marshall is currently offline marc.marshall
Messages: 30
Registered: June 2011
Member
Jason,

I have a situation were I am validating the user that is accessing my Birt Report. If the User is deemed invalid then I would like to display a 403 Error (Forbidden). Is there any way of forcing this error within a Java Event handler? The only object that I have in the report intilization Event Handler is the ReportContext but it does not appear that I can force this Error. Do you have any suggestions?

Thanks in advance for any help and expertise,

Marc M.
Re: Redirecting BIRT Response to 404 [message #726124 is a reply to message #726092] Fri, 16 September 2011 16:00 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Marc,

You can get access to the request object from the ReportContext but not
the response so I do not think there is an easy solution here. One way
may be to add a text element to the top of the report that is dropped in
the beforeFactory if the user is valid. The text element could contain
a simple script (client side) that replaces the current location with an
error page. If the user is not valid drop the other report items, if
they are valid drop the text element. To drop in the beforeFactory,
name you elements and use script similar to

reportContext.getDesignHandle().findElement("mytable").drop();

Jason

On 9/16/2011 10:30 AM, marc.marshall wrote:
> Jason,
>
> I have a situation were I am validating the user that is accessing my
> Birt Report. If the User is deemed invalid then I would like to display
> a 403 Error (Forbidden). Is there any way of forcing this error within a
> Java Event handler? The only object that I have in the report
> intilization Event Handler is the ReportContext but it does not appear
> that I can force this Error. Do you have any suggestions?
>
> Thanks in advance for any help and expertise,
>
> Marc M.
Previous Topic:Custom Emitter
Next Topic:Save a rptdocument during a report is ran
Goto Forum:
  


Current Time: Fri Sep 19 03:53:21 GMT 2014

Powered by FUDForum. Page generated in 0.02172 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software