How to Hide Input Controls from the JasperServer using Optional Jsp

Posted on by By Nikhilesh, in Business Intelligence, Jaspersoft, Open Source Business Intelligence | 0

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.

Lets Start 30 Days Free Trail

Example : lets say Optional.jsp is our jsp which should be kept under location in your jasperserver


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”


user=”prasanth” password=”P@ssw0rd”/>

<sql:query dataSource=”${snapshot}” sql=”select * from rooms.library ” var=”result” />

<c:forEach var=”row” items=”${result.rows}”>


<td><c:out value=”${row.tenant}”/></td>



<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>




–In this below function I am hiding my input control p_library when condition fails


function showAllData(){

jQuery(‘#inputControlsContainer > div’).each(function( index ) {

if(jQuery( this ).attr(‘id’) == ‘p_library’){





jQuery(document).ready(function() {

var checkExist = setInterval(function() {

if (jQuery(‘#inputControlsContainer > div’).length) {

if(jQuery(‘#inputControlsContainer > div’).length == 1)





console.log(jQuery(‘#inputControlsContainer > div’).length);


}, 100);



</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=””


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.

Grab The 30 Days Free Trail

set path to — modules/inputControls/Optional.jsp and save it.

Now Run your report it should work.

Thanks & Regards,

A.prasanth Kumar


Best Open Source Business Intelligence Software Helical Insight is Here


A Business Intelligence Framework

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments