Hello,
I’m working on a series of articles on Vaading with a special focus on Groovy and Grails.
So I develop a small demonstration application that displays a Fusion Chart’s bar graph in order to show the evolution of the temperature.
For that, I reused the code found in this forum (thank you to Sami).
The application works well as a classical web application deployed on Tomcat.
An Embedded object is used to represent the flash object that will use the Flash file Column3D.swf available in the Java package.
ClassResource chartResource = new ClassResource("Column3D.swf", mainWindow.getApplication());
// The Embedded component to present the Flash object
Embedded chart = new Embedded(null, chartResource);
// Set size properties for the chart
chart.setWidth("500px");
chart.setHeight("400px");
// dataUrl maps to URIHandler below.
chart.setParameter("FlashVars", "dataUrl=mydata.xml");
When displayed, the Flash component will fetch its data from the URL “data.xml” (defined in “dataUrl=mydata.xml” ); in the code, the data is served by an URIHandler with something like:
mainWindow.addURIHandler(new URIHandler() {
private static final long serialVersionUID = 1L;
public DownloadStream handleURI(URL context, String relativeUri) {
if (relativeUri.startsWith("mydata")) {
String xml = "<chart caption='Températures maximales sur 5 jours' subcaption='Antibes, France' xAxisName='Jours' yAxisName='Températures' numberSuffix='°C'>"+
"<set label='Oct 20' value='15.0' /><set label='Oct 21' value='16.1' /></chart>";
ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
return new DownloadStream(bais, "application/xml", relativeUri);
}
return null;
}
});
What’s the problem then?
Well, I’m trying to port this application as a
portlet
deployed in Liferay 6.
The point that doesn’t work is the data URL of course ; without modification, the Flash component shows the error message “Error in loading data”, and in the console I get this message:
14:12:00,320 INFO [PortalImpl:3812]
Current URL /web/guest/Data.xml?FCTime=109 generates exception: null
Note that it’s not mydata.xml!
My question is: how can I construct an URL in order the application can handle the request for the data?
I tried a lot of code but without success, for example, by using the PortletApplicationContext2 instance in order to generate an URL to use.
Any idea?
Cheers,
Bertrand.