YouTube Icon

Interview Questions.

JSF Interview Questions and Answers - Jul 16, 2022

fluid

JSF Interview Questions and Answers

Q1. What is JSF?

Ans: Java Server Faces (JSF) era is a the front stop framework which makes the advent of consumer interface components less difficult through reusing the UI additives. JSF is designed based on the Model View Controller pattern (MVC) which segregates the presentation, controller and the enterprise common sense.

Q2. What are JSF life cycle phases?

Ans: There are six lifecycle levels particularly;

Restore view phase

Apply request values phase

Process validations section

Update model values phase

Invoke software phase

Render reaction segment

Q3. List  a number of the facelets tags?

Ans: Some of the critical facelets tags are;

<ui:component> tag

<ui:composition> tag

<ui:decorate> tag

<ui:define> tag

<ui:fragment> tag

<ui:include> tag

Q4. What is the significance of @ManagedProperty annotation?

Ans: The @ManagedProperty annotation permits us to inject a controlled bean into some other managed bean.

Q5. What does @ApplicationScoped annotation indicate?

Ans: The @ApplicationScoped annotation shows that the bean is legitimate so long as the net utility is valid.

Q6.  Different varieties of Page Navigation supported in JSF?

Ans: The types of Page navigation supported in JSF are

Implicit Navigation

Navigation thru Managed Bean

Navigation thru faces-config.Xml

Forward as opposed to Redirect navigation

Conditional Navigation

Q7. What is a Managed Bean?

Ans: A controlled bean is a java magnificence registered to JSF which makes interaction between the UI and the commercial enterprise good judgment viable. Managed Beans may be created the use of @ManagedBean annotation.

Q8. What are the three styles of text fields tags provided by way of JSF?

Ans: The three styles of text area tags are;

<h:inputText> – This adds the text container subsequent to the label field.

<h:inputSecret> – This type is used for password fields in which the entered records is hidden.

<h:inputTextarea> – This kind of fields is used while coming into big range of characters.

Q9. What are instantaneous and deferred value expressions?

Ans: Immediate expressions are evaluated and consequences are rendered as soon as the page is displayed to begin with. The syntax for fast evaluation is $.

Deferred expressions are evaluated during the lifecycle segment whenever it's miles asked by using the person. The syntax for deferred assessment is #expression.

Q10. What is Resource bundling in JSF?

Ans: The phenomenon of storing the UI labels, date, reputation messages and different UI textual factors in a separate homes file as opposed to hardcoding these in a page is known as aid bundling.

We can use h:outputLabel element to pick out those values from aid package residences file in JSF view pages.[teaserbox type="4" img="2803" title="Interested in Learning PYTHON" subtitle="Click Here to Join Now" link_url="https://www.Mytectra.Com/python-training-in-bangalore.Html" target="blank"]

Q11. Explain the required and requiredMessage characteristic of the <h:inputText> tag?

Ans: Required attribute indicates that the field is obligatory while set to true. The requiredMessage characteristic allows users to specify their personal message for the ui additives while the fields are obligatory. They are used for declarative validations in JSF view pages.

Q12. Explain value expression and method expressions?

Ans: Value expressions usually fetch a cost or set a value. These expressions can be further categorised into rvalue and lvalue expressions. Lvalue expressions can each read and write records while rvalue expressions can most effective examine statistics.

A technique expression lets in consumer to invoke a public technique of the bean that returns the end result vital for validating the facts element and coping with occasions.

Q13. What are the exclusive forms of validations in JSF?

Ans: There are two kinds of validations specifically;

Declarative Validations: The validations which are fired using JSF popular validators or Bean validators fall under declarative type.

Imperative validation: The fashionable validation messages might no longer be enough in all the cases and every now and then may additionally require complex validations which can be declared via the person overriding the same old validations and these are known as Imperative validations.

HubSpot Video
 

Q14. What are special varieties of expressions supported by JSF EL?

Ans: JSF Expression Language helps following kinds of expressions.

