Q: What is
the difference between JSP and JSF?
JSP simply provides a Page which may contain
markup, embedded Java code, and tags which encapsulate
more complicated logic / html.
JSF may use JSP as its template, but provides
much more. This includes validation, rich component
model and lifecycle, more sophisticated EL,
separation of data, navigation handling, different
view technologies (instead of JSP), ability
to provide more advanced features such as AJAX,
etc.
32. What is JSF life cycle and its phases?
The series of steps followed by an application
is called its life cycle. A JSF application
typically follows six steps in its life.
a. Restore view phase
b. Apply request values phase
c. Process validations phase
d. Update model values phase
e. Invoke application phase
f. Render response phase
Q: What
is the role of Renderer in JSF? and justify
the statement "JSF supports multiple client
devices".
After creating JSF components, it is also necessary
for each component to be rendered to the client
so that it can be visible to the client’s
device. Each of the tag gives rise to an associated
component. A renderer is a type of class that
is responsible for encoding and decoding components.
Encoding displays the component while decoding
translates the user’s input into components
value i.e. transform it into values the component
can understand.
Now a days there are many devices that are web
enabled. So application developers have challenge
to develop components that can work across various
platforms. For example, if we have an application
that works on standard web browser and we want
to extend it to make it enable to work on a
WAP device. So, to handle this case we need
components to be rendered in more than one way.
Here JSF can be helpful. This is a simple task
for JSF. The solution is to develop separate
renderers for the component. JSF components
use different renderers depending on the device
used.
Q: What is Render Kit in JSF?
Component classes generally transfer the task
of generating output to the renderer. All JSF
components follow it. Render kit is a set of
related renderers. javax.faces.render.RenderKit
is the class which represents the render kit.
The default render kit contains renderers for
html but it’s up to you to make it for
other markup languages. Render kit can implement
a skin (a look & feel). Render kit can target
a specific device like phone, PC or markup language
like HTML, WML, SVG. This is one of the best
benefit of JSF because JSF doesn't limit to
any device or markup.
Q: What is conversion and validation? and how
are they related?
This is one of the phase of JSF life cycle that
happens before binding the component data to
the related backing bean in the Update model
values phase.
Conversion is the process of transforming the
component data from String to Java objects and
vice versa. For example, an user enters a value
(String) in an input component and this value
is to store in a Date field in the backing bean
then this String value is converted to a java.util.Date
value when request is sent to the server and
vice versa. This process is called Conversion.
Validation is the process of ensuring data contains
the expected content. For example, checking
the Date value is in MM./dd/YYYY format or any
integer value is between 1 to 10.
The main purpose of conversion and validation
is to ensure the values are of correct type
and following the required criteria before updating
model data. So this step allows you to focus
on business logic rather than working on tedious
qualifications of input data such as null checks,
length qualifiers, range boundaries, etc.
Q: When automatic conversion is supplied
by JSF Implementation?
JSF implementation automatically converts component
data between presentation view and model when
the bean property associated with the component
is of one of the types supported by the component's
data.
For example, If a UISelectBoolean component
is associated with a bean property of type Boolean,
then JSF implementation will automatically convert
the data from String to Boolean.
1. Which type of converters can we use
in our application?
A JSF application can use two types of converters
:
1. JSF standard Converters
JSF supplies built-in converters known as standard
converters. All standard converters implements
javax.faces.convert.Converter interface. These
converter classes are listed below :
1. BigDecimalConverter
2. BigIntegerConverter
3. BooleanConverter
4. ByteConverter
5. CharacterConverter
6. DateTimeConverter
7. DoubleConverter
8. FloatConverter
9. IntegerConverter
10. LongConverter
11. NumberConverter
12. ShortConverter
2. Custom Converter
Custom data converter is useful in in converting
field data into an application-specific value
object. For example,
1. String to User object.
2. String to Product object etc.