News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

JSF Interview Questions - Part - 1

Started by ganeshbala, Jul 05, 2008, 06:57 PM

Previous topic - Next topic

ganeshbala

JSF Interview Questions


1.  What is JSF life cycle and its phases?
      The series of steps followed by an application is called its life cycle. A JSF application typically follows six steps in its life.
         1. Restore view phase
         2. Apply request values phase
         3. Process validations phase
         4. Update model values phase
         5. Invoke application phase
         6. Render response phase


2. What is the role of Renderer in JSF? and justify the statement "JSF supports multiple client devices".

      After creating JSF components, it is also necessary  for each component to be rendered to the client so that it can be visible to the client's device. Each of the tag gives rise to an associated component. A renderer is a type of class that is responsible for encoding and decoding components. Encoding displays the component while decoding translates the user's input into components value i.e. transform it into values the component can understand.
      Now a days there are many devices that are web enabled. So application developers have challenge to develop components that can work across various platforms. For example, if we have an application that works on standard web browser and we want to extend it to make it enable to work on a WAP device. So, to handle this case we need components to be rendered in more than one way. Here JSF can be helpful. This is a simple task for JSF. The solution is to develop separate renderers for the component. JSF components use different renderers depending on the device used.


3. What is Render Kit in JSF?

      Component classes generally transfer the task of generating output to the renderer. All JSF components follow it. Render kit is a set of related renderers. javax.faces.render.RenderKit is the class which represents the render kit. The default render kit contains renderers for html but it's up to you to make it for other markup languages. Render kit can implement a skin (a look & feel). Render kit can target a specific device like phone, PC or markup language like HTML, WML, SVG. This is one of the best benefit of  JSF because JSF doesn't limit to any device or markup.


4. What is conversion and validation? and how are they related?

      This is one of the phase of JSF life cycle that happens before binding the component data to the related backing bean in the Update model values phase.
      Conversion is the process of transforming the component data from String to Java objects and vice versa. For example, an user enters a value (String) in an input component and this value is to store in a Date field in the backing bean then this String value is converted to a java.util.Date value when request is sent to the server and vice versa. This process is called Conversion.
      Validation is the process of ensuring data contains the expected content. For example, checking the Date value is in MM./dd/YYYY format or any integer value is between 1 to 10.
      The main purpose of conversion and validation is to ensure the values are of correct type and following the required criteria before updating model data. So this step allows you to focus on business logic rather than working on tedious qualifications of input data such as null checks, length qualifiers, range boundaries, etc.


5. When automatic conversion is supplied by JSF Implementation?

      JSF implementation automatically converts component data between presentation view and model when the bean property associated with the component is of one of the types supported by the component's data.
      For example, If a UISelectBoolean component is associated with a bean property of type Boolean, then JSF implementation will automatically convert the data from String to Boolean.


6.  What does component mean and what are its types?

      Components in JSF are elements like text box, button, table etc. that are used to create user interfaces of JSF Applications. These are objects that manage interaction with a user. Components help developers to create UIs by assembling a number of components , associating them with object properties and event handlers. Would u like to repeat the same code again & again and waste time if u want to create many tables in hundreds of pages in your web application? Not at all. Once you create a component, it's simple to drop that component onto any JSP. Components in JSF are of two types :
         1. Simple Components like text box, button and
         2. Compound Components like table, data grid etc.

A component containing many components inside it is called a compound component.

JSF allows you to create and use components of two types:

   1. Standard UI Components:
      JSF contains its basic set of  UI components like text box, check box, list boxe, button, label, radio button, table, panel etc. These are called standard components.
   2. Custom UI Components:
      Generally UI designers need some different , stylish components like fancy calendar, tabbed panes . These types of components are not standard JSF components. JSF provides this additional facility to let you create and use  your own set of reusable components. These components are called custom components.

7. What are third party components and how they are useful?
      One of the greatest power of JSF is to support third party components . Third party components are custom components created by another vendor. Several components are available in the market, some of them are commercial and some are open source . These pre-built & enhanced components can be used in UI of your web application. For example, we are in need of a stylish calendar then we have an option to take it from third party rather than creating it our own. This will help saving time & cost creating effective & robust UI and to concentrate on business logic part of web application.


8. What are tags in JSF ?

      JSF application typically uses JSP pages to represent views. JSF provides useful special tags to enhance these views. Each tag gives rise to an associated component. JSF (Sun Implementation) provides 43 tags in two standard JSF tag libraries:
         1. JSF Core Tags  Library
         2. JSF Html Tags Library

      Even a very simple page uses tags from both libraries. These tags can be used adding the following lines of code at the head of the page.

      <%@ taglib uri="http://java.sun.com/jsf/core " prefix="f" %> (For Core Tags)
      <%@ taglib uri="http://java.sun.com/jsf/html " prefix="h" %> (For Html Tags)



9. What is the difference between JSP and JSF?

      JSP simply provides a Page which may contain markup, embedded Java code, and tags which encapsulate more complicated logic / html.
      JSF may use JSP as its template, but provides much more. This includes validation, rich component model and lifecycle, more sophisticated EL, separation of data, navigation handling, different view technologies (instead of JSP), ability to provide more advanced features such as AJAX, etc.