Immediate price expressions

Deferred cost expressions

Value expression and method expression

Q15. What is an event?

Ans: An occasion is defined as a sign caused based upon the person movements inclusive of click on of button, link, converting the enter price and so on. JSF tells the thing to invoke the precise listener class that method the occasion generated by means of the person.

Q16. How can we reap the generated event?

Ans: The generated event may be obtained by calling occasion.GetComponent as

UIComponent ui = new UIComponent(); MyFacesEvent ev1 = new MyFacesEvent(ui); UIComponent sc1 = ev1.GetComponent();

Q17. What are the one-of-a-kind kinds of JSF occasions?

Ans: There are three styles of JSF occasions namely

Action Events: Action activities are the events which can be generated for the ui additives like command button or command hyperlink.

Value Change Events: Value trade events refers back to the UI components textfield, radio button, listing container and so on. The price alternate event will get fired as quickly as the cost is changed within the UI thing.

Phase Events: This form of event involves the activities to be fired in one of the six stages of JSF lifecycle either throughout begin or toward the cease of every phase.

Q18. What is a listener class?

Ans: A magnificence that is associated with an event is known as a listener magnificence. For example, if the occasion is a valueChange event then the corresponding listener elegance ValueChangeListener is related to it.

Q19. What is the significance of facelets tag?

Ans: JSF gives a unique set of tags that gives the flexibility to control common tags/elements in one location for a couple of application. These tags permit us to create a commonplace layout that may be used across programs. You can consist of facelets tags the use of underneath code;

<html xmlns="http://www.W3.Org/1999/xhtml" xmlns:ui="http://java.Sun.Com/jsf/facelets" >

Q20 . Explain @ViewScoped, @SessionScoped, @CustomScoped and @RequestScoped annotations?

Ans:

@ViewScoped: annotation shows that the bean is alive so long as the consumer interacts with the same JSF view web page in the browser.

@SessionScoped: annotation shows that the bean is legitimate so long as the HTTP consultation is alive.

@CustomScoped: annotation suggests that the bean lives so long as the bean’s access inside the custom Map that's created for this scope lives.

@RequestScoped: annotation shows that the Bean lives as long as the HTTP request-reaction lives.

Q21. Mention a number of the attributes of <h:form> tag?

Ans: The critical h:form tag attributes are;

identity: This is the unique identifier used to discover a element.

Identify: A name for an element of the shape used as tooltip.

Onclick: invokes the javascript feature to be called when a button is clicked next to an element.

Onsubmit: invokes javascript function to be referred to as on click of shape via a put up button.

Onreset: Javascript to be invoked at the reset of the elements in a form.

Ondblclick: Javascript code to be finished when the mouse is double clicked over a field in a shape.

Onmouseup: Javascript code to be accomplished when the mouse button is released over a issue.

Onmousedown: Javascript code to be done whilst the mouse pointer is clicked down over this element.

Binding: cost of the expression related to a assets in a backing bean.

Goal: Name of the frame wherein the resource retrieved is to be displayed.

Take delivery of: the contents listing that the shape can take care of.

AcceptCharSet: defines the list of character encoding that the shape will be given.

Fashion: The CSS fashion definitions that can be carried out for the shape

prependId: flag that shows whether identity have to be prepended to the form

dir: Overrides default text functionality for this thing.

Q22. What are the command aspect tags used for motion and navigation?

Ans: The command element tags for performing movement and navigation are

<h:commandButton> tag – The h:commandButton tag renders a button to put up a shape thereby paving a way for processing the records entered with the aid of the consumer.

<h:commandLink> tag – The commandLink gives an hyperlink equal to anchor tag in HTML that acts like a publish button and can be related to the backing beans or action elegance for event dealing with.

Q23. What are Data Bound desk additives?

Ans: The additives which are answerable for displaying the relational information in a tabular layout are referred to as facts bound desk components. The <h:dataTable> tag is used for showing the information components. The <h:column> tag iterates over each record in the data source displayed in rows.

