Aklin
Aklin

Reputation: 2649

Cache base url #{request.contextPath} in a variable to use multiple times on page & included pages

I need to cache #{request.contextPath} into a variable so that it could used multiple times within a page. Previously while I was working with Mojarra 2.1.3, I could use ui:param for this purpose & that would cache the expression value for entire page & across all the included pages in the current page. But it doesn't work with Myfaces(see issue) reason being <ui:param> should be direct child of <ui:include> or <ui:define> to work.

I have been suggested to use c:set but I want to avoid working with JSTL tags as far as possible. What is recommended for my use case ?

Upvotes: 1

Views: 504

Answers (1)

BalusC
BalusC

Reputation: 1108982

Just use <c:set>. It doesn't harm anything in this particular case.


but I want to avoid working with JSTL tags as far as possible.

It look like that you don't understand why and when JSTL tags should (not) be used and thus overgeneralizes the usage of all JSTL tags in JSF as "bad" for ever. You shouldn't think that. Carefully read this answer to get enlightened: JSTL in JSF2 Facelets... makes sense?

Upvotes: 1

Related Questions