Jump to content

Insert sql statement in Expression editor


javi_123

Recommended Posts

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

how do you use scriplet through iReports?? i havnt done it before, could you please provide an example??

 

I need to add a license agreement page for out external customers. As soon as the user logs in, the license agreement page should appear which will contain information about the terms and conditions. If the user agrees with the terms and conditions, then the link should direct the user to the home page. If the user disagree, then the link should logout the user from the session.

 

I have created a report unit from iReports and have changed the following URL in jasperserver-servlet-pro.xml source file:

ROLE_USER|redirect:/flow.html?_flowId=viewReportFlow&reportUnit=/public/SRA/View/LicensePage

 

When a user logs in, license page appears instead of home page.

 

In the report unit I have added two links:

1: Agree 2: Disagree

Both the links work accordingly. When a user clicks on Agree link, it then redirects the user to home page and if user clicks on Disagree link, it logs the user out.

 

Now, if the user has agreed with the terms and conditions, the license page should not appear second time which it does at the moment. In the report query I have tried to use an insert statement but I think iReports doesn¿t allow the insert statement in the report query.

 

All I need to know is how can we redirect the user to home page once the user has agreed with terms and conditions??

 

WE are using iReports V3.5.2 and JasperServer V3.5.1 on SUSE Linux Enterprise Server Version 10, Service pack 2 with Mysql 5.

 

If there is any other alternative method to do it, please let me know about that

 

Many Thanks

javi

Link to comment
Share on other sites

I have already posed it on jasperserver forums but i havnt received any kind of reply from the jasperserver guru's. I think they randomly choose the threads to reply on, otherwise they would have definitely replied to my thread.

Have you added this kind of functionality before?

 

Regards

Javi

Link to comment
Share on other sites

Not sure what you want to do, but a trick to execute code in iReport is to put an element (i.e. in the title) with a print when expression like:

com.mycompany.MyClass.myMethod()

myMethod is a static public method of com.mycompany.MyClass which is a class that must be in the classpath. The method should return Boolean. FALSE so the printWhen expression result false and the element is not printed. Inside the method you can put all the code you want.

An example:

public class MyClass {

 public static Boolean myMethod(java.sql.Connection c)
{

     .... code to insert a record using the connection ....

    return Boolean.FALSE;

}

}

 

the print when expression should be something like:

com.mycompany.MyClass.myMethod($P{REPORT_CONNECTION})

 Giulio

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...