Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:19:26+00:00 2026-06-11T10:19:26+00:00

Enviornment: JSF 2.1.7 SEAM 2.3.0 JBOSS 5.1.2 My application has a string that needs

  • 0

Enviornment:
JSF 2.1.7
SEAM 2.3.0
JBOSS 5.1.2

My application has a string that needs to be localized

“I agree to WorldSite’s Privacy Policy and Cookie Notice“

Where the italicized Privacy Policy and Cookie Notice are hyperlinks to other pages.

Originally our facelet was set up like this:

<h:outputText value="#{messages['iAgreeTo']}" />
<h:outputLink target="_blank" value="#{bean.privacyPolicy}">#{messages['privacyPolicy']}</h:outputLink>
<h:outputText value="#{messages['and']}"/>
<h:outputLink target="_blank" value="/jsf/Notice.xhtml">
    <h:outputText value="#{messages['cookieNotice']}"/>
    <f:param name="content" value="Cookie-Notice"/>
    <f:param name="application" value="#{bean.application}"/>
</h:outputLink>

Note: We have URL rewriting in place that takes /jsf/Notice.xhtml and rewrites to

rewrite pattern: /#{application}/Notice/#{content}
result:http://contextRoot/contextPath/myApp/Notice/Cookie-Notice

This allowed for piecemeal translations of the individual keys

iAgreeTo=I agree to WorldSite's&#160;
privacyPolicy=Privacy Policy
and=&#160;and&#160;
cookieNotice=Cookie Notice

But this required a workaround for some languages (in “iAgreeTo” and “and” keys)

iAgreeTo=J'accepte la&#160;
privacyPolicy=Politique de la vie privée
and=&#160;de WorldSite et les&#160;
cookieNotice=Note D'information sur les Cookies

Ideally I would like to be able to have the links be movable within the key. Something like this:

iAgreePhrase=I agree to WorldSite's #{messages['privacyPolicyLink']} and the #{messages['cookieNoticeLink']}
privacyPolicy=Privacy Policy
cookieNotice=Cookie Notice

//The following non-translatable keys held in a separate file
privacyPolicyLink=<h:outputLink target="_blank" value="#{bean.privacyPolicy}">#{messages['privacyPolicy']}</h:outputLink>
cookieNoticeLink=<h:outputLink target="_blank" id="cookieNoticeLink" value="/jsf/Notice.xhtml">\
    #{messages['cookieNotice']}\
    <f:param name="content" value="Cookie-Notice"/>\
    <f:param name="application" value="#{bean.application}"/>\
</h:outputLink>

But the facelet returns the JSF tags (h:outputLink) as strings instead of expanding them to their HTML tags. I can use <a> tags, but then I’m putting rewrite logic in the properties file which is difficult to maintain

iAgreePhrase=I agree to WorldSite's #{messages['privacyPolicyLink']} and the #{messages['cookieNoticeLink']}
privacyPolicy=Privacy Policy
cookieNotice=Cookie Notice

//The following non-translatable keys held in a separate file
privacyPolicyLink=<a target="_blank" href="#{bean.privacyPolicy}">#{messages['privacyPolicy']}</a>
cookieNoticeLink=<a target="_blank" href="#{contextPath}/#{bean.application}/Notice/Terms-and-Conditions">\
    #{messages['cookieNotice']}</a>

Is there a way I can achieve my desired effect without having to put rewrite logic in the resource bundle? Some thoughts I have are forcing the application container to process the facelet twice/reorder it, so it inserts the resource bundles first, and then expands the JSF tags.

Alternatively I may be able to construct the rewritten URL in a bean then call that from my resource bundle?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:19:27+00:00Added an answer on June 11, 2026 at 10:19 am

    While Oversteer’s answer is certainly applicable, this could also prove helpful. You can create URLs from EL expressions like this:

    #{facesContext.externalContext.encodeActionURL('/myapp/Notice/Privacy-Policy')}
    

    To include HTML markup in a message, you need to use escape="false" in <h:outputText/>, for example:

    <h:outputText escape="false" value="#{messages['iAgreePhrase']}" />
    

    And, in your messages.properties (or localized version):

    iAgreePhrase=I agree to WorldSite's <a href="#{facesContext.externalContext.encodeActionURL('/myapp/Notice/Privacy-Policy')}">Privacy Policy</a> and ...
    

    This has the problem that the URL is calculable only from within an HTTP request, if you for example use the message key from within an asynchronous thread, the URL will not be calculated (there’s no facesContext available).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an JSP tag that I would like to use in my JSF/Seam
I have been investigating a JSF upgrade on our existing web apps that are
I'm have a VS 2011 web application. Reports worked fine in development enviornment, but
I have a UI that has options to upload multiple documents of specific natures
We currently maintain a JSF application developed using Netbeans 5.5.1 using the Visual Web
In a JSF 2.0 application (running on Tomcat 7 and using weld 1.1.1.Final), I
We have a JSF based web application which submits the input form data to
How do I make sure that my java program is compatible with Java Enviornment
I would like to development an simple application using the following envirnoment. JBoss 7.1.1
i'm developing a new piece of our jdk 1.4.2, JSF + iBatis Web Application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.