Package org.mapfish.print.attribute
Class JsonDatasourceAttribute
- java.lang.Object
-
- org.mapfish.print.attribute.JsonDatasourceAttribute
-
- All Implemented Interfaces:
Attribute
,ConfigurationObject
public class JsonDatasourceAttribute extends java.lang.Object implements Attribute
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 Constructor Description JsonDatasourceAttribute()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getValue(Template template, java.lang.String attributeName, PObject requestJsonAttributes)
Get the attribute value.java.lang.Class
getValueType()
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(java.lang.String name)
Set the name of the attribute as set in the configuration file.void
validate(java.util.List<java.lang.Throwable> validationErrors, Configuration configuration)
validate that the configuration was correct.
-
-
-
Method Detail
-
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
public void setConfigName(java.lang.String name)
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
public java.lang.Class getValueType()
Description copied from interface:Attribute
Get the class of the value.- Specified by:
getValueType
in interfaceAttribute
- Returns:
- the value class
-
getValue
public java.lang.Object getValue(@Nonnull Template template, @Nonnull java.lang.String attributeName, @Nonnull PObject requestJsonAttributes)
Description copied from interface:Attribute
Get the attribute value.
-
validate
public void validate(java.util.List<java.lang.Throwable> validationErrors, Configuration configuration)
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
-
-