Walker, Robert
2012-03-30 03:55:30 UTC
Hi all, I was turned onto freemarker today and really impressed with it, and wanted to use it to generate spreadsheetML
(xml that Excel will open as if it were a xlsx file)
I am having problems accessing properties buried a few layers deep.
Basically, I have a OrganisationInfo class which contains an OrganisationInfo. NetworkList object,
And that networkList property contains a List of Network objects, from which I need to get
property values.
I am wondering if JAXB has generated something freemarker can't be used to access in it's template.
I want to try something like
cfg.setObjectWrapper( new DefaultObjectWrapper() );
SimpleHash root = new SimpleHash();
// expose JAXB generated java object
root.put("organisationInfo", organisationInfo);
then my template has accessing syntax like
<h1> ${organisationInfo.networkList[0].tadigCode} </h1>
Is this possible with freemarker? Is there an example of this anywhere?
I get various errors Expected hash. organisationInfo.networkList[0] evaluated instead to freemarker.template.SimpleScalar.
Thanks all
I have JAXB generated classes like this
OrganisationInfo.java
====================@XmlRootElement(name = "OrganisationInfo")
public class OrganisationInfo
{
@XmlElement(name = "NetworkList", required = true)
protected OrganisationInfo.NetworkList networkList;
.
.
.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"network"})
public static class NetworkList
{
@XmlElement(name = "Network", required = true)
protected List<Network> network;
.
.
}
}
Network.java
===========@XmlRootElement(name = "Network")
public class Network
{
@XmlElement(name = "TADIGCode", required = true)
protected String tadigCode;
.
.
}
(xml that Excel will open as if it were a xlsx file)
I am having problems accessing properties buried a few layers deep.
Basically, I have a OrganisationInfo class which contains an OrganisationInfo. NetworkList object,
And that networkList property contains a List of Network objects, from which I need to get
property values.
I am wondering if JAXB has generated something freemarker can't be used to access in it's template.
I want to try something like
cfg.setObjectWrapper( new DefaultObjectWrapper() );
SimpleHash root = new SimpleHash();
// expose JAXB generated java object
root.put("organisationInfo", organisationInfo);
then my template has accessing syntax like
<h1> ${organisationInfo.networkList[0].tadigCode} </h1>
Is this possible with freemarker? Is there an example of this anywhere?
I get various errors Expected hash. organisationInfo.networkList[0] evaluated instead to freemarker.template.SimpleScalar.
Thanks all
I have JAXB generated classes like this
OrganisationInfo.java
====================@XmlRootElement(name = "OrganisationInfo")
public class OrganisationInfo
{
@XmlElement(name = "NetworkList", required = true)
protected OrganisationInfo.NetworkList networkList;
.
.
.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"network"})
public static class NetworkList
{
@XmlElement(name = "Network", required = true)
protected List<Network> network;
.
.
}
}
Network.java
===========@XmlRootElement(name = "Network")
public class Network
{
@XmlElement(name = "TADIGCode", required = true)
protected String tadigCode;
.
.
}