jsf-facelets interview questions

10
1. What is a web application? Answer: A web application is a dynamic extension of a web or application Server. 2. What is facelets? 3. Answer: The term facelets refer to the view declaration for Java Server faces technology. Facelets is a lightweight but powerful page declaration language that is used to build Java Server Faces views using HTML style template and to build component trees 4. What language is used to create Facelet views? Answer: XHTML 5. what is the prefix for JavaServer Faces Facelets Tag Library? Answer: ui: 6. What is the prefix for JavaServer Faces HTML Tag Library? Answer: h: 7. What is the prefix for JavaServer Faces Core Tag Library? Answer: f: 8. What is the prefix for JSTL core tag Library? Answer: c: 9. What is the prefix for JSTL function tag library? Answer: fn: 10. How do facelets refer properties and methods of backing bean? Answer: through the support of Expression Language (EL) in JSP 2.1 specification. 11. What are the steps taken to create a facelet application? Answer: Developing the backing beans, creating the pages using component tags, defining page navigation, mapping the facesServlet instance, adding managed bean application. 12. In a typical Java Server Faces application, each page is connected to what? Answer: to a backing bean file. 13. What are the two annotation you should use with a backing Bean? Answer: @ManagedBean, @SessionScoped.

Upload: towid

Post on 27-Apr-2015

578 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Jsf-facelets Interview Questions

1. What is a web application? Answer: A web application is a dynamic extension of a web or application Server. 2. What is facelets?3. Answer: The term facelets refer to the view declaration for Java Server faces

technology. Facelets is a lightweight but powerful page declaration language that is used to build Java Server Faces views using HTML style template and to build component trees

4. What language is used to create Facelet views?Answer: XHTML

5. what is the prefix for JavaServer Faces Facelets Tag Library?Answer: ui:

6. What is the prefix for JavaServer Faces HTML Tag Library?Answer: h:

7. What is the prefix for JavaServer Faces Core Tag Library?Answer: f:

8. What is the prefix for JSTL core tag Library?Answer: c:

9. What is the prefix for JSTL function tag library?Answer: fn:

10.How do facelets refer properties and methods of backing bean?Answer: through the support of Expression Language (EL) in JSP 2.1 specification.

11.What are the steps taken to create a facelet application?Answer: Developing the backing beans, creating the pages using component tags, defining page navigation, mapping the facesServlet instance, adding managed bean application.

12. In a typical Java Server Faces application, each page is connected to what?Answer: to a backing bean file.

13.What are the two annotation you should use with a backing Bean?Answer: @ManagedBean, @SessionScoped.

14.What are the steps involved in creating a facelet view/page?Answer: adding components on the page, wining the components to the backing bean values and properties, and registering converters, validators and listeners.

15.Where do you specify the name space?Answer: using xmlns tag.

16.What is the use of context parameter PROJECT_STAGE?Answer: This parameter identifies the status of a JavaServer Faces application in the software lifecycle. The Default project stage is Production.

17.What is templating? Answer: JavaServer Faces technology provides the tool to implement user interface that are reusable and extensible. Templating is a useful facelets feature that allows you to create a page that acts as a template or base. By using templating, you can re-use the code avoiding re-creating similarly constructed pages.

Page 2: Jsf-facelets Interview Questions

18.How do the client page invokes template from the main page?Answer: The client page invokes the template by the ui:composition tag, allowing content to be inserted using the ui:define tag inside ui:composition tag.

19.What is a composite component?Answer: A composite component consists of a collection of markup tags and other existing components. This reusable, user-created component has a customized, defined functionality and can have validators, converters, and listeners attached to it like any other component. the composite component can be stored in a library that is available to the application from the defined resources location

20.What is the reverse work for composite component in JavaServer Faces Technology?

Answer: cc is the reserve work to access the attribute defined for composite Component interface,21.Which directory is considered to be the library of JavaServer Faces ?

Answer: resource directory under the web-app root directory. 22.What is a using page?

Answer: The web page using the composite component from the library. 23.What are the two places that a web resource can be places:

Answer: There are basically two places a web resource can be placed.a) A web resource packaged in the root directory of the web-app must be

placed in side the resource/resource-identifier directoryb) A web resource packaged in the classpath of the web-app must be

placed inside the META-info/resource/resource-identifier directory. 24.Which technology is used both by JavaServer Pages and JavaServer faces

technology?

Answer: Expression Language (EL)

25.What does immediate evaluation mean in the context of expression

language?

Answer: Immediate evaluation means that expression is evaluated and result

is returned as soon as the page is first rendered.

26.What does deferred evaluation means in terms of Expression Language?

Answer: deferred evaluation means that the technology using the expression

language can use their own machinery to evaluate the expression sometimes

later during the lifecycle of this page, whenever is appropriate.

27.What is the syntax used for deferred or immediate evaluation?

Answer: ${ } for immediate evaluation and #{ } for deferred evaluation.

28.Why JavaServer Faces technology uses deferred evaluation?

Page 3: Jsf-facelets Interview Questions

Answer: Because of its multiphase lifecycle, JavaServer Faces technology uses

mostly deferred evaluation expressions. During the lifecycle, component events

are handled, data is validated, and other tasks are performed in a particular

order. Therefore, a JavaServer Faces implementation must defer evaluation of

expressions until the appropriate point in the lifecycle.

29.How many kinds of expressions are defined in EL?

Answer: EL defines two kinds of expression: value expressions and method

expressions.

