Solution:NIIT/GNIIT Sonugiri0032@gmail.com

Monday, March 12, 2018

SF Interview Questions


A list of top frequently asked JSF interview questions and answers are given below.

1) What is JSF (JavaServer Faces)?

It is a server side component based user interface framework. It is used to develop web applications. It provides a well-defined programming model and consists of rich API and tag libraries. The latest version JSF 2 uses Facelets as its default templating system.
For more information: Click here

2) What are the benifits of JSF (JavaServer Faces)?

It provides clean and clear separation between behavior and presentation of web application. You can write business logic and user interface separately.
For more information: Click here

3) What are the features of JSF (JavaServer Faces)?

Latest version of JSF 2.2 provides the following features.
  • Component Based Framework
  • Implements Facelets Technology
  • Integration with Expression Language
  • Support HTML5
  • Ease and Rapid web Development.
  • Support Internationalization
  • Bean Annotations
For more information: Click here

4) What is lifecyle of JSF (JavaServer Faces)?

JavaServer Faces application framework manages lifecycle phases automatically for simple applications and also allows you to manage that manually. The lifecycle of a JavaServer Faces application begins when the client makes an HTTP request for a page and ends when the server responds with the page.
For more information: Click here

5) How does execution phase work in JSF (JavaServer Faces) lifecyle?

In execute phase, when first request is made, application view is built or restored. For other subsequent requests other actions are performed like request parameter values are applied, conversions and validations are performed for component values, managed beans are updated with component values and application logic is invoked.
For more information: Click here

6) How does render phase work in JSF (JavaServer Faces) lifecyle?

In this phase, the requested view is rendered as a response to the client browser. View rendering is a process in which output is generated as HTML or XHTML. So, user can see it at the browser.
For more information: Click here

7) What is managed bean in JSF (JavaServer Faces)?

It is a pure Java class which contains set of properties and set of getter, setter methods.
Following are the common functions that managed bean methods perform:
  • Validating a component's data
  • Handling an event fired by a component
  • Performing processing to determine the next page to which the application must navigate
For more information: Click here

8) How to configure managed bean in XML file?

In thiscase, we configure bean-name, bean-class and bean-scope in XML file. So, it can be accessible in the project. This is an older approach to configure bean into xml file.
For more information: Click here

9) What are the available scopes for managed bean?

You can use following scopes for a bean class:
  • Application (@ApplicationScoped): Application scope persists across all users? interactions with a web application.
  • Session (@SessionScoped): Session scope persists across multiple HTTP requests in a web application.
  • View (@ViewScoped): View scope persists during a user?s interaction with a single page (view) of a web application.
For more information: Click here

10) What is eager managed bean?

Managed bean is lazy by default. It means, bean is instantiated only when a request is made from the application.
You can force a bean to be instantiated and placed in the application scope as soon as the application is started.
For more information: Click here

11) What are User Interface Components in JSF (JavaServer Faces)?

JavaServer Faces HTML tag library represents HTML form components and other basic HTML elements, which are used to display or accept data from the user. A JSF form send this data to the server after submitting the form.
For more information: Click here

12) What is h:inpuText tag in JSF (JavaServer Faces)?

The JSF <h: inputText> tag is used to render an input field on the web page.
It is used within a <h: form> tag to declare input field that allows user to input data.
For more information: Click here

13) What is h:outputText tag in JSF (JavaServer Faces)?

The JSF <h:outputText> is used to render a plain text. If the "styleClass", "style", "dir" or "lang" attributes are present, render a "span" element. If the "styleClass" attribute is present, render its value as the value of the "class" attribute.
For more information: Click here

14) What is h:form tag in JSF (JavaServer Faces)?

The <h:form> tag represents an input form. It includes child components that can contain data which is either presented to the user or submitted with the form. It can also include HTML markup to lay out the components on the page.
For more information: Click here

15) What is h:commandButton tag in JSF (JavaServer Faces)?

The <h:commandButton>tag creates a submit button and used to submit a application form.
For more information: Click here

16) What is h:inputTextarea tag in JSF (JavaServer Faces)?

The <h:inputTextarea>tag renders an HTML "textarea" element. It allows a user to enter multiline string.
For more information: Click here

17) What is h:commandLink tag in JSF (JavaServer Faces)?

JSF renders it as an HTML "a" anchor element that acts like a form submit button when clicked. So, you can create anchor tag by using this tag. An h:commandLink tag must include a nested h:outputText tag, which represents the text that the user clicks to generate the event. It's also required to be placed inside a <h:form> tag.
For more information: Click here

18) What is h:inputSecret tag in JSF (JavaServer Faces)?

It is a standard password field which accepts one line of text with no spaces and displays it as a set of asterisks as it is entered. In other words, we say, it is used to create a HTML password field which allows a user to input a string without the actual string appearing in the field.
For more information: Click here

19) What is h:inputHidden tag in JSF (JavaServer Faces)?

It renders an HTML "input" element of type hidden. It does not appear in web page, so you can pass hidden information while submitting form.
For more information: Click here

20) What is h:inputFile tag in JSF (JavaServer Faces)?

JSF renders it as an HTML element of type file. It is used to get file as input. In HTML form, it allows a user to upload a file.
For more information: Click here

21) What is h:graphicImage tag in JSF (JavaServer Faces)?

JSF renders an HTML element "img" tag. This tag is used to render an image on the web page.
For more information: Click here

22) What is h:message tag in JSF (JavaServer Faces)?

It is used to display a single message for a particular component. You can display your custom message by passing id of that component into the for attribute.
For more information: Click here

23) What is h:messages tag in JSF (JavaServer Faces)?

It is used to displays all messages that were stored in the faces context during the course of the JSF life cycle.
For more information: Click here

