Custom JSP input dialog in JasperReports Server 4.0

2

Hello all.

 

I would be glad if someone could help me with some kind of JSP code example, how

to call (and pass input parameters) IReport from that JSP page, which I can enter under "Controls&Resources" - > Optional JSP Location in JasperServer 4.0 Repository?

 

P.S.: I've posted a similar question liek this A WEEK AGO, but I didn't get a SINGLE answer.  Are there really NO ONE to know that or to have a problem like me ????

 

Thank you very much for every info I get....

 

Best regards,

Robi



Post Edited by robidomadenik at 06/14/2011 07:34
robidomadenik's picture
Joined: Apr 13 2011 - 1:54pm
Last seen: 3 years 6 months ago

8 Answers:

1

Robi,

If you only need to customize the parameters, start off by making a copy of the DefaultParametersForm.jsp.  Make the changes as needed, rename the file (you don't want to overwrite the DefaultParametersForm because all other reports will use this!) then copy to the WEB-INF/modules/inputControls (or another folder you designate).  Now you can reference it in the optional jsp field under the edit controls and resources page from the server.

Here is a very basic example of the code that was changed in the copy of the jsp, in order to display masked input for a specified input control.  Note that the input control to be changed is refered to by name (not ideal if you want to reuse the custom jsp for other reports) and there are only a few changes required, such as changing the input type='password' .  Take a look at the original DefaultParametersForm.jsp and you'll be able to compare the differences.

Good luck!

Code:
<%-- ##########   SINGLE_VALUE - CUSTOM PARAMETER   ########## --%>
                <c:when test="${inputName == 'pass'}">  <%-- Single value : InputControl.TYPE_SINGLE_VALUE --%>
                    <li class="leaf" id="jsCtrl_pass">
                        <c:choose>
                            <c:when test="${control.dataType.localResource.type == 3 or control.dataType.localResource.type == 4}">
                                <c:set var="controlClass" value="picker"/>
                            </c:when>
                            <c:otherwise>
                                <c:set var="controlClass" value="text"/>
                            </c:otherwise>
                        </c:choose>
                        <label class="control input password" for="pass" title="Filter value">
                            <span class="wrap">
                                <js:inputControlLabel control="${wrapper}" messageSource="${messageSource}"/>:
                            </span>
 
                                    <input type="password" name="<c:out value="${inputName}"/>" id="<c:out value="${inputName}"/>" value="<c:out value="${wrapper.formattedValue}"/>" <c:if test="${readOnly}">disabled</c:if>
                                        onchange="fireCascade('${requestScope.reportUnitObject.URI}','${wrapper.resourceUriPrefix}','${inputName}', ${control.type}, ${readOnly});"/>
 
 
                            <c:if test="${wrapper.errorMessage != null}">
                                <c:set var="hasValueError" value="true"/>
                            </c:if>
                            <div id="error_${inputName}"></div>
                            <span class="message warning"><c:out value="${wrapper.errorMessage}"/></span>
                       </label>
                    </li>
                    <c:set var="initAggregate_2">
                        initAggregate('${wrapper.resourceUriPrefix}'  ,'${inputName}', ${control.type}, ${readOnly}, '<spring:escapeBody javaScriptEscape="true">${wrapper.formattedValue}</spring:escapeBody>');
                    </c:set>
                    <script>
                        ${initAggregate_2}
                    </script>
                    <textarea name="_evalScript" class="hidden" style="display:none">
                        ${initAggregate_2}
                    </textarea>
                </c:when>
                <%-- end custom parameters --%></td></tr></tbody></table>
fisbell's picture
19
Joined: Nov 18 2008 - 2:24pm
Last seen: 2 months 4 weeks ago
0

Hi.


Thanks a lot for a sample code....i saw the difference between these two files. Thanks again :)


Now I have another problem.....a have situation, when my custom input dialog box opens, I want to load some parameters from mySQL database into this input dialog box (textbox) and save them into mySQL, when parameters are changed or when OK button (submit) is clicked and then the report is shown.

I received a message from Sherman (Jasper), that this could be the way:

