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
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
1 Answer:
Posted on November 2, 2006 at 4:00am
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>
-------------------------------------------------------
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>
-------------------------------------------------------