Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[birt-dev] how can i change the dataset

Hello

I developed a birt-servlet like
http://wiki.eclipse.org/index.php/Servlet_Example
and now i try to give an array to the servlet as an input for the already
designed report. in the designed report i defined a ScriptDataSetHandle.

is it possible to use the array as input for the report?

i tried to make the datasource like:

ScriptDataSetHandle dataSetHandle =
(ScriptDataSetHandle)report.findDataSet("MyDataSet");//$NON-NLS-1$
dataSetHandle.setDataSource("MyDataSource");//$NON-NLS-1$

dataSetHandle.setOpen("i=0;"//$NON-NLS-1$
+ "sourcedata = new Array( new Array(3), new Array(3), new Array(3), new
Array(3));"//$NON-NLS-1$

+ "sourcedata[0][0] = 10; "//$NON-NLS-1$
+ "sourcedata[0][1] = \"Ice Bella\";"//$NON-NLS-1$
+ "sourcedata[0][2] = 304;"//$NON-NLS-1$
+ "sourcedata[1][0] = 10; "//$NON-NLS-1$
+ "sourcedata[1][1] = \"Nola Dicci\";"//$NON-NLS-1$
+ "sourcedata[1][2] = 258;"//$NON-NLS-1$
+ "sourcedata[2][0] = 11; "//$NON-NLS-1$
+ "sourcedata[2][1] = \"Ice Bella\";"//$NON-NLS-1$
+ "sourcedata[2][2] = 202;"//$NON-NLS-1$
+ "sourcedata[3][0] = 11; "//$NON-NLS-1$
+ "sourcedata[3][1] = \"Nola Dicci\";"//$NON-NLS-1$
+ "sourcedata[3][2] = 181;");//$NON-NLS-1$


dataSetHandle.setFetch("if ( i < 4 ){"//$NON-NLS-1$
+ "row[\"xAxis\"] = sourcedata[i][0];"//$NON-NLS-1$
+ "row[\"yAxis\"] = sourcedata[i][2];"//$NON-NLS-1$
+ "i++;"//$NON-NLS-1$
+ "return true;}" + "else return false;");//$NON-NLS-1$//$NON-NLS-2$


cs1 = StructureFactory.createComputedColumn();
cs1.setName("xAxis");//$NON-NLS-1$
cs1.setExpression("row[\"xAxis\"]");//$NON-NLS-1$
cs1.setDataType("integer");//$NON-NLS-1$
cs2 = StructureFactory.createComputedColumn();
cs2.setName("yAxis");//$NON-NLS-1$
cs2.setExpression("row[\"yAxis\"]");//$NON-NLS-1$
cs2.setDataType("integer");//$NON-NLS-1$


PropertyHandle computedSet =
dataSetHandle.getPropertyHandle(ScriptDataSetHandle.COMPUTED_COLUMNS_PROP);
computedSet.addItem(cs1);
computedSet.addItem(cs2);

report.getDataSets().add(dataSetHandle);


but there is no output?? i found also no comparable example. can someone
help me?

thanks in advance




Back to the top