·        catch the form submit event in Javascript

·        send the parameters to a separate JSP which would save them

·        continue doing the normal JasperServer submit

but its messy and I don't see nothing about submit in file DefaultparametersForm.jsp

Any suggestions???

 

Thanks,

Robi

robidomadenik's picture
Joined: Apr 13 2011 - 1:54pm
Last seen: 3 years 6 months ago
0

Check out these files

  • ..apache-tomcat/webapps/jasperserver/WEB-INF/jsp/modules/viewReport/ViewReport.jsp (input controls on-page form section)
  • ..apache-tomcat/webapps/jasperserver/scripts/controls.report.js (applyInputValues function)
fisbell's picture
19
Joined: Nov 18 2008 - 2:24pm
Last seen: 2 months 4 weeks ago
0

Hello again.

 

I still didn't manage to solve all my issues regarding additional input parameters in JasperServer 4.0

As I see in post above, there's a sample of modification in existing input parameter........I would like to know, how I can add "additional" parameter to this DefaultParametersForm.jsp file ??

Well, here's my case:

In JasperServer I made 2 date parameters.... (from-to.....Single value , Type:Date)

Now I'm wondering if I can make a custom two additional buttons, so i can modify these 2 dates BEFORE I run the report. So....if I have FROM: 01-04-2011 and TO: 30-04-2011  and then I press button "Before" the dates moves to FROM: 01-03-2011 and TO: 31-03-2011  and if I press "AFTER" the dates are FROM: 01-05-2011 and TO: 31-05-2011.

But this have to happen when I enter my input parameters, so on-the-fly.......in the end I press Apply and I run the report.

 

Can I do this somehow??? Maybe an example for adding a additional parameter to DefaultParametersForm.jsp ?

 

Thanks a lot!

Robi

robidomadenik's picture
Joined: Apr 13 2011 - 1:54pm
Last seen: 3 years 6 months ago

Hi,

thanks for this post , I also have been trying this for last one month , So if you could tell me in detail how can i do this in my jasperserver?

shatad0101 - 1 year 10 months ago
0

Hey.

 

Thanks anyway.

I've already solved it...........

 

Robi

robidomadenik's picture
Joined: Apr 13 2011 - 1:54pm
Last seen: 3 years 6 months ago
0

Hi All,

    I am trying to give my own inputs to the jasper ireport. I have some conditions , which are different from what jasper providing by default.I want to display my options in a tree structure to the user, By selecting them, the report has to be genarated.

For this i created one jsp file and placed it in optional jsp location, then i can see the tree structure in the browser windwo but i am not able to get the report,and no error message tooo.

        Tell me the way (if possible sample code) to give our own values to the ireport .

          And which things to be consider when we are providing jsp file in optional jsp location.

Thanks in advance.

hlta's picture
1
Joined: Nov 22 2011 - 6:50am
Last seen: 2 years 11 months ago
0

 hi all 

 

i have a issue which is kiling me from many days.

 

 

i am using js cp 4.5 and my problem  is

 

i am creating  a report in ireport with paramter product_id and am linking a input control to this parameter in jasper server where 

i am passing prodcut-id as a value column and product_name as a visible column.

 

i want to dispaly what ever selected filter value along with the report.

 

 

i dragged parameetr product_id into detail band but it is dispalying product_id as it is referencing value column as product_id.

 

 

please help if you have any thoughts on this on how to show visible column instead of value column in the report .

 

any jasper server  customization needed ,please let me know.

 

thanks in advace

 

chandrasekhar

 

kcsekhar25's picture
Joined: Apr 24 2011 - 7:00am
Last seen: 1 week 2 days ago

Hi kcsekhar25....!

You can display paramter text using subreport functionality.

NikunjB - 3 months 4 days ago
0

with the code shown above I have the following problem

does not show correctly the password field, and the parameter fails to report

im in JRS 4.7

, Uploaded with ImageShack.us

superunicojosh's picture
Joined: Mar 26 2012 - 12:36pm
Last seen: 9 months 3 weeks ago

a

NikunjB - 3 months 4 days ago
Feedback
randomness