1

Usually we use Facelet's templating mechanism to include the same header on each page. But in the current project, the content of said header is provided from another server. Is there a way to include such content from another URL within the XHTML page?

(I saw a post with a similar topic but neither ui:insert (page content is not within the WAR) nor ui:include (reference only within WAR possible) seems to fit.)

Community
  • 1
  • 1
Alexander Rühl
  • 6,769
  • 9
  • 53
  • 96

1 Answers1

0

As you can see in this question you will need to write your own custom Facelets resource resolver so it can resolve from urls.

Community
  • 1
  • 1
ElderMael
  • 7,000
  • 5
  • 34
  • 53
  • Thanks for the hint, but the answer proposes to put the shared content somewhere - but in my case, the shared content is not under my control, but is maintained by another server and has to be referred by URL. – Alexander Rühl Oct 02 '12 at 14:23
  • And it is not the same because? You will be importing the file from a URL. – ElderMael Oct 02 '12 at 14:28
  • Ok, so you're saying in case the path to resolve is already a full URL it is just taken and in case not it is resolved from WAR with the default mechanism? But still, how is it referenced in my XHTML template page in the first place? In my case I don't need the template to be taken from the URL, but to reference content within the template (e.g. the header) which comes from another URL. – Alexander Rühl Oct 02 '12 at 14:58
  • `Ok, so you're saying in case the path to resolve is already a full URL it is just taken and in case not it is resolved from WAR with the default mechanism?` That depends on how do you implement your facelet resolver – ElderMael Oct 02 '12 at 15:07
  • `But still, how is it referenced in my XHTML template page in the first place? In my case I don't need the template to be taken from the URL, but to reference content within the template (e.g. the header) which comes from another URL.` You could use [nested templates](http://stackoverflow.com/questions/5323937/jsf-2-0-facelets-nested-templates-inheritance) for that. Just make a first template in wich you put a ui:insert (where you put your header) and then make a second template in wich you define (with ui:define) the url from wich you want to retrieve the header. – ElderMael Oct 02 '12 at 15:09
  • Ok, the setup works as you said with 2 templates, I now did a `` in the 1st template to insert a local file without content which again refers via its `template` attribute in `` to the external header file which again defines the content in ``. Is this a sensible setup or does it bring any problems with it? And why would I need a custom resource resolver in this setup? Seems to work without one. – Alexander Rühl Oct 05 '12 at 06:56