Interview Questions and Answers on Java EE – Java Server Faces (JSF) – Part 1

What is JSF?

Java Server Faces (JSF) is a framework for web applications written in Java. It serves to facilitate the development of user interfaces for Java EE-applications. Unlike other MVC frameworks that are managed by queries, the JSF approach is based on the use of components. The state of the user interface components is retained when the user requests a new page and then restores if the request is repeated.

JavaServer Faces technology includes a set of APIs for representing user interface components (UI) and managing their state, processing events and validating input information, defining navigation, as well as supporting internationalization (i18n) and accessibility. JSF 2.0 uses the Facelets technology as the view handler, which came to replace JSP.

What is Managed Bean?

In JSF technology, managed beans are used to save the state of web pages. Creation and manipulation of beans are carried out under the control of the implementation of JSF, which performs the following:

  • Creating and destroying beans as needed (this explains the origin of the term “managed beans”). To create, you can use the @ManagedBean annotation.
  • Reading the properties of a bin when displaying a web page
  • Specifying the properties of a bean when sending a form

What are the three types of tags for text fields exist in JSF?

<h: inputText> is the standard text field for data entry.

<h: inputSecret> – the input data is hidden (for example by dots).

<h: inputTextarea> – used to enter large amounts of textual information.

Explain the purpose of the <h: form> tag.

The <h: form> tag generates an HTML form element that uses the “POST” request to confirm the form and transfer data from the form. The behavior when decoding: receives a Map from the “request parameter map” property from ExternalContext. If the map contains the “clientId” of this UIForm component, then submitted (true) is called on the form; otherwise, it is called setSubmitted (false) on the form.

Coding behavior: The value of the “method” attribute must be “post”. The value of the “action” attribute must be the result of passing the current view’s identifier to the getActionURL () method from the ViewHandler of this application, then passing the String to the encodeActionURL () method from ExternalContext. You must call ViewHandler.writeState () before closing the “form” element. More details on the details of the behavior of the form can be found on the Oracle website.

What tags are used for action and navigation?

The tags for the action and navigation commands are:

<h: commandButton> – generates an HTML button that confirms the form and thus allows you to begin processing the data entered by the user.

<h: commandLink> – Generates an HTML hyperlink, equivalent to an anchor tag in HTML. It can be associated with a managed bean or Action class to handle events.

What components are used to display data in a tabular form?

The main component for working with tables is <h: dataTable>. It contains extensive display and interaction settings between the view and managed beans.

What is an event?

An event is a reaction to a user’s action, such as clicking a button, activating a link, or modifying a component. JSF supports listeners (listeners) that respond to various emerging events and allow them to be processed.

Close

About The Author

Ruchi Singla
An enthusiast writer with years of experience, who loves to create beautiful thoughts into words. She writes with a zeal and enjoys reading vogue with a good cup of coffee when not writing. Ruchi is working as a content writer for many businesses, helping them gain an extra edge over their competitors. As a content writer, she is responsible for enhancing engagement and traffic on the blog by brainstorming exciting content ideas.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.