Some of the attributes of the h:dataTable tag are;

bgcolor: historical past colour for the table this is displayed.

Border: width in pixel to be drawn around the desk.

Cellpadding: Space between border of every cellular and its contents.

Cellspacing: Space among left side of the table and leftmost column and also quantity of area among the cells.

ColumnClasses: List of css patterns separated by way of comma to be carried out to the columns of this table.

Bodyrows: List of row indices separated through comma to be implemented for the “tbody” detail should be started out.

Q24. Mention some of the validator tags utilized in JSF?F:validateLength: Validates length of a string

Ans:

f:validateLongRange: Validates variety of numeric value

f:validateDoubleRange: Validates range of waft cost

f:validateRegex: Validate JSF issue with a given regular expression

Q25. What are the blessings of the usage of JSF Framework?

Ans: Some of the benefits of the use of JSF framework are;

Clean separation between presentation and business common sense.

Manages UI country throughout a couple of server requests.

Implementation of custom additives.

Easier go with the flow of data between the additives.

JSF specifications that facilitates custom implementations which include PrimeFaces

Q26. Explain one of a kind ways of maintaining a managed bean in JSF?

Ans:

Use @ManagedBean annotation within the java class indicating that the class is a managed bean as;

@ManagedBean(name="Greetings", eager="actual")If the call attribute isn't always distinctive the name is defaulted to the class call as java naming requirements. For example elegance Car could be named “vehicle” and CarDetails can be named “carDetails”.

Declare the managed bean in faces-config.Xml report as;

<managed-bean> <managed-bean-name>Greetings</managed-bean-name> <managed-bean-class>com.Greetings.Greetings</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean>

Q27. What is the significance of call and eager attributes in controlled bean?

Ans:

call: The name attribute suggests the managed bean with the call unique. If the name isn't always unique then the bean call is equal as the magnificence name.

Eager: If eager is ready to “true” then managed bean is created before it's miles requested for the primary time and if set to fake the bean is created whilst it is requested.

Q28. What is a backing bean?

Ans: A JavaServer Faces utility includes one or more backing beans, every of which is a kind of managed bean that can be associated with the additives used in a selected page.

Q29. List the blessings of Expression Language?

Ans:

Arithmetic, logical, relational operations may be used in expression language.

Automatic kind conversion.

Shows missing values as empty strings in place of NullPointerException.

Provides easy access to predefined gadgets which include request.

Q30. What are special implementations of JSF API?

Ans:

ADF Faces: Oracle’s implementation for the JSF fashionable.

Reference Implementation (RI): through Sun Microsystems.

Apache MyFaces: open source JavaServer Faces (JSF) implementation.

Primefaces: JSF components with Ajax framework.

Q31. Mention a number of the features that the backing bean approach performs?

Ans:

Validating a component’s information

Handling an occasion fired by a factor

Performs processing to determine the subsequent page to which the application have to navigate

Q32. What are standard JSF tag libraries?

Ans:

JSF Core Tags library

JSF HTML tags library

Use under namespace configurations to apply them in JSF xhtml pages.

<html xmlns="http://www.W3.Org/1999/xhtml" xmlns:h="http://java.Sun.Com/jsf/html" xmlns:ui="http://java.Sun.Com/jsf/facelets" xmlns:c="http://java.Sun.Com/jsf/core">

The html tags can now be used as with the h prefix as <h:head>,<h:form> and so on and center tags with c prefix as <c:validateBean>,<c:validator> and so forth.

Q33. What are distinct JSF Converter tags?

Ans:

f:convertNumber: tag is used to convert a string fee to a number of required format.

F:convertDateTime: tag is used to convert a string value to a date of required format.

CustomConverter: lets in person to outline their personal convertor in JSF.

Q34. How distinct components are rendered in JSF page?

Ans: JSF additives are rendered within the xhtml pages with the aid of the tag libraries blanketed, consisting of JSF core, html and facelets tag libraries.




CFG