cameron_1 Posted September 16, 2013 Share Posted September 16, 2013 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 More sharing options...
Solution cameron_1 Posted October 15, 2013 Author Solution Share Posted October 15, 2013 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 More sharing options...
cameron_1 Posted October 17, 2013 Author Share Posted October 17, 2013 What happened to the text?!?!! I wrote up a long answer to this! Blergh. Re-wrote (part) of it again. Link to comment Share on other sites More sharing options...
rsuddhala Posted May 16, 2014 Share Posted May 16, 2014 Hi, I am looking to change the input controls view,Can you please help me by giving example for custom input controls.I did not understand about script/Example Thanks, Raj Link to comment Share on other sites More sharing options...
rsuddhala Posted May 19, 2014 Share Posted May 19, 2014 In Above example the controlsViewModel.draw = function (jsonStructure) is not invoking is there any changes need to be done ? Please help me out Thanks, Raviraj Link to comment Share on other sites More sharing options...
santhoshkolloju Posted May 27, 2015 Share Posted May 27, 2015 Can you please Post Some Example with Customised Jquery Code I am Struck Link to comment Share on other sites More sharing options...
santhoshkolloju Posted May 30, 2015 Share Posted May 30, 2015 I am getting error in this "Uncaught Reference Error:_is not defined" Link to comment Share on other sites More sharing options...
kolja.ehlersiconplc.com Posted November 9, 2015 Share Posted November 9, 2015 So there are no examples anymore for Jasper Server >5.6? As santhoshkolloju pointed out the exmple from the earlier Guides do not work anymore and the current guide does not contains any information. Thanks Link to comment Share on other sites More sharing options...
littleredshack Posted January 22, 2016 Share Posted January 22, 2016 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 More sharing options...
cameron_1 Posted January 26, 2016 Author Share Posted January 26, 2016 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now