YouTube Icon

Interview Questions.

Top 39 Javaserver Faces (JSF) Interview Questions - Jul 26, 2022

fluid

Top 39 Javaserver Faces (JSF) Interview Questions

Q1. What Is Javaserver Faces Validation Model?

A mechanism for validating the information a consumer inputs to a JavaServer Faces UI issue.

Q2. What Are The Main Tags In Jsf?

JSF application generally makes use of JSP pages to symbolize perspectives. JSF provides useful special tags to decorate these views. Each tag gives upward thrust to an associated factor.

JSF (Sun Implementation) presents 43 tags in  popular JSF tag libraries:

•JSF Core Tags Library.

•JSF Html Tags Library.

Q3. 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.

Backing Be :

A backing bean is any bean that is referenced by way of a form.

Backing Be should be defined simplest in the request scope.

Managed Be :

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 whilst it's miles needed.

The advantage of controlled be is that the JSF framework will robotically create those be, optionally initialize them with parameters you specify in faces-config.Xml,

The controlled be which can be created by JSF can be saved within the request, consultation, or application scopes.

         Backing Be must be described inside the request scope, exist in a one-to-one courting with a selected page and preserve all the page precise event handling code.In a real-world situation, several pages can also need to share the same backing bean behind the curtain.A backing bean not only includes view statistics, but also conduct associated with that facts.

 

Q4. What Is View Object?

A view object is a version object used mainly inside the presentation tier. It carries the information that must display within the view layer and the good judgment to validate user input, deal with activities, and have interaction with the commercial enterprise-good judgment tier. The backing bean is the view item in a JSF-based software. Backing bean and examine object are interchangeable terms.

 

 

Q5. How To Add Context Path To Url For Outputlink?

Current JSF implementation does no longer upload the context direction for outputLink if the described course starts offevolved with '/'. To correct this hassle use #facesContext.ExternalContext.RequestContextPath prefix at the beginning of the outputLink fee attribute. For ForExample:

<h:outputLink value=”#facesContext.ExternalContext.RequestContextPath/myPage.Faces”> 

Q6. What Is Javaserver Faces Event And Listener Model?

A mechanism for figuring out how activities emitted by JavaServer Faces UI components are handled. This model is based totally at the JavaBe aspect event and listener model.

Q7. What Is Backing Bean?

Backing be are JavaBe additives associated with UI additives used in a page. Backing-bean management separates the definition of UI element items from gadgets that carry out software-precise processing and hold records.

     The backing bean defines houses and handling-logics associated with the UI additives used on the page. Each backing-bean belongings is certain to either a issue example or its fee. A backing bean also defines a set of methods that carry out functions for the component, along with validating the issue's data, dealing with occasions that the component fires and performing processing associated with navigation whilst the thing activates.

Q8. What Is Render Kit In Jsf?

Component lessons typically trfer the mission of producing output to the renderer. All JSF additives comply with it. Render kit is a fixed 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 up to you to make it for different markup languages. Render package can put into effect a pores and skin (a glance & feel).Render package can target a specific tool like smartphone, PC or markup language like HTML, WML, SVG. This is one of the pleasant gain of JSF due to the fact JSF doesn’t restriction to any device or markup.

Q9. What Does It Mean By Render Kit In Jsf?

A render package defines how factor lessons map to issue tags that are appropriate for a particular patron. The JavaServer Faces implementation consists of a wellknown HTML render kit for rendering to an HTML client.

Q10. What Is A Javaserver Faces Application?

JavaServer Faces packages are much like another Java net software. They run in a servlet field, and they typically include the following:

JavaBe additives containing software-unique functionality and information.

Event listeners.

Pages, including JSP pages.

Server-side helper training, which include database get right of entry to be.

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 occasion handlers, validators, and other movements.

UI additives represented as stateful objects at the server.

Backing be, which define residences and features for UI additives.

Validators, converters, event listeners, and event handlers.

An utility configuration useful resource record for configuring software sources.
 

Q11. How Do You Declare The Managed Be In The Faces-config.Xml File?

The bean example is configured within the faces-config.Xml document:

  <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 me: Construct an item of the magnificence com.DevelopersBookJsf.LoginBean, give it the name login, and keep it alive at some stage in the request.

 

Q12. What Is Jsf (or Javaserver Faces)?

A server aspect person interface component framework for Java era-based totally net programs. JavaServer Faces (JSF) is an enterprise popular and a framework for building issue-primarily based person interfaces for web packages. 

JSF consists of an API for representing UI additives and coping with their nation; dealing with events, server-side validation, and information conversion; defining page navigation; supporting internationalization and accessibility; and presenting extensibility for these kinds of capabilities. 

Q13. What Is Javaserver Faces Navigation Model?

A mechanism for outlining the sequence wherein pages in a JavaServer Faces utility are displayed.

Q14. What Are Differences Between Struts And Jsf?

In a nutshell, Faces has the following benefits over Struts:

Eliminated the want for a Form Bean

Eliminated the want for a DTO Class

Allows using the identical POJO on all Tiers due to the Backing Bean

The number one blessings of Struts as compared to JavaServer Faces generation are as follows: 

Because Struts is a web utility framework, it has a greater state-of-the-art controller architecture than does JavaServer Faces era. It is greater sophisticated partly because the utility developer can get admission to the controller with the aid of creating an Action object which could integrate with the controller, whereas JavaServer Faces generation does now not permit get entry to to the controller. In addition, the Struts controller can do such things as get admission to control on every Action primarily based on consumer roles. This capability isn't always furnished by way of JavaServer Faces technology.

Struts includes a powerful layout control framework, known as Tiles, which permits you to create templates that you could reuse throughout multiple pages, consequently enabling you to set up an ordinary appearance-and-feel for an utility.

The Struts validation framework consists of a bigger set of fashionable validators, which mechanically generate both server-facet and patron-facet validation code based totally on a hard and fast of regulations in a configuration record. You can also create custom validators and easily include them for your software by adding definitions of them to your configuration file.

The finest gain that JavaServer Faces generation has over Struts is its flexible, extensible UI component version, which incorporates: 

A preferred aspect API for specifying the nation and conduct of a huge variety of components, which includes simple additives, consisting of input fields, and extra complex components, along with scrollable information tables. Developers can also create their very own components based on these APIs, and lots of 0.33 parties have already achieved so and have made their thing libraries publicly available.

A separate rendering model that defines a way to render the additives in various methods. For example, a thing used for selecting an object from a list can be rendered as a menu or a hard and fast of radio buttons.

An event and listener model that defines the way to deal with occasions generated by means of activating a component, consisting of what to do whilst a consumer clicks a button.

Conversion and validation models for converting and validating issue statistics.

Q15. What Is Managed Bean?

JavaBean items managed by a JSF implementation are referred to as managed be. A managed bean describes how a bean is created and controlled. It has not anything to do with the bean's functionalities

Q16. What Typical Jsf Application Consists Of?

A usual JSF software includes the subsequent elements:

•JavaBe additives for handling software country and conduct.

•Event-driven development (thru listeners as in traditional GUI improvement).

•Pages that represent MVC-fashion perspectives; pages reference view roots through the JSF component tree.

Q17. What Is Javaserver Faces Expression Language?

A simple expression language used by a JavaServer Faces UI aspect tag attributes to bind the related aspect to a bean property or to bind the related thing’s value to a method or an outside information supply, consisting of a bean belongings. Unlike JSP EL expressions, JavaServer Faces EL expressions are evaluated by the JavaServer Faces implementation as opposed to with the aid of the Web field.

 

Q18. What Are The Advantages Of Jsf?

The principal blessings of JavaServer Faces technology are:

JavaServer Faces architecture makes it clean for the builders to use. In JavaServer Faces generation, user interfaces can be created effortlessly with its built-in UI thing library, which handles most of the complexities of consumer interface management.

Offers a clean separation among behavior and presentation.

Provides a rich structure for managing thing nation, processing issue records, validating person input, and handling events.

Robust event handling mechanism.

Events easily tied to server-facet code.

Render kit support for unique clients.

Component-degree manage over statefulness.

Highly 'pluggable' - additives, view handler, and so on.

JSF additionally supports internationalization and accessibility.

Offers a couple of, standardized supplier implementations.

Q19. What Is Javaserver Faces Conversion Model?

A mechanism for converting between string based markup generated with the aid of Java Server Faces UI components and server aspect Java gadgets

Q20. How To Declare The Page Navigation (navigation Rules) In Faces-config.Xml File?

Navigation regulations tells JSF implementation which web page to ship lower back to the browser after a shape 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 declaration states that the login motion navigates to /welcome.Jsp, if it happened internal /index.Jsp.

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

The facts this is manipulated in form or the opposite is performed by way of model. The facts offered to person in a single form or the opposite is carried out by view. JSF is connects the view and the model. View may be depicted as proven by: 

<h:inputText value="#user.Name"/> 

JSF acts as controller through way of movement processing finished by means of the person or triggering of an occasion. For ex. 

<h:commandbutton value="Login" action="login"/> 

this button event will precipitated by means of the user on Button press, which will invoke the login Bean as stated within the faces-config.Xml document. Hence, it is able to be summarized as below: User Button Click -> form submission to server ->; invocation of Bean class ->; end result thrown with the aid of Bean class stuck be navigation rule ->; navigation rule based totally on movement directs to unique page.

Q22. What Do You Mean By Bean Scope?

Bean Scope usually holds be and different gadgets that need to be available in the specific additives of a web application.

 

Q23. How To Declare The Message Bundle In Jsf?

We can declare the message package deal in two methods: 

(Let’s expect com.DevelopersBookJsf.Messages is the houses file)

@ The handiest manner is to consist of the following factors in faces-config.Xml report:

   <application>

<resource-bundle>

<base-name>com.DevelopersBookJsf.Messages</base-name>

<var>message</var>

</resource-bundle>

    </application>

@ Alternatively, you could add the f:loadBundle detail to every JSF page that needs get admission to to the package:

   <f:loadBundle baseName = “com.DevelopersBookJsf.Messages” var=”message”/>

Q24. What Are The Available Implementations Of Javaserver Faces?

The major 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 general.

Q25. What Does It Mean By Rendering Of Page In Jsf?

Every JSF page as described has numerous components made with the assist of JSF library. JSF can also include h:shape, h:inputText, h:commandButton, and so on. Each of these are rendered (trlated) to HTML output. This system is called encoding. The encoding method additionally assigns each factor with a unique ID assigned by means of framework. The ID generated is random.

 

Q26. What Is Javaserver Faces Ui Component?

A user interface control that outputs data to a patron or allows a consumer to enter statistics to a JavaServer Faces utility.

Q27. What Is The Difference Between Jsp-el And Jsf-el?

SP-EL :

In JSP-EL the value expressions are delimited by $….

The $… delimiter denotes the instantaneous assessment of the expressions, on the time that the utility server techniques the page.

JSF-EL :

In JSf-EL the fee expressions are delimited by #….

The #… delimiter denotes deferred assessment. With deferred evaluation ,the utility server keeps the expression and evaluates it on every occasion a fee is needed.
 

Q28. What Is Javaserver Faces Technology?

A framework for building server ­aspect person interfaces for Web programs written within the Java programming language.

Q29. What Is The Difference Between Jsp And Jsf?

JSP truely gives a Page which might also contain markup, embedded Java code,and tags which encapsulate greater complicated logic / html. JSF may additionally use JSP as its template, however presents lots more. This includes alidation, wealthy factor model and lifecycle, more sophisticated EL, separation of records, navigation dealing with, different view technology (as opposed to JSP), ability to offer greater superior features consisting of AJAX, and many others.

Q30. What Is Domain Object Model?

Domain item model is about the business object and have to belong inside the business-logic tier. It carries the commercial enterprise facts and commercial enterprise common sense associated with the particular enterprise object.

Q31. What Is The Difference Between The Domain Object Model And A View Object?

In a simple Web utility, a site object model may be used throughout all levels, however, in a extra complex Web utility, a separate view item model desires for use. Domain item version is set the commercial enterprise item and should belong within the enterprise-good judgment tier. It includes the business records and enterprise good judgment related to the unique commercial enterprise item. A view item consists of presentation-specific statistics and conduct. It includes records and common sense precise to the presentation tier.

Q32. What If No Navigation Rule Matches A Given Action?

If no navigation rule suits a given movement, then the contemporary page is redisplayed.

 

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

JSF supports three Bean Scopes. Viz.,

•Request Scope: The request scope is brief-lived. It starts when an HTTP request is submitted and ends when the response is despatched lower back to the consumer.

•Session Scope: The session scope persists from the time that a consultation is installed until consultation termination.

•Application Scope: The software scope persists for the entire length of the web software. This scope is shared among all of the requests and periods.

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

When you have the following URL: http://your_server/your_app/product.Jsf?Identification=777, you get entry to the passing parameter identity with the following strains of java code: 

FacesContext fc = FacesContext.GetCurrentInstance(); 

String identity = (String) fc.GetExternalContext().GetRequestParameterMap().Get("identity"); 

From the web page, you can get entry to the same parameter the use of the predefined variable with call param. For example, 

<h:outputText value="#param['id']" /> 

Note: You have to call the jsf page at once and the usage of the servlet mapping.

 

Q35. Explain Briefly The Life-cycle Phases Of Jsf?

1.Restore View :   A request comes via the FacesServlet controller. The controller examines the request and extracts the view ID, which is determined by using the call of the JSP page. 

@Apply request values :   The motive of the observe request values section is for each thing to retrieve its present day state. The additives ought to first be retrieved or created from the FacesContext object, followed by way of their values. 

@Process validations :   In this segment, each element can have its values confirmed against the application's validation rules.

@Update model values:   In this section JSF updates the real values of the server-facet version ,with the aid of updating the homes of your backing be.

@Invoke software :   In this phase the JSF controller invokes the application to address Form submissions.

@Render reaction :   In this phase JSF presentations the view with all of its components of their contemporary state.

 

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

Backing Be are merely a conference, a subtype of JSF Managed Be which have a completely unique reason. There is not anything special in a Backing Bean that makes it distinct from every other controlled bean other than its utilization.

Q37. Is It Possible To Have More Than One Faces Configuration File?

We may have any range of config files. Just want to sign up in net.Xml. Assume that we want to apply faces-config(1,2,and 3),to register multiple faces configuration report in JSF,simply claim inside the net.Xml record

 

Q38. What Is Javaserver Faces Ui Component Class?

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

Q39. How To Get Current Page Url From Backing Bean?

You can get a connection with the HTTP request item thru FacesContext like this: 

FacesContext fc = FacesContext.GetCurrentInstance(); 

HttpServletRequest request = (HttpServletRequest) fc.GetExternalContext().GetRequest(); 

after which use the normal request techniques to attain path information. Alternatively, context.GetViewRoot().GetViewId(); 

will return you the call of the current JSP (JSF view IDs are essentially just JSP direction names).




CFG