Here you can find JSF Interview Questions and Answers.
In this JSF Interview Questions and Answers section you can learn and practice JSF Interview Questions and Answers to improve your skills in order to face technical inerview by IT companies. By Practicing these interview questions, you can easily crack any JSF interview.
AllIndiaExams provides you lots JSF Interview Questions and Answers with proper explanation. Fully solved examples with detailed answer description. All students, freshers can download JSF Interview Questions and Answers as PDF files and eBooks.
You no need to worry, we have given lots of JSF Interview Questions and Answers and also we have provided lots of FAQ's to quickly answer the questions in the JSF technical interview.
What is JSF?
* JSF stands for Java Server Faces. JSF has set of pre-assembled User Interface (UI). * By this it means complex components are pre-coded and can be used with ease. * It is event-driven programming model. By that it means that JSF has all necessary code for event handling and component organization. * Application programmers can concentrate on application logic rather sending effort on these issues. * It has component model that enables third-party components to be added like AJAX.
What is required for JSF to get started?
Following things required for JSF: • JDK (Java SE Development Kit) • JSF 1.2 • Application Server (Tomcat or any standard application server) • Integrated Development Environment (IDE) Ex. Netbeans 5.5, Eclipse 3.2.x, etc. Once JDK and Application Server is downloaded and configured, one can copy the JSF jar files to JSF project and could just start coding. :-) If IDE is used, it will make things very smooth and will save your time.
What is JSF architecture?
JSF was developed using MVC (a.k.a Model View Controller) design pattern so that applications can be scaled better with greater maintainability. It is driven by Java Community Process (JCP) and has become a standard. The advantage of JSF is that itâ€™s both a Java Web user â€“ interface and a framework that fits well with the MVC. It provides clean separation between presentation and behavior. UI (a.k.a User Interface) can be created by page author using reusable UI components and business logic part can be implemented using managed beans.
How JSF different from conventional JSP / Servlet Model?
JSF much more plumbing that JSP developers have to implement by hand, such as page navigation and validation. One can think of JSP and servlets as the assembly language under the hood of the high-level JSF framework.
How the components of JSF are rendered? An Example
<%@ taglib uri="http://Java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://Java.sun.com/jsf/html" prefix="h"%> Or one can try XML style as well: xmlns:f="http://Java.sun.com/jsf/core" xmlns:h="http://Java.sun.com/jsf/html"> Once this is done, one can access the JSF components using the prefix attached. If working with an IDE (a.k.a Integrated Development Environment) one can easily add JSF but when working without them one also has to update/make the faces-config.xml and have to populate the file with classes i.e. Managed Beans between tags
How to declare the Navigation Rules for JSF?
Navigation rules tells JSF implementation which page to send back to the browser after a form has been submitted. For ex. for a login page, after the login gets successful, it should go to Main page, else to return on the same login page, for that we have to code as: /login.jsp login /main.jsp fail /login.jsp from-outcome to be match with action attribute of the command button of the login.jsp as: Secondly, it should also match with the navigation rule in face-config.xml as user core.jsf.LoginBean session In the UI component, to be declared / used as: value attribute refers to name property of the user bean.
How do I configure the configuration file?
The configuration file used is our old web.xml, if we use some IDE it will be pretty simple to generate but the contents will be something like below: xmlns:xsi="e;http://www.w3.org/2001/XMLSchema-instance"e; xsi:schemaLocation="e;http://java.sun.com/xml/ns/j2ee http://java.sun. com.sun.faces.verifyObjects false com.sun.faces.validateXml true javax.faces.STATE_SAVING_METHOD client Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet /faces/* 30 index.jsp The unique thing about this file is ?servlet mapping?. JSF pages are processed by a servlet known to be part of JSF implementation code. In the example above, it has extension of .faces. It would be wrong to point your browser to http://localhost:8080/MyJSF/login.jsp, but it has to be http://localhost:8080/MyJSF/login.faces. If you want that your pages to be with .jsf, it can be done with small modification :-), Faces Servlet *.jsf
What is JSF framework?
JSF framework can be explained with the following diagram: As can be seen in Figure 1, JSF interacts with Client Devices which ties together with presentation, navigation and event handling and business logic of web tier model. Hence JSF is limited to presentation logic / tier. For Database tier i.e. Database and Web services one has to rely on other services.
How does JSF depict the MVC (a.k.a Model View Controller) model?
The data that is manipulated in form or the other is done by model. The data presented to user in one form or the other is done by view. JSF is connects the view and the model. View can be depicted as shown by: JSF acts as controller by way of action processing done by the user or triggering of an event. For ex. , this button event will triggered by the user on Button press, which will invoke the login Bean as stated in the faces-config.xml file. Hence, it could be summarized as below: User Button Click -> form submission to server -> invocation of Bean class -> result thrown by Bean class caught be navigation rule -> navigation rule based on action directs to specific page.
What does it mean by rendering of page in JSF?
Every JSF page as described has various components made with the help of JSF library. JSF may contain h:form, h:inputText, h:commandButton, etc. Each of these are rendered (translated) to HTML output. This process is called encoding. The encoding procedure also assigns each component with a unique ID assigned by framework. The ID generated is random.