Package org.mapfish.print.attribute
Class JsonDatasourceAttribute
java.lang.Object
org.mapfish.print.attribute.JsonDatasourceAttribute
- All Implemented Interfaces:
Attribute
,ConfigurationObject
A JSON data source attribute. To be declared as net.sf.jasperreports.engine.data.JsonDataSource
in Jasper. Accepts only JSON objects at the root. To use it, you must pass it to a sub report
like that:
< subreport>
...
< dataSourceExpression>
< ![CDATA[$P{json_attribute}.subDataSource("path.to.list")]]>
< /dataSourceExpression>
< subreportExpression><![CDATA["subreport_name.jasper"]]>< /subreportExpression>
< /subreport>
The expression given to the subDataSource method must select an array in the JSON structure.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the attribute value.Get the class of the value.void
printClientConfig
(org.json.JSONWriter json, Template template) Write this attribute out the the json writer so that clients can know what attributes are expected.void
setConfigName
(String name) Set the name of the attribute as set in the configuration file.void
validate
(List<Throwable> validationErrors, Configuration configuration) validate that the configuration was correct.
-
Constructor Details
-
JsonDatasourceAttribute
public JsonDatasourceAttribute()
-
-
Method Details
-
printClientConfig
public void printClientConfig(org.json.JSONWriter json, Template template) throws org.json.JSONException Description copied from interface:Attribute
Write this attribute out the the json writer so that clients can know what attributes are expected.- Specified by:
printClientConfig
in interfaceAttribute
- Parameters:
json
- the json writer to write totemplate
- the template that this attribute is part of- Throws:
org.json.JSONException
-
setConfigName
Description copied from interface:Attribute
Set the name of the attribute as set in the configuration file.- Specified by:
setConfigName
in interfaceAttribute
- Parameters:
name
- the name of the attribute
-
getValueType
Description copied from interface:Attribute
Get the class of the value.- Specified by:
getValueType
in interfaceAttribute
- Returns:
- the value class
-
getValue
public Object getValue(@Nonnull Template template, @Nonnull String attributeName, @Nonnull PObject requestJsonAttributes) Description copied from interface:Attribute
Get the attribute value. -
validate
Description copied from interface:ConfigurationObject
validate that the configuration was correct.- Specified by:
validate
in interfaceConfigurationObject
- Parameters:
validationErrors
- a list to add any detected errors to.configuration
- the containing configuration
-