Share on Google+Share on Google+

JSF Interview Questions

How can we replace the JSF Standard Error Message? Create the message bundle file and set the value of the key for a particular type of error specified in JSF specification.

JSF Interview Questions


  1. How can we replace the JSF Standard Error Message?
    Create the message bundle file and set the value of the key for a particular type of error specified in JSF specification.
    For example, JSF specification supplies value "Value is required" for key "javax.faces.component.UIInput.REQUIRED" so replace the value in our message bundle file similar to the following :
     javax.faces.component.UIInput.REQUIRED= Please enter the required value.

    Register the message bundle within <application> tag  in the configuration file (faces-config.xml) and restart the server. Now when we use message or messages tag in the view page then the value specified in this message bundle file for a particular error is displayed.

  2. How we can change the appearance of error messages in a JSF Page?
    The appearance can be changed by any of the two methods :
    Using "style" attribute or "styleClass" attribute. "style" attribute is used to set the CSS style definition for the component while styleClass attribute is used to set the CSS class for the component. Using "styleClass" attribute is same as html "class" attribute.
  3. What is the significance of properties file (Resource Bundle) and how to use this in our JSF page?
    Properties file is a collection of param=value pairs. This provides a great benefit to the application like we can modify these values easily and there is no need to change the JSP file. For example, we can create "" like :
    prompt=Enter Your Name:
    greeting_text=Welcome In Roseindia

    Now edit the configuration file using <message-bundle> element which tells the application where the message resource file is located.


    Now, message resource bundle is loaded first using core tag <f:loadBundle> in view page. That loads the bundle and stores it in the request scope. 

    <f:loadBundle basename="roseindia.messages" var="message"/>

    We can now use this in our JSP like below :

    <h:outputText value="#{message.prompt}"/>
  5. How can I use several configuration resource files in one single application?
    JSF finds configuration file or files looking in context initialization parameter, javax.faces.CONFIG_FILES  in web.xml, that specifies one or more paths to multiple configuration files for your web application. These multiple paths must be comma separeted. The important point to remember is not to register /WEB-INF/faces-config.xml file in the web.xml. Otherwise, the JSF implementation will process it twice. For example, make changes in web.xml like below :
  6. Can we use a different configuration resource file in place of traditional "faces-config.xml" file in our application?
    JavaServer Faces technology provides an XML document for configuring resources. This file is used to register application's resources, such as validators, converters, managed beans, and navigation rules. This application configuration resource file is usually called faces-config.xml. You can have more than one application configuration resource file but it must be valid against the DTD located at Now register the file within context-param element in web.xml file.



Posted on: February 27, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: JSF Interview Questions  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image