Friday 6 January 2017

JSF Interview Questions and Answers - JavaServer Faces




JSF and AJAX
 AJAX and JSF together makes a rich web application. AJAX usage is focused on creating richer user interfaces..
JSF Ajax components
The custom web tier components for JSF can be developed using AJAX along with JSF...
Explain how JSF supports AJAX
 A JSF component supports the client-side AJAX Java Script and processes the AJAX requests...
JSF Architecture
 JSF developed based on MVC design pattern. Therefore, the applications can be scaled better and well maintained..
How JSF different from conventional JSP?
 In JSP, page navigation and validation should be implemented by developers...
How the components of JSF are rendered?
Add JSF libraries to an application. Add the .jsp tag libraries in the .jsp page like:...
How to declare the Navigation Rules for JSF?
A navigation rule specifies the JSF implementation which page need to send back to the browser after submitting a form...

What is JSF framework?
JSF framework is an API for developing user interface components for web applications...
What does it mean by rendering of page in JSF?
A JSF page has components that are made with the help of JSF library. The JSF components lke h:form...
What is JSF, JavaServer Faces?
JavaServer Faces (JSF) is a server side Java technology, developed by Sun Microsystems, in the field of web application development.
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 â€oeassembly languageâ€? under the hood of the high-level JSF framework.
 How the components of JSF are rendered? An Example
In an application add the JSF libraries. Further in the .jsp page one has to add the tag library like:
<%@ 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:
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




No comments:

Post a Comment