Java Integration with Weld and XHTML Page


#1

Good morning
I would like to integrate the Pivot table with my J2EE/XHTML application. I have tried to use the following setup (as described in the documentation) with this JSP code in a XHTML page:

function updateDHXAdminPivot() {

	var dhxFields=document.getElementById("#{parentForm}:adminTab:dhxFields").value;
	var dhxDatafile = document.getElementById("#{parentForm}:adminTab:dhxDatafile").value;

	alert(dhxFields);
	alert(dhxDatafile);
	
	var pivot = new dhx.Pivot("pivot", {
			
			fields: {
				rows: ["USERNAME"],
				columns: ["MODULE"],
				values: [{ id: "USERNAME", method: "count" }],
			},
			fieldList: JSON.parse(dhxFields),
		});

	alert("/rest/dhxdatafile/name/"+dhxDatafile);

 
    pivot.load("../../rest/dhxdatafile/name/"+dhxDatafile, new dhx.dataDrivers.csv({
    	nameByHeader: true,
        rowDelimiter: "\n",
        columnDelimiter: ","
	}));

I am keeping getting an error like:

Failed to load resource: the server responded with a status of 406 (Not Acceptable)

The problem is that the url is working perfectly and allows my to download correctly a CSV file.

Is there an example I can use to better understand why the code is bugging?

Thank you for the help and best regards


#2

Unfortunately we have no such examples of the dhx.Pivot usage.
Could you please, provide your using example, so the porblem could be reconstructed locally.


#3

Hello, I really did not implement anything different from above. The Javascript parte is as follow:

var pivot;
function createDHXAdminPivot() {

	updateDHXAdminPivot();
	 	
 }

 function updateDHXAdminPivot() {

	var dhxFields=document.getElementById("#{parentForm}:adminTab:dhxFields").value;
	var dhxDatafile = document.getElementById("#{parentForm}:adminTab:dhxDatafile").value;

	alert(dhxFields);
	alert(dhxDatafile);	

	var pivot = new dhx.Pivot("pivot", {
		fields: {
			rows: ["form", "name"],
			columns: ["year", { "id": "when", "group": "dateByQuarter" }],
			values: [{ id: "oil", method: "max" }, { id: "oil", method: "min" }],
		},
		fieldList: [
			{ id: "name", label: "Name" },
			{ id: "year", label: "Year" },
			{ id: "continent", label: "Continent" },
			{ id: "form", label: "Form" },
			{ id: "gdp", label: "GDP" },
			{ id: "oil", label: "Oil" },
			{ id: "balance", label: "Balance" },
			{ id: "when", label: "When", type: "date", format: "%d/%m/%Y" },
		],
	});
	
	alert("/rest/dhxdatafile/name/"+dhxDatafile);

    pivot.load("http://localhost:8080/rest/dhxdatafile/name/bingo", new dhx.dataDrivers.csv({
		names: ["name", "year", "continent", "form", "gdp", "oil", "balance", "when"],
	}));

 }

… that I have taken from the site. The difference is that I use a REST service to get the data from the file system and I am using, in my implementation, the following URL. http://localhost:8080/rest/dhxdatafile/name/bingo

This URL just download the file that I have taken from the DHTMLP pivot page, it is just served using a rest service rather than being downloaded “directly” from a folder.

Please note that the example without the rest service, that is the pivot loading directly the Javascript data in the page, is working correctly. This means that the issue is not the pivot, rather than the pivot.load function.

Best regards


#4

Note, that load() method performs an ajax request to the specified URL to fetch the data from it.
If the location is not reachable or not accessible it won’t be able to load that data.