JSF Interview questions

Q: 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 "message.properties" like :
prompt=Enter Your Name:
greeting_text=Welcome In Roseindia
button_text=Submit

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

<application>
<message-bundle>roseindia.messages</message-bundle>
</application>

Q: 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"/>

Q: We can now use this in our JSP like below :
<h:outputText value="#{message.prompt}"/>
Q: 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 :
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/WEB-INF/test1-config.xml,/WEB-INF/test2-config.xml
</param-value>
</context-param>
Q: 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 http://java.sun.com/dtd/web-facesconfig_1_0.dtd. Now register the file within context-param element in web.xml file.


Q: What is JSF (or JavaServer Faces)?
A server side user interface component framework for Java™ technology-based web applications.JavaServer Faces (JSF) is an industry standard and a framework for building component-based user interfaces for web applications.

JSF contains an API for representing UI components and managing their state; handling events, server-side validation, and data conversion; defining page navigation; supporting internationalization and accessibility; and providing extensibility for all these features.
SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment