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 8432727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:12:23+00:00 2026-06-10T06:12:23+00:00

I have use case in which I have to use resource bundle to display

  • 0

I have use case in which I have to use resource bundle to display various texts on UI. Some of these resource bundle entries take paramets (e.g. {0}), for these I use h:outputFormat but sometimes that isn’t enough.

e.g.

someMessage=Display this message with param {0}

in a resource bundle.

To display it on xhtml I normally do:

<h:outputFormat value="#{msg['someMessage']}"><f:param value="#{someBean.value}"/></h:outputFormat>

That works well when it’s a simple case, but for more complex use cases it isn’t enough. For example if I want the ‘title’ attribute of a commandLink to use the above resource bundle entry:

    <h:commandLink action="logout" title="#{msg['someMessage']}">
        <f:param value="#{someBean.value}" />
        <h:graphicImage library="images" name="image.png" />
    </h:commandLink>

which doesn’t work. I also tried:

    <h:commandLink action="logout">
        <f:attribute name="title">
            <h:outputFormat value="#{msg['someMessage']}"><f:param value="#{someBean.value}"/></h:outputFormat>
        </f:attribute>
        <h:graphicImage library="images" name="image.png" />
    </h:commandLink>

which also doesn’t work since f:attibute doesn’t allow children.

Even if there is a hack to bypass this (e.g. using hover component from primefaces) there are other fields that might require a parameterized message.

Does anyone know of a way to use MessageFormat that takes an argument in a non-value field of a JSF component?

  • 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-10T06:12:25+00:00Added an answer on June 10, 2026 at 6:12 am

    You could create a custom EL function for this with which you can ultimately end up like:

    <h:commandLink ... title="#{my:format(msg['someMessage'], someBean.value)}" />
    

    You can use the MessageFormat API to perform the job, exactly as <h:outputFormat> is doing under the covers.

    An alternative is to create a custom component which does the same as JSTL’s good ‘ol <fmt:message> which supports a var attribute to export the formatted message into the EL scope.

    <my:outputFormat ... var="linkTitle">
        ...
    </my:outputFormat>
    <h:commandLink ... title="#{linkTitle}" />
    

    Update: JSF utility library OmniFaces has #{of:formatX()} functions and a <o:outputFormat> component for the very purpose.

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

Sidebar

Related Questions

¿In what case do I have to use which of them? In google documentation
I use some strings which are defined in a resource file. What is better
Let's assume I have a class which manages some resource in RAII way: class
I'm just starting to learn AspectJ, and I have use-case for say, User login.
I have following use-case: there are several assemblies decorated with ProtoContract classes and I
I have a use case where I need to call a (non-static) method in
I have a use case where I am setting the page focus to a
I have a use case where if a number lies between 0-10 it should
I have this use case of an xml file with input like Input: <abc
I have a use case with NServiceBus explained in this question. Essentially there is

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.