0

I'm working on Spring WebFlow / JSF web-app. I need to develop administration panel where admin can upload some files and build page content using this files as fragments. I hope I described it well. To do that, I've created Spring MVC controller with mapping like below. It output files from database (images, .xhtml). How to use that controller to include files on page source ?

@RequestMapping("/file")
public void getFileContent(@RequestParam("id") Integer id, HttpServletResponse response) throws IOException {
    File f = fileDAO.get(id);
    response.setContentType(f.getMime());
    IOUtils.write(f.getData(), response.getOutputStream());
}

This doesn't work:

<ui:include src="#{request.contextPath}/app/file?id=6" />
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
marioosh
  • 27,328
  • 49
  • 143
  • 192

1 Answers1

0

JSF/Facelets includes runs server side, not client side. <ui:include> accepts server side paths, not web URLs. Spring listens on client (HTTP) requests, not on server side resource resolvings as JSF does.

Your best bet is using a custom Facelets ResourceResolver instead which checks the incoming path, stores the file on temp storage and returns its URL back, or just to replace <ui:include> by HTML <iframe> since you seem to want use Spring for this.

<iframe src="#{request.contextPath}/app/file?id=6"></iframe>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Is any cache within ResourceResolver or somewhere ? I created custom ResourceResolver that get file from DB, save in `/WEB-INF/files` and return url to this file. But... I noticed that `` is resolved only once. Change in the database has no effect on the view - `resolveUrl` method is not called once again. – marioosh Jun 17 '11 at 08:03
  • My custom ResourceResolver: [link](http://www.pastie.org/2081595) – marioosh Jun 17 '11 at 08:17