Problem setting pivot content dynamically

Open
Andre Pinheiro asked on September 26, 2018

Folks,
 
I have the following flexmonster object: 

var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "./js/flexmonster/",
report: {
dataSource: {
dataSourceType: "json",
data: {}
},
options: {
configuratorActive: false,
viewType: "grid",
grid: {
type: "flat",
showTotals: "off",
showGrandTotals: "off"
}
}

},
width: "100%",
height: "100%",
toolbar: true,
licenseKey: "XXX",
beforetoolbarcreated: customizeToolbar
});

 
And the following method that sets some content into the object:
 

function flexmonsterSetURL( filename ){ 
console.log( 'FLEXMONSTER-------------start flexmonsterSetURL' );

if (filename != null) {
pivot.updateData({
dataSourceType: "json",
filename: filename
});

pivot.refresh();
}
console.log( 'FLEXMONSTER-------------finished flexmonsterSetURL' );
}

The problem I have is the following:
 

  • Scenario 1 - Running it on a local tomcat environment (spring-boot) with no application name present in the url. Example: http://localhost:8080/flexmonster.html

a) When I pass the followin URL to the javscript method, it works: /queryServlet/?queryID=1
b) When I pass the followin URL to the javscript method, it does not work, showing the error present in the attachment named "flexerror1.jpg": ./queryServlet/?queryID=1

  • Scenario 2 - Running it on a local tomcat environment with an application name present in the url. Example: http://localhost:8080/AppTest/flexmonster.html

c) When I pass the followin URL to the javscript method, it does not work, showing the error present in the attachment named "flexerror2.jpg": /queryServlet/?queryID=1
d) When I pass the followin URL to the javscript method, it does not work, showing the error present in the attachment named "flexerror1.jpg": ./queryServlet/?queryID=1
 
Bellow some comments (with the letters related to the previous scenarios cases):
a) It works since apparently the final URL that is used is this one, and no application name is used: http://localhost:8080/queryServlet/?queryID=1
b) As per my understanding, the URL that uses a dot (.) should not have problems, and it seems that the problem is because flexmonster kind of "concatenates" the URL with the "componentFolder" parameter value
c) It does not work apparently because the generated URL is the following one http://localhost:9080/queryServlet/?queryID=1, where we have the application name missing
 b) As per my understanding, the URL that uses a dot (.) should not have problems, and it seems that the problem is because flexmonster kind of "concatenates" the URL with the "componentFolder" parameter value
 
Please give some advice on what would be the solution that woult fit to both scenarios (with and without application name)
 
Thanks in advance,
Andre Pinheiro

Attachments:
flexerror1.jpg

6 answers

Public
Andre Pinheiro September 26, 2018

Forgot to attach the other error printscreen

Attachments:
flexerror2.jpg

Public
Andre Pinheiro September 26, 2018

A small update...
 
I have managed to make this work in both scenarios using the following relative URL, since it seems (according to one of Ian's answers on this post: https://www.flexmonster.com/question/can-we-directly-pass-configuration-as-string-without-creating-a-file-stream/) that flexmonster uses a relative path based on what is defined in componentFolder:
 
../../queryServlet/?queryID=1
 
Based on this, I am a little bit confused about the componentFolder property, since I thought it was only used to point where the flexmonster bits were stored, and I am not able to understand why both properties (filename and componentFolder) are connected.
 
Thanks in advance

Public
Ian Sadovy Ian Sadovy Flexmonster September 27, 2018

 Hello Andre,
 
Thank you for the detailed explanation.
First of all, I can confirm that using a relative path such as ../../queryServlet/?queryID=1 is a recommended way (and I guess only possible now) for your use case.
 
As for the componentFolder, you are right, it is used as a base folder for file paths, excepting the paths that start with /.
It may sound a bit complicated, but it is a way it works for a long time and we cannot change this.
 
Also, it seems that the paths that start with ./ use componentFolder as well and behave the same as without ./
It may be convenient to ignore componentFolder for such paths (same as we do for /). I will add this feature to our backlog for further discussion with the dev team.
 
Hope my answer was helpful.
 
Regards,
Ian

Public
Andre Pinheiro September 27, 2018

Hello Ian,
 
thank you very much for the clarification. Just wanted to be sure that we were using an approach that is officialy supported by Flexmonster.
 
Kindest regards,
Andre Pinheiro

Public
Vera Didenko Vera Didenko Flexmonster March 18, 2019

Hello, Andre,

Thank you for your reply.

Here is a link to our changes to relative URLs when migrating to the latest version.
Please let us know if this helps.

Best Regards,
Vera

Public
Andre Pinheiro March 18, 2019

Thanks, Vera and Flexmonster team!!

Please login or Register to Submit Answer