RichFaces Interview Questions and Answers
Ques 16. What is a4j:ajax?
a4j:ajax is one of our core behaviors, extending the base JSF 2.0 f:ajax tag. This tag triggers an Ajax request when the specified parent event is triggered.
<
h:inputText
value
=
"#{userBean.name}"
>
<
a4j:ajax
event
=
"keyup"
render
=
"out"
/>
</
h:inputText
>
<
h:outputText
value
=
"#{userBean.name}"
id
=
"out"
/>
Ques 17. What is a4j:commandLink in RichFaces?
The a4j:commandLink combines the standard h:commandLink with our own a4j:ajax. This not only reduces typing, but also inherits all a4j:ajax special options.
Ques 18. What is a4j:actionListener in RichFaces?
Use a4j:actionListener to register an ActionListener class on a parent action component. Multiple listener methods can be registered on an action components in this way.
The a4j:actionListener tag differs from the standard JSF tag in that it allows the listener to be attached in any of three ways:
- By listener method, using the listener attribute.
- By listener class, using the type attribute.
- By object binding, using the binding attribute.
<
h:commandButton
value
=
"Update"
>
<
a4j:actionListener
listener
=
"#{bean.actionMethod}"
/>
<
f:ajax
render
=
"messages"
/>
</
h:commandButton
>
Ques 19. What is a4j:jsFunction in RichFaces?
The a4j:jsFunction component creates a JavaScript function that allows you to send JSF Ajax requests from any JavaScript. You define the Ajax and JSF properties just like a4j:ajax, or a4j:commandButton, and a4j:jsFunction creates the JavaScript for you. The component sends a request using the standard JSF mechanisms. Note that this means a JSF form is required.
The following example shows how to use a4j:jsFunction to create a function named updateName. This is then called on mouseover of the different names. This triggers the full round trip Ajax request and renders the updated name.
<
span
onmouseover
=
"updateAddress('WithoutBook')"
onmouseout
=
"updateAddress('')"
>WithoutBook</
span
>
<
a4j:jsFunction
name
=
"updateAddress"
render
=
"showAddress"
>
<
a4j:param
name
=
"address"
assignTo
=
"#{bean.address}"
/>
</
a4j:jsFunction
>
Ques 20. What is a4j:param in RichFaces?
<
a4j:commandButton
value
=
"Update Name"
render
=
"rep"
>
<
a4j:param
value
=
"WithoutBook"
assignTo
=
"#{bean.name}"
/>
</
a4j:commandButton
>
Most helpful rated by users:
- What is RichFaces?
- What is rich:dataGrid in RichFaces?
- What are the basic configurations of web.xml for Rich Faces?
- What is limitToList attribute?
- What is rich:messages in RichFaces?