Here we go..
First we have to create a Jsp
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
Example : lets say Optional.jsp is our jsp which should be kept under location in your jasperserver
jasperreports-server-6.2.0\apache-tomcat\webapps\jasperserverpro\WEBINF\jsp\modules\inputControls
In this path you can see DefaultParametersForm.jsp which having empty template-
<%–Include templates–%>
<jsp:include page=”InputControlTemplates.jsp” />
<%– input controls container –%>
<ul class=”list inputControls” id=”inputControlsContainer”></ul>
–so you can add the same in you new jsp and define your own logic
Here I am using the sql Datasource and according to the Query conditon I am displaying or hinding the inputcontrols
Code in Optional.jsp
———————————————————————————————————
<sql:setDataSource var=”snapshot” driver=”org.postgresql.Driver”
url=”jdbc:postgresql://localhost:4242/prasanth”
user=”prasanth” password=”P@ssw0rd”/>
<sql:query dataSource=”${snapshot}” sql=”select * from rooms.library ” var=”result” />
<c:forEach var=”row” items=”${result.rows}”>
<tr>
<td><c:out value=”${row.tenant}”/></td>
</tr>
</c:forEach>
<c:if test =”${ result.rowCount eq 0}”>
–-Here I am using Template mustache for multiselect Inputcontrol Similarly we can use any template
from inputControlTemplates.jsp according to your requirement.
<script id=”multiSelect” type=”template/mustache”>
<div class=”leaf visibleOverflow” id=”{{id}}”>
<div class=”control select multiple” title=”{{description}}”>
<span class=”wrap”>{{#mandatory}}* {{/mandatory}}{{label}}</span>
<div class=”msPlaceholder” {{#readOnly}}disabled=”disabled”{{/readOnly}}></div>
<span class=”warning”>{{message}}</span>
<div class=”resizeOverlay hidden”></div>
<div class=”sizer vertical hidden”><span class=”ui-icon ui-icon-grip-solid-horizontal”></span></div>
</div>
</div>
</script>
–In this below function I am hiding my input control p_library when condition fails
<script>
function showAllData(){
jQuery(‘#inputControlsContainer > div’).each(function( index ) {
if(jQuery( this ).attr(‘id’) == ‘p_library’){
jQuery(this).hide();
}
});
}
jQuery(document).ready(function() {
var checkExist = setInterval(function() {
if (jQuery(‘#inputControlsContainer > div’).length) {
if(jQuery(‘#inputControlsContainer > div’).length == 1)
{
clearInterval(checkExist);
}
showAllData();
console.log(jQuery(‘#inputControlsContainer > div’).length);
}
}, 100);
});
</script>
</c:if >
————————————————————————————————————————-
This is the way you can hide InputControls from the jsp and can set your data source accordingly.
If you want to use MS Sql Server then your sql data source will be like this
<sql:setDataSource var=”snapshot” driver=”com.microsoft.sqlserver.jdbc.SQLServerDriver”
url=”jdbc:sqlserver://localhost:1433;databaseName=Prasanth”
user=”Prasanth1″ password=”Prasanth2016″/>
After jsp page is set In controls & Resources tab we can see the option below as
Optional JSP Location:
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
set path to — modules/inputControls/Optional.jsp and save it.
Now Run your report it should work.
Thanks & Regards,
A.prasanth Kumar
![logo](https://www.helicaltech.com/wp-content/uploads/2019/01/Quotes.png)
Best Open Source Business Intelligence Software Helical Insight is Here
![logo](https://www.helicaltech.com/wp-content/uploads/2019/01/logo.png)