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

  • Home
  • SEARCH
  • 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 8307671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:34:31+00:00 2026-06-08T18:34:31+00:00

In my JSF project, i have something like this <h:outputText value=#{msg[foo]} /> where msg

  • 0

In my JSF project, i have something like this

<h:outputText value="#{msg[foo]}" />

where msg is my ResourceBundle and foo is the variable for the identifier of the properties, containing for example label.car, so that the code would return either car or Auto (internationalization).

The problem:

If foo is set to a property identifier which doesn’t exist in the ResourceBundle, lets say boat, the app, of course, crashes with a javax.el.PropertyNotFoundException.

While in Spring there is a way to handle this as a fallback with a default message..

<spring:message code="${foo}" text="${foo}" />

(returning the identifier itself instead of it’s internationalized value)

..I was not able to do this in JSF.

Any hints how something similar to this is possible in JSF? Thanks!

//Update:
– Apache Tomcat/6.0.29
– Apache MyFaces-2
– PrimeFaces 3.3
– tomcat-maven-plugin:1.1
– Java version number: 1.7.0_05
– Hibernate 3.5.6-Final

  • 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-08T18:34:32+00:00Added an answer on June 8, 2026 at 6:34 pm

    I ‘solved’ the problem by adding my own tag imitating the Spring-behavior by doing this:

    (excerpt of my TagHandler implementation)

    value = getAttribute("value").getValue(context);
    ...
    key = getAttribute("key").getValue(context);
    ...
    if (key != null) {
      try {
        w.write(String.format("%s", getLocalizedString(key, bundle)));
      } catch (final Exception cause) {
        if (value != null) {
          w.write(String.format("%s", value));
        } else {
          // exception / invalid key
        }
      }
    
    } else if (value != null) {
      w.write(String.format("%s", value));
    } else {
      // exception / do noting
    }
    

    So I am able to use this like:

    <my:outputText key="#{key}" value="#{fallback_value}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a maven project, and then, i would like to enable JSF 2
I have a JSF project working with JPA, I do this : retrive some
I have imported a JSF/Facelets project from SVN into Netbeans. Any change which I
I am working on project in JSF, using Tomcat 7. The application will have
So I have imported a project to netbeans. I am using jsf and xhtml
I use Richfaces, Seam and JSF, and I want something like the following: and
I have a War and Jar project in my Eclipse-based JSF project. I have
I have easily created a JSF project with NetBeans that delivers a web service
I have the following scenario in my project based on JSF and RF3.3 1.Each
I have a JSF project and I already have an index.xhtml page which 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.