30.What kind of objects can you refer to by EL (both rvalue and lvalue)?

Answer: JavaBean Object, collection, enum type and implicit objects.

31.Who and how an EL expression is evaluated?

Answer: The web container evaluates the variable that appears in an

expression by looking up its value according to the behavior of

PageContext.findAttribute {String}, where the string argument is the name of

the variable. For example, when evaluating the expression ${customer}, the

container will look for customer in page, request, session and application

scope and will return its value. A null value is returned if it is not found.

32.How can you refer an enum constant with EL?

Answer: using string literal. For example. For the following enum

Public enum Suit {hearts,spread,diamond,clubs}

To refer to the Suit constant Suit.hearts with an expression, use the String

literal "hearts". Depending on the context, the String literal is converted to the

enum constant automatically. For example, in the following expression in

which mySuit is an instance of Suit, "hearts" is first converted to Suit.hearts

before it is compared to the instance:

${mySuit == "hearts"}

33. How can you refer to properties of a bean or an enum instance, items of a

collection, or attributes of an implicit object?

Answer: you use the . or [ ] notation

33.What is a must requirement to access the properties of an enum constant

using EL?

Page 4: Jsf-facelets Interview Questions

Answer: As with JavaBeans component properties, the properties of an enum

class must follow JavaBeans component conventions (e.g. getter and setter

method)

34.How can you access an Item in an array or list?

Answer: If you are accessing an item in an array or list, you must use either a

literal value that can be converted to int or the [] notation with an int and

without quotes. The following examples could resolve to the same item in a

list or array, assuming that socks can be converted to int:

${customer.orders[1]}

${customer.orders.socks}

In contrast, an item in a Map can be accessed using a string literal key; no

coercion is required:

${customer.orders["socks"]}

35.Name the literals that are defined by EL?

Answer: Boolean, Integer as In Java, floating-point as in Java, String as in

Java and Null as null.

36.How can you set a tag attribute value using the ${ } delimiter?

Answer: <some:tag value=”${ }” />. These expressions are evaluated and the

values are converted to the attribute’s expected type.

37. How composite expressions are evaluated?

Answer: Composite expressions are evaluated from left to right, Each

expression embedded in the composite expression is converted to a String

and then concatenated with any intervening text. The resulting String is then

converted to the attribute’s expected type.

38.When a tag value expression must use literal?

Answer: When a tag attribute has an enum type.

39.What expression would you use with method invocation expression (deferred

or immediate?)

Page 5: Jsf-facelets Interview Questions

Answer: Because a method can be invoked during a different phases of the

lifecycle, method expression must always use the deferred evaluation syntax.

40.What is the use of Page Description Language (PDL)?

Answer: Which kind of expression and how it is evaluated, whether

immediately or deferred, are determined by the type attribute of the tag’s

definition in the PDL that defines the tag.

41.What does a literal expression uses?

Answer: a Literal expression uses String as a type. It does not use ${ } and

#{ }.

42.Can you use lvalue expression with rendered attribute for component tags?

Answer: No. it can only use rvalue expressions.

43.What is the use of Panel in JavaServer Faces?

Answer: you use panel as a layout container for a set of other components. A

panel is rendered as an HTML table.

44.What is the name of standard password field in JSF?

Answer: h:inputSecret.

45.What is an equivalent facelets tag of html < div> or <span> element?

Answer: panelGroup.

46.Where can you find all the facelets tag and function?

Answer:

http://download.oracle.com/javaee/6/javaserverfaces/2.0/docs/pdldocs/

facelets/.

47.How can you prevent the password from being displayed in a query string or

in the source file of the resulting html page?

Answer: by setting the redisplay attribute to false for <h:inputSecrete> tag.

48. What is the use of for attribute in JSF?

Answer: The for attribute of the h:outputLabel tag maps to the id of the input

field to which the label is attached.

49.When you should use <h:outputLink> over <h:commandLink>

Answer: You should use this tag instead of the h:commandLink tag if you

always want the URL specified by the h:outputLink tag’s value attribute to

Page 6: Jsf-facelets Interview Questions

open and do not want any processing to be performed when the user clicks

the link.

50. What a <h:commandLink> tag must include?

Answer: a command link tag must include an < h:outputText> tag.

51. What must be done to use <h:commandLink> tag?

Answer: The h:commandLink tag will render JavaScript programming

language. If you use this tag, make sure that your browser is enabled for

JavaScript technology

52. What is the only tag that JavaServer Faces technology provides to represent

Boolean state?

Answer: <h:selectBooleanCheckbox>

53.What is the benefit of using <f:selectItems> ?

Answer: Itesm can be represented using data datastructures ( array, map,

collection ), even generic collection of POJOS.

54. How can you bind a table of data to a table in JSF page?

Answer: <h:dataTable> tag

55. Where is the standard converter implementation located?

Answer: javax.faces.convert.

56. What is associated with each of the converters?

Answer: a standard error message.

57.What are the ways you can register a converter onto a component?

Answer: Nest one of the converter tags inside the component tag, bind the

value of the component to a backing bean property, refer to the converter

from the component tag’s converter attribute, nest a converter tag inside the

component tag and either use converter Id or binding attribute to refer to

converter.

58. What does DateTimeConverter convert to?

Answer: java.util.Date.

59.How an application developer can implement listeners?

Answer: as classes or as backing bean methods.

60.What are the two main attributes for valueChange and action Listener tag?

Page 7: Jsf-facelets Interview Questions

Answer: type, binding.

61.