I have four input controls in jasper server like CCA, CCIT, CIT and TAN. Now those four fields has to get validated and proper alert message has to be displayed when TAN input control is entered other CCA, CCIT and CIT has to get disabled and when you enter anything in CCA, CCIT and CIT then TAN input has to get disabled. this validations i has generated in JSP code and trying to publish a report in jasperserver by script is as follows: This script is working fine when i use input fields in jsp and execute. But, when i use same script with same input control names and all no alert window nor any kind of messages are displayed nor report values get changed.. I need solution how to make input controls can speak with script and fire proper alert messages. Thank you in advance.
2 Answers
With help of Stack overflow am able to work with question which i asked. I tried it in different way like, Follow these steps
Step:1
Run your report in jasper server, Now
Observe in inspect window of your browser(if right click is not happening use ctrl+shift+j
) inside elements tag expand body tag inside that div "frame"--> div class "content"--> div id "display"--> div id "reportViewFrame"--> div class "content"--> div class "body"--> div id "inputcontrolsform"-->div class "panel pane inputcontrols"--> div class "content hasFooter"--> div class "body"-->ul class "list input controls"
Now, select which input control id you would like to use code when your jasper report is displayed
Step 2: Create Jsp file with same names
For eg: sampleText.jsp
Open notepad and paste following code
<%--Include templates--%> <jsp:include page="InputControlTemplates.jsp"/> <%-- input controls container --%> <ul class="list inputControls" id="inputControlsContainer"></ul> <script> jQuery(document).ready(function(){ jQuery("#apply").click(function(){ var fromDate = document.querySelector('#start_date label.control input').value; var toDate = document.querySelector('#end_date label.control input').value; /*alert("Start Date: "+fromDate+"End Date: "+toDate);*/ /*Year conversion*/ var start1=fromDate.substring(0,4); var end1=toDate.substring(0,4); /*alert("Years: From: "+start1+" End: "+end1);*/ /*Months conversion*/ var m1=fromDate.substring(7,5); var m2=toDate.substring(7,5); /*alert("Months m1: "+m1+" m2 :"+m2);*/ /*condition checking*/ if(fromDate>toDate){ alert("End Date has to be higher than start date"); } if((end1-1)>start1){ alert("1.End date has to be in the same financial year as start date."); } if((end1-1)==start1){ if(m2>3){ alert("End date has to be in the same financial year as start date."); } } if(end1==start1) { if(m2<=3) { alert("End date has to be in the same financial year as start date."); } } }); }); </script>
Save as in the location “\jasperreports-server-cp-5.1.0\apache-tomcat\webapps\jasperserver\WEB-INF\jsp\” with sampleText.jsp
Now login to jasper soft and execute that report. Screen should appear like this,
Select date from the date picker screen appears like this
Specify in start date todays date and in end date specify 1 of this month and click on “Apply “ button then screen will give u a pop up (alert) like this,
So you can check for different conditions like a. Enter end date 2014-04-01 and check b. Enter end date with 2014-03-31 and check c. Enter end date with 2012-03-31 and check In all the above situations it has to show alert.
Note: Above sample code of jsp is used to give validations for input controls of start date and end date.

- 313
- 1
- 4
- 17
Refer the link https://www.youtube.com/watch?v=1xP967Eb4f4&t=585s by using the concept of js into your code

- 313
- 1
- 4
- 17