YouTube Icon

Interview Questions.

Top 100+ Javaserver Faces (jsf) Interview Questions And Answers - May 31, 2020

fluid

Top 100+ Javaserver Faces (jsf) Interview Questions And Answers

Question 1. What Is Jsf (or Javaserver Faces)?

Answer :

A server side user interface issue framework for Java generation-based totally web programs. JavaServer Faces (JSF) is an enterprise general and a framework for building issue-based person interfaces for internet programs. 

JSF carries an API for representing UI additives and managing their kingdom; handling occasions, server-facet validation, and statistics conversion; defining web page navigation; assisting internationalization and accessibility; and providing extensibility for all these features. 

Question 2. What Are The Advantages Of Jsf?

Answer :

The foremost blessings of JavaServer Faces generation are:

JavaServer Faces architecture makes it clean for the developers to use. In JavaServer Faces era, consumer interfaces may be created without problems with its integrated UI factor library, which handles maximum of the complexities of consumer interface control.
Offers a easy separation among behavior and presentation.
Provides a wealthy architecture for dealing with aspect country, processing element statistics, validating person enter, and managing activities.
Robust occasion dealing with mechanism.
Events easily tied to server-facet code.
Render package aid for special clients.
Component-degree control over statefulness.
Highly 'pluggable' - components, view handler, and so forth.
JSF additionally helps internationalization and accessibility.
Offers a couple of, standardized vendor implementations.
Adv Java Interview Questions
Question 3. What Are Differences Between Struts And Jsf?

Answer :

In a nutshell, Faces has the subsequent advantages over Struts:

Eliminated the want for a Form Bean
Eliminated the want for a DTO Class
Allows the use of the identical POJO on all Tiers due to the Backing Bean
The primary benefits of Struts compared to JavaServer Faces era are as follows: 

Because Struts is a web application framework, it has a greater sophisticated controller structure than does JavaServer Faces era. It is extra sophisticated in part because the utility developer can access the controller by growing an Action object which could integrate with the controller, while JavaServer Faces technology does not permit get right of entry to to the controller. In addition, the Struts controller can do such things as get right of entry to manage on every Action primarily based on person roles. This capability is not furnished by JavaServer Faces technology.
Struts includes a effective format management framework, referred to as Tiles, which allows you to create templates that you may reuse throughout a couple of pages, thus enabling you to set up an standard appearance-and-experience for an utility.
The Struts validation framework consists of a larger set of general validators, which automatically generate both server-side and purchaser-facet validation code based on a fixed of guidelines in a configuration report. You can also create custom validators and without difficulty encompass them to your application by including definitions of them to your configuration record.
The greatest advantage that JavaServer Faces generation has over Struts is its flexible, extensible UI issue model, which incorporates: 

A popular aspect API for specifying the nation and behavior of a extensive range of additives, including simple components, which includes enter fields, and more complex components, together with scrollable records tables. Developers also can create their personal additives based on these APIs, and plenty of 1/3 events have already accomplished so and feature made their thing libraries publicly to be had.
A separate rendering version that defines how to render the additives in numerous methods. For example, a element used for selecting an item from a list can be rendered as a menu or a set of radio buttons.
An occasion and listener model that defines the way to cope with activities generated by means of activating a element, along with what to do when a consumer clicks a button.
Conversion and validation fashions for changing and validating issue records.
Question four. What Are The Available Implementations Of Javaserver Faces?

Answer :

The important implementations of JavaServer Faces are:

•Reference Implementation (RI) by Sun Microsystems.
•Apache MyFaces is an open source JavaServer Faces (JSF) implementation or run-time.
•ADF Faces is Oracle’s implementation for the JSF wellknown.

Adv Java Tutorial
Question five. What Typical Jsf Application Consists Of?

Answer :

A regular JSF software consists of the following components:

•JavaBeans components for dealing with application country and behavior.
•Event-driven development (via listeners as in conventional GUI development).
•Pages that constitute MVC-style views; pages reference view roots via the JSF issue tree.

J2EE Interview Questions
Question 6. What Is A Javaserver Faces Application?

Answer :

JavaServer Faces applications are much like any other Java web utility. They run in a servlet box, and that they usually include the following:

JavaBeans additives containing software-unique capability and statistics.
Event listeners.
Pages, along with JSP pages.
Server-facet helper training, together with database get right of entry to beans.
In addition to those items, a JavaServer Faces utility also has:

A custom tag library for rendering UI components on a web page.
A custom tag library for representing event handlers, validators, and other actions.
UI components represented as stateful objects on the server.
Backing beans, which outline houses and capabilities for UI components.
Validators, converters, event listeners, and occasion handlers.
An software configuration aid document for configuring utility assets.
 