24) What is h:dataTable tag in JSF (JavaServer Faces)?

It is used to create a data table. A table that can be updated dynamically.
For more information: Click here

25) What are available validation tags in JSF (JavaServer Faces)?

JavaServer Faces technology provides a set of standard classes and associated tags that you can use to validate elements data. A table which contains the validation tags is given.
For more information: Click here

26) What is f:validateBean tag in JSF (JavaServer Faces)?

It is used to register a bean validator to the component. For validating bean model, you must set the context parameter in the web deployment descriptor file web.xml.
For more information: Click here

27) What is f:validateDoubleRange tag in JSF (JavaServer Faces)?

It is used to check that the value of a input field is within a certain range or not. The value must be a float or double type.
For more information: Click here

28) What is f:validateLength tag in JSF (JavaServer Faces) ?

It is used to check whether the length of a component's value is within a certain range or not. The value must be a java.lang.String.
For more information: Click here

29) What is f:validateLongRange tag in JSF (JavaServer Faces)?

It is used to check whether the local value of a component is within a certain range or not. The value must be any numeric type or String that can be converted to a long.
For more information: Click here

30) What is f:validateRegex tag in JSF (JavaServer Faces)?

It is used to check whether the local value of a component is a match against a regular expression from the java.util.regex package or not.
For more information: Click here

31) What is f:validateRequired tag in JSF (JavaServer Faces)?

It is used to ensure that the local value is not empty on an EditableValueHolder component.
For more information: Click here

32) How to validate managed bean in JSF (JavaServer Faces)?

JSF provides validation constraints for bean model in the form of annotations. You can place that annotations on a field, method, or class of a JavaBeans component, such as a managed bean.
For more information: Click here

33) What are standard converters in JSF (JavaServer Faces)?

The JavaServer Faces provides a set of Converters. You can use that to convert component data. The purpose of conversion is to take the String-based data from the Servlet API and convert it to strongly typed Java objects.
For more information: Click here

34) What is f:converter tag in JSF (JavaServer Faces)?

It is a core converter tag. It is used to add an arbitrary converter to the parent component.
For more information: Click here

35) What is f:convertDateTime tag in JSF (JavaServer Faces)?

It is used to convert user input into specified date. You can convert a component's data to a java.util.Date by nesting the convertDateTime tag inside the component tag. The convertDateTime tag has several attributes that allow you to specify the format and type of the data.
For more information: Click here

36) What is f:convertNumber tag in JSF (JavaServer Faces)?

It is used to convert component (user input) data into a Java Number type. You can convert a component's data to a java.lang.Number by nesting the convertNumber tag inside the component tag. The convertNumber tag has several attributes that allow you to specify the format and type of the data.
For more information: Click here

37) How to refer bean method in JSF (JavaServer Faces)?

We refer a managed bean method that performs navigation processing for the component and returns a logical outcome String.
For more information: Click here

38) What is Facelets?

It is a light weight page declaration language which is used to build JavaServer Faces views using HTML style.
For more information: Click here

39) What are advantages of Facelets?

1) It supports code reusabilty through templating and composite components.
2) It provides functional extensibility of components and other server-side objects through customization
For more information: Click here

40) What is lifecyle of Facelets application in JSF (JavaServer Faces)?

The JavaServer Faces specification defines the lifecycle of a JavaServer Faces application. The following steps describe that process to a Facelets-based application.
1) Lifecycle starts when a client makes a new request for a web page which is created using Facelets. JSF creates a new component tree or javax.faces.component.UIViewRoot and placed into the FacesContex.
For more information: Click here

41) How to create a Fecelet view?

Facelets views are XHTML pages. You can create a web page or view, by adding components to the page, wire the components to backing bean values and properties, and register converters, validators, or listeners on the components.
For more information: Click here

42) How to map Faces Servlet instance in JSF (JavaServer Faces) application?

Configure of a JavaServer Faces application is done by mapping the Faces Servlet in the web deployment descriptor file a web.xml.
For more information: Click here

43) What are Facelets Templates?

It is a tool which provides the facility to implement the user interface. Templating is a useful Facelets feature that allows you to create a page that will act as the base for the other pages in an application. By using templates, you can reuse code and avoid recreating similarly pages again and again.
For more information: Click here

44) How to create Facelets Templates?

Templating is a useful Facelets feature that allows you to create a page that will act as the base for the other pages in an application.
For more information: Click here

45) What are Facelets Composite Components?

JSF provides the concept of composite components with Facelets. Composite component is a special type of template that acts as a component in your application.
For more information: Click here

46) What are web resources in JSF (JavaServer Faces)?

JSF web resources are the resources which are required for proper rendering in the web application. It includes images, script files, and any user-created component libraries.
For more information: Click here

47) How to access CSS (Cascading Style Sheets) File in JSF (JavaServer Faces) application?

The <h:outputStylesheet> tag is used to access CSS (Cascading Style Sheets) resource in the web application. You must create a subdirectory inside the resources folder.
For more information: Click here

48) How to access JS (JavaScript) File in JSF (JavaServer Faces) application?

The <h:outputScript> tag is used to access JavaScript file in the web application. You must create a subdirectory inside the resources folder.
For more information: Click here

49) How to relocate web resources in JSF (JavaServer Faces) application?

JSF provides a facility to place your resources at any section of your web page and render it to another section. . You can relocate your resource by specifying target attribute.
For more information: Click here

50) How to create JDBC (Java Database Connectivity) connection in JSF (JavaServer Faces) application?

You can integrate JSF application to the jdbc. JDBC allows you to store data into the database table.
For more information: Click here 
Share:

0 comments:

GNIITSOLUTION GNIIT SOLUTION. Powered by Blogger.

Translate

Blog Archive

Unordered List