Jump to content
We've recently updated our Privacy Statement, available here ×

Input Control JSP Standard draw() Function


cameron_1
Go to solution Solved by cameron_1,

Recommended Posts

Hello,

I've got a custom JSP page for some input controls we're using, mainly to handle dynamically hiding and showing parameters based on selections of other parameters.

I'm having an issue though getting the basic functionality of the input controls working correclty in this new JSP.

I've followed the guide in the course training material and I've ended up with a function like this - 

controlsViewModel.draw = function (jsonStructure) {

 
       var drawControl = function (container, jsonControl) {
            if (jsonControl.visible) {
                var control = this.findControl({id:jsonControl.id});
                container.append(control.getElem());
            }
        };
 
        _.each(jsonStructure, _.bind(drawControl, this, jQuery("#inputControlsContainer")));
 
...<extra code in here to handle dynamically showing and hiding div's>....
 
}
 
When I use this function to draw the input controls I lose the sizer for multi-select lists.
 
Where can I find the "standard" funciton to replication this functionality properly?
 
thanks,
 
Cameron
Link to comment
Share on other sites

  • 4 weeks later...
  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

OK. So, no response from anyone who actually has this information on hand, so I worked through it myself and came up with the following JSP template to use as a base for any custom input control JSP.

<jsp:include page="InputControlTemplates.jsp" /><ul id="inputControlsContainer" class="list inputControls ui-sortable"></ul></script><script type="text/javascript">    ;(function (jQuery, _, controlsViewModel) {        controlsViewModel.draw = function (jsonStructure) {            var drawControl = function (container, jsonControl) {                                if (jsonControl.visible) {                                        var control = this.findControl({id:jsonControl.id});                         control.makeResizable && control.makeResizable();                                        container.append(control.getElem());                                }            };            _.each(jsonStructure, _.bind(drawControl, this, jQuery("#inputControlsContainer")));   //*********************************************   //********  CUSTOM CODE GOES HERE  ************   //*********************************************     }; }) (            //Dependencies            jQuery,            _,            JRS.Controls.getController().getViewModel() //take viewmodel from globalnamespace    );</script>[/code]

So, for anyone who comes across this in the future looking for a place to start, here's a few gotchas and points I've come across so far - 

  • Your JSP doesn't have to be used just for an input control! This JSP is included in your report at all times (it's not loaded in an iframe or anything like that), so you can modify things outside of the input controls as well.
  • jQuery is included, but the $ namespace isn't used, so you need to use the prefix "jQuery" instead of "$", just replace the $ sign in any example code you come across with "jQuery" and it should mostly work.
  • The input controls themselves don't have ID on their DOM objects. Their containing <div>s do have ID though, those ID's are the resource ID of the input control.
  • Don't put extra input objects in the same <div> as the in-built ones, it seems to get confused and doesn't always know where to pick up the values from when passing them to the report. If you need to add in extra input objects, put them in seperate <div>s.
  • You need to trigger the "change" event on the input objet jaspersoft creates if you modify it programatically, if you don't trigger this event jaspersoft doesn't passs the values that have changed or been entered to the report.
Link to comment
Share on other sites

  • 6 months later...
  • 1 year later...
  • 5 months later...
  • 2 months later...

Hello !

Seriously well done working out that sample code - I assume with absolutely no help from Jaspersoft ...

I am trying to get started with building a custom input control on Jasperserver 6.2.  If I take your sample code as is and put it into a JSP and then change a report to use that as a custom jsp page for controls, then the report works fine.

But I cannot then work out how to add my custom control code into your section where it says custom code goes here ...

Do you think you could share one of your custom jsp pages in total so that I can get an idea of how this is meant to hang together ?

 

Link to comment
Share on other sites

Not sure if this will still work on 6.2... It was written for 5.2, and updated again with 5.5, but that's the latest version I have, so I've not been able to test/port to 6.2 unfortunately. I have had a quick look at 6.2 and there did appear to be some changes in the way the input controls were rendered, so I suspect it may break this code in the process...
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...