Question 7. What Is Managed Bean?

Answer :

JavaBean gadgets controlled through a JSF implementation are known as controlled beans. A managed bean describes how a bean is created and managed. It has not anything to do with the bean's functionalities

J2EE Tutorial Core Java Interview Questions
Question 8. What Is Backing Bean?

Answer :

Backing beans are JavaBeans additives related to UI additives used in a web page. Backing-bean control separates the definition of UI issue items from gadgets that perform software-particular processing and keep statistics.

     The backing bean defines homes and managing-logics associated with the UI additives used on the web page. Each backing-bean belongings is bound to both a thing example or its price. A backing bean additionally defines a hard and fast of strategies that perform functions for the component, such as validating the issue's facts, dealing with activities that the component fires and performing processing associated with navigation when the thing turns on.

Question 9. What Are The Differences Between A Backing Bean And Managed Bean?

Answer :

Backing Beans are simply a conference, a subtype of JSF Managed Beans that have a very unique purpose. There is not anything special in a Backing Bean that makes it special from some other controlled bean other than its utilization.

JSP Interview Questions
Question 10. What Makes A Backing Bean Is The Relationship It Has With A Jsf Page; It Acts As A Place To Put Component References And Event Code.

Answer :

Backing Beans :

A backing bean is any bean this is referenced via a form.
Backing Beans should be defined best within the request scope.
Managed Beans :

A managed bean is a backing bean that has been registered with JSF (in faces-config.Xml) and it automatically created (and optionally initialized) by way of JSF while it is wanted.
The gain of controlled beans is that the JSF framework will mechanically create these beans, optionally initialize them with parameters you specify in faces-config.Xml,
The controlled beans that are created through JSF can be stored within the request, consultation, or application scopes.
         Backing Beans ought to be defined in the request scope, exist in a one-to-one relationship with a selected page and preserve all the web page unique event handling code.In a real-world situation, several pages may additionally need to proportion the same backing bean behind the scenes.A backing bean no longer only carries view records, however additionally conduct related to that facts.

 

Core Java Tutorial
Question eleven. What Is View Object?

Answer :

A view object is a model item used specially inside the presentation tier. It includes the statistics that have to show within the view layer and the logic to validate person enter, deal with activities, and have interaction with the business-good judgment tier. The backing bean is the view item in a JSF-based software. Backing bean and look at item are interchangeable terms.

 

 

Java-Springs Interview Questions
Question 12. What Is Domain Object Model?

Answer :

Domain object model is about the business item and ought to belong within the business-logic tier. It contains the enterprise facts and commercial enterprise good judgment related to the unique commercial enterprise object.

Adv Java Interview Questions
Question thirteen. What Is The Difference Between The Domain Object Model And A View Object?

Answer :

In a simple Web application, a site object version can be used across all tiers, but, in a more complex Web utility, a separate view item model needs to be used. Domain item version is set the enterprise item and should belong within the commercial enterprise-logic tier. It carries the commercial enterprise statistics and business common sense related to the precise enterprise item. A view object consists of presentation-particular facts and behavior. It consists of records and logic precise to the presentation tier.

JSP Tutorial
Question 14. What Do You Mean By Bean Scope?

Answer :

Bean Scope generally holds beans and different items that want to be to be had in the special components of an internet utility.

 

Question 15. What Are The Different Kinds Of Bean Scopes In Jsf?

Answer :

JSF helps three Bean Scopes. Viz.,
•Request Scope: The request scope is brief-lived. It starts offevolved while an HTTP request is submitted and ends while the reaction is sent returned to the patron.
•Session Scope: The session scope persists from the time that a consultation is established till consultation termination.
•Application Scope: The software scope persists for the entire duration of the web utility. This scope is shared amongst all of the requests and sessions.

JMS(Java Message Service) Interview Questions
Question sixteen. What Is The Difference Between Jsp-el And Jsf-el?

Answer :

SP-EL :

In JSP-EL the price expressions are delimited by using $….
The $… delimiter denotes the immediate assessment of the expressions, at the time that the application server approaches the page.
JSF-EL :

In JSf-EL the price expressions are delimited by means of #….
The #… delimiter denotes deferred evaluation. With deferred assessment ,the utility server retains the expression and evaluates it whenever a fee is wanted.
 

Java-Springs Tutorial
Question 17. What Are The Main Tags In Jsf?

Answer :

JSF software commonly makes use of JSP pages to represent perspectives. JSF gives beneficial special tags to decorate those views. Each tag offers upward thrust to an related component.

