JSF

40. What is DateTimeConverter in JSF ?

The getAsObject( ) method parses a String into a java.util.Date.

If a pattern JavaBeans property is specified on this converter instance, it must conform to the rules of java.text.SimpleDateFormat. The pattern property takes precedence over the type, dateStyle, and timeStyle JavaBeans properties.

If pattern is not specified, parsing takes place based on the value of the type property, which must be date, time, or both.

41. What is NumberConverter in JSF ?

The getAsObject( ) method parses a String into a java.lang.Number.

If a pattern JavaBeans property is specified, it must conform to the rules of java.text.DecimalFormat. The pattern property takes precedence over the type property.

If a pattern JavaBeans property is not specified, parsing takes place based on the value of the type property, which must be number, percentage, or currency.

If the integerOnly property is set to true, only the integer part of the String is parsed.

42. When FacesMessage instance is created in JSF ?

There are exactly three times in the request processing lifecycle when the standard components will create a FacesMessage instance and add it to the FacesContext: when conversion fails, when validation fails, or when the converted and validated data cannot be pushed to the model during the Update Model Values phase.

43. What is application event in JSF ?

Listen for events in this category when you want to do something in response to specific user action that is relevant to your particular application. Example: “A user pressed a ‘cancel’ button.”

44. What is phase event in JSF ?

Listen for events in this category when you want do something in response to every user’s progression through the request processing lifecycle, but only at the granularity of a lifecycle phase. Example: “Any user is having their components validated”.

45. What is system event in JSF ?

Like phase events, but with a finer granularity than lifecycle phase. Example: The application was initialized, or destroyed.

46. What is Component system event in JSF ?

A subtype of system event. Allows you to listen for specific lifecycle events on specific component instances. Example: This component is about to be validated.

47. What is value change event in JSF ?

A value change event is an event that is used to indicate when a value of a UI component, such as an input field, has changed. An example would be when you might want to capture the event when the Zip Code field has been filled in so that the server can auto-fill a City field.

48. What is composite component in JSf ?

JSF 2.0 provides a powerful new feature, called “composite components” that makes it easier to create custom UI components.

Composite component has two top-level elements, both from the http://java.sun.com/jsf/composite/ tag library: cc:interface and cc:implementation.

cc:interface Declares everything the page author needs to know to use this component. This is more formally known as the usage contract.

cc:implementation Defines the implementation of the contract declared in the cc:interface section.

49. What is <cc:attribute> element inside <cc:interface> section in JSF ?

<cc:attribute> elements within the <cc:interface> section declares that the composite component supports one or more XML attributes.

<cc:attribute name="name of the attribute in the using page"
default="optional default value for the attribute"
required="true or false. If true, there must be a value
for this attribute in the using page."
type="optional Java language type for the attribute"
method-signature="optional and mutually exclusive with the
type attribute this attribute is a Java
method signature of the method pointed
at by this attribute"
targets="optional list of component ids within the
cc:implementation that should receive this attribute"
displayName="optional information to describe the attribute"
shortDescription="more optional information.">

50. Which tag is used for AJAX in JSF ?
<f:ajax/> is used for AJAX in JSF.
51. How to update only content of the form in JSF ?
Use <f:ajax render=”@form” /> to the element where it will trigger the asynchronous update.
For example,

<h:form>
You entered: #{requestScope.input}.
<h:inputText id="input" value="#{requestScope.input}">
<f:ajax render="@form" />
</h:inputText>
</h:form>

So as soon as you input something and focus out of the input box then it will automatically shown the updated value at You entered: #{requestScope.input}.