Show report parameter value to user from database

Hi,

How can I show the report parameter's value to user from database before selection.

Suppose user have to select Organization id which is a Text value but yet he had not informed which Org_ID 's are available to Database Table.

I want to show those ID's from database table to help him to select according to his desire.
Suppose by pressing F2 key he will see all abailable ID's.

How can I achive this.

I want to draw attention specially JasperSoft to help.


Alauddin
alauddinctgbd's picture
Joined: Aug 4 2006 - 8:37pm
Last seen: 17 years 1 month ago

1 Answer:

you can do it but you will not like my solution, since it's messy


It can be done by injecting some JSP to the
jasperintelligence-1.1.0/apache-tomcat/webapps/jasperserver/WEB-INF/decorators/main.jsp


so you insert the following code in to main.jsp
-------------------------------------------------------------------------------------------------------------------

<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.* "%>

<%
Class.forName("com.mysql.jdbc.Driver");
Connection myConn = DriverManager.getConnection("jdbc:mysql://host/test?user=user&password=pass");
Statement stmt = myConn.createStatement();
ResultSet myResultSet =
stmt.executeQuery("select Id, Name
from SomeTable ;");
if (myResultSet != null) {
int i = 0;
while (myResultSet.next()) {
String db_name = myResultSet.getString("Name");
String db_id = myResultSet.getString("Id");
%> <div> <a href="javascript:setNameId('<%= db_name%>','<%= db_id%>');"> -<%= oname%> </a> </div> <%
}
}
stmt.close();
myConn.close(); %>
----------------------------------------------------

now you have list of names that link to the appropriate field setters ....
...
implement the setNameId, which set values to the input controlles you defined in report
----------------------------------------------------
<script>
function setSiteAndOperator(site_text, operator_text) {
document.getElementById("input_name").value=text;
document.getElementById("input_id").value=text;
}
</script>
------------------------------------------------------

hide the widget if we have no input control variable
-------------------------------------------------------
<script>
if ( document.getElementById("input_name") == null ) {
document.getElementById("widget_menu").style.visibility = "hidden";
}
</script>
-------------------------------------------------------
sofra's picture
2
Joined: Jul 19 2006 - 3:29am
Last seen: 17 years 2 months ago
Feedback
randomness