JSF (Sun Implementation) presents forty three tags in two standard JSF tag libraries:

•JSF Core Tags Library.
•JSF Html Tags Library.

Java applet Interview Questions
Question 18. How Do You Declare The Managed Beans In The Faces-config.Xml File?

Answer :

The bean example is configured within the faces-config.Xml file:
  <managed-bean>
<managed-bean-name>login</managed-bean-name>
<managed-bean-class>com.DevelopersBookJsf.LoginBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
  </managed-bean>
This way: Construct an item of the class com.DevelopersBookJsf.LoginBean, provide it the call login, and maintain it alive at some stage in the request.

 

J2EE Interview Questions
Question 19. How To Declare The Message Bundle In Jsf?

Answer :

We can claim the message bundle in two ways: 
(Let’s count on com.DevelopersBookJsf.Messages is the houses file)
1.  The best manner is to consist of the following elements in faces-config.Xml record:
   <application>
<resource-bundle>
<base-name>com.DevelopersBookJsf.Messages</base-name>
<var>message</var>
</resource-bundle>
    </application>
2.  Alternatively, you may add the f:loadBundle element to each JSF page that wishes get right of entry to to the bundle:
   <f:loadBundle baseName = “com.DevelopersBookJsf.Messages” var=”message”/>

JavaServer Faces (JSF) Tutorial
Question 20. How To Declare The Page Navigation (navigation Rules) In Faces-config.Xml File?

Answer :

Navigation rules tells JSF implementation which page to ship again to the browser after a form has been submitted. We can claim the page navigation as follows:
  <naviagation-rule>
    <from-view-id>/index.Jsp</from-view-id>
    <navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/welcome.Jsp</to-view-id>
    </navigation-case>
  </naviagation-rule>
This statement states that the login motion navigates to /welcome.Jsp, if it came about inner /index.Jsp.

Java Interview Questions
Question 21. What If No Navigation Rule Matches A Given Action?

Answer :

If no navigation rule fits a given motion, then the cutting-edge page is redisplayed.

 

Question 22.  What Are The Jsf Life-cycle Phases?

Answer :

The six phases of the JSF software lifecycle are as follows (notice the occasion processing at each section):

Restore view 
Apply request values; procedure occasions 
Process validations; manner occasions 
Update model values; manner activities
Invoke utility; manner activities
Render reaction
 

Java Tutorial
Question 23. Explain Briefly The Life-cycle Phases Of Jsf?

Answer :

1.Restore View :   A request comes thru the FacesServlet controller. The controller examines the request and extracts the view ID, which is decided by the call of the JSP web page. 
2. Apply request values :   The reason of the practice request values phase is for each issue to retrieve its present day state. The additives must first be retrieved or produced from the FacesContext item, followed by means of their values. 
3. Process validations :   In this section, every aspect will have its values validated towards the application's validation guidelines.
4. Update model values:   In this segment JSF updates the real values of the server-facet model ,through updating the homes of your backing beans.
5. Invoke software :   In this section the JSF controller invokes the application to deal with Form submissions.
6. Render response :   In this section JSF displays the view with all of its components of their modern state.

 

Java eight Interview Questions
Question 24. What Does It Mean By Render Kit In Jsf?

Answer :

A render package defines how component lessons map to component tags which can be suitable for a specific client. The JavaServer Faces implementation includes a preferred HTML render kit for rendering to an HTML customer.

Core Java Interview Questions
Question 25. Is It Possible To Have More Than One Faces Configuration File?

Answer :

We can have any quantity of config documents. Just need to register in net.Xml. Assume that we need to use faces-config(1,2,and 3),to sign in a couple of faces configuration report in JSF,simply declare within the internet.Xml document

 

Java 8 Tutorial
Question 26. What Is Javaserver Faces Event And Listener Model?

Answer :

A mechanism for determining how activities emitted by means of JavaServer Faces UI additives are treated. This version is based on the JavaBeans element event and listener model.

RichFaces Interview Questions
Question 27. What Is Javaserver Faces Conversion Model?

Answer :

A mechanism for converting between string based totally markup generated with the aid of Java Server Faces UI additives and server side Java items

JSP Interview Questions
Question 28. What Is Javaserver Faces Ui Component Class?

Answer :

A JavaServer Faces magnificence that defines the conduct and residences of a JavaServer Faces UI issue.

Apache Struts 2 Tutorial
Question 29. What Is Javaserver Faces Expression Language?

Answer :

A easy expression language utilized by a JavaServer Faces UI aspect tag attributes to bind the associated factor to a bean belongings or to bind the associated aspect’s price to a way or an outside information source, together with a bean property. Unlike JSP EL expressions, JavaServer Faces EL expressions are evaluated via the JavaServer Faces implementation in preference to by means of the Web box.

 

Apache Struts 2 Interview Questions
Question 30. What Is Javaserver Faces Navigation Model?

Answer :

A mechanism for outlining the series in which pages in a JavaServer Faces utility are displayed.

Question 31. What Is Javaserver Faces Technology?

Answer :

A framework for constructing server ­facet consumer interfaces for Web applications written within the Java programming language.

Question 32. What Is Javaserver Faces Ui Component?

Answer :

A person interface manipulate that outputs information to a patron or permits a person to enter information to a JavaServer Faces application.

Java Programmer Interview Questions
Question 33. What Is Javaserver Faces Validation Model?

Answer :

A mechanism for validating the records a user inputs to a JavaServer Faces UI aspect.

Java-Springs Interview Questions
Question 34. What Is The Difference Between Jsp And Jsf?

Answer :

JSP certainly gives a Page which may comprise markup, embedded Java code,and tags which encapsulate more complicated logic / html. JSF may additionally use JSP as its template, but presents a good deal extra. This includes alidation, rich issue model and lifecycle, greater sophisticated EL, separation of records, navigation handling, specific view technology (instead of JSP), potential to provide more superior features consisting of AJAX, and so on.

Question 35. What Is Render Kit In Jsf?

Answer :

Component instructions commonly switch the project of generating output to the renderer. All JSF additives comply with it. Render kit is a hard and fast of associated renderers. Javax.Faces.Render.RenderKit is the magnificence which represents the render package. The default render package contains renderers for html but its as much as you to make it for other markup languages. Render package can enforce a skin (a look & feel).Render kit can target a particular tool like cellphone, PC or markup language like HTML, WML, SVG. This is one of the nice benefit of JSF because JSF doesn’t restrict to any tool or markup.

Question 36. How Does Jsf Depict The Mvc (version View Controller) Model?

Answer :

The data this is manipulated in form or the alternative is carried out through model. The records supplied to user in one form or the alternative is achieved by way of view. JSF is connects the view and the version. View can be depicted as shown by using: 
<h:inputText value="#user.Name"/> 
JSF acts as controller by means of way of action processing carried out by means of the consumer or triggering of an occasion. For ex. 
<h:commandbutton value="Login" action="login"/> 
this button event will caused by means of the person on Button press, in an effort to invoke the login Bean as said within the faces-config.Xml report. Hence, it could be summarized as below: User Button Click -> form submission to server ->; invocation of Bean elegance ->; result thrown by means of Bean class stuck be navigation rule ->; navigation rule primarily based on movement directs to specific web page.

JMS(Java Message Service) Interview Questions
Question 37. What Does It Mean By Rendering Of Page In Jsf?

Answer :

Every JSF web page as described has various components made with the help of JSF library. JSF can also incorporate h:shape, h:inputText, h:commandButton, and so forth. Each of these are rendered (translated) to HTML output. This technique is referred to as encoding. The encoding manner additionally assigns every component with a unique ID assigned by using framework. The ID generated is random.

 

Question 38. How To Pass A Parameter To The Jsf Application Using The Url String?

Answer :

when you have the following URL: http://your_server/your_app/product.Jsf?Id=777, you get right of entry to the passing parameter id with the following traces of java code: 
FacesContext fc = FacesContext.GetCurrentInstance(); 
String identity = (String) fc.GetExternalContext().GetRequestParameterMap().Get("identification"); 
From the web page, you can get admission to the identical parameter the usage of the predefined variable with name param. For instance, 
<h:outputText value="#param['id']" /> 
Note: You have to call the jsf page without delay and the usage of the servlet mapping.

 

Question 39. How To Add Context Path To Url For Outputlink?

Answer :

Current JSF implementation does not upload the context direction for outputLink if the described course starts offevolved with '/'. To correct this trouble use #facesContext.ExternalContext.RequestContextPath prefix at the beginning of the outputLink value attribute. For ForExample:
<h:outputLink value=”#facesContext.ExternalContext.RequestContextPath/myPage.Faces”> 

Question 40. How To Get Current Page Url From Backing Bean?

Answer :

You can get a reference to the HTTP request item via FacesContext like this: 
FacesContext fc = FacesContext.GetCurrentInstance(); 
HttpServletRequest request = (HttpServletRequest) fc.GetExternalContext().GetRequest(); 

and then use the regular request methods to gain course facts. Alternatively, context.GetViewRoot().GetViewId(); 

will go back you the call of the modern JSP (JSF view IDs are essentially simply JSP course names).

Java applet Interview Questions




CFG