Thursday, March 31, 2011

JSF2 complete reference - again 6 - march 31

312 (343)

read about a simple input component, the fact
that u have to declare in a taglib.xml and also
have the java class that defines the component (u could also
have a separate renderer).

The java class must have an annotation @FacesComponent(value = "nameOfTheComponent")
or you have to declare in faces-config.xml.

Monday, March 21, 2011

JSF2 complete reference - again 5 - march21

The result will be that the same Facelet page will
appear differently when viewed in a desktop Web browser and on the Apple mobile device,
as shown in Figure 11-8.
To make this possible, we rely on two basic concepts: a JSF PhaseListener and class
decoration. This example will provide a foundation for a more complete customization,
as well as showing how to automatically deliver a client device–specific CSS style sheet
to the user agent, and allow you to tailor how individual markup elements are displayed.

<lifecycle>
<phase-listener>com.jsfcompref.components.renderer.applemobile.
RenderKitSelectorPhaseListener</phase-listener>
</lifecycle>

The subtlety comes from how we must take
action in the afterPhase( ) method of restore view because this is the earliest time in the
lifecycle when context.getViewRoot( ) returns non-null.

Friday, March 18, 2011

JSF2 complete reference - again 4 - march18

<?xml version='1.0' encoding='UTF-8'?>
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://jsfcompref.com/example</namespace>
<tag>
<tag-name>helloworld</tag-name>
<component><component-type>HtmlHelloWorld</component-type></component>
</tag>
</facelet-taglib>

Now that we’ve created a simple, but fully functional component, we can begin adding
attributes to the component. Because HtmlHelloWorld extends from UIComponentBase,
UIComponent properties from the superclass such as id, binding, rendered are already
available for use in the Facelet page.

Prior to JSF 2.0, component state was typically stored in instance
variables on the UIComponent subclass. For example, the UIInput component has a valid
property, which indicates whether this component is valid or not. This value would be stored
in a simple boolean instance variable, accessed via a JavaBeans getter and setter and handled
explicitly in the saveState( ) and restoreState( ) methods. JSF 2.0 introduces the StateHelper
interface to make this sort of activity easier and less error prone.

Wednesday, March 16, 2011

JSF2 complete reference - again 3

TIP OF THE DAY: make the order button a composite component

Finally, notice the @FacesComponent annotation. This annotation is an alternative for
the following XML in the faces-config.xml file:
<component>
<component-type>HtmlHelloWorld</component-type>
<component-class>
com.jsfcompref.components.component.HtmlHelloWorld
</component-class>
</component>

310

Tuesday, March 15, 2011

JSF2 complete reference - again 2

For example <h:outputLabel
for="#{cc.clientId}:userid" value="Userid:" />
causes the label to have the correct absolute
client ID to the actual userid text field.


<h:inputSecret required="true"
validatorMessage="#{cc.attrs.passwordValidatorMessage}"
requiredMessage="Password is required" id="password" />

Monday, March 14, 2011

JSF2 complete reference - again 1

UI component is something that has
appearance, state, and behavior.

xmlns:vt="http://java.sun.com/jsf/composite/trainer"

vt:loginPanel

that means the file is src/main/webapp/resources/trainer/loginPanel.xhtml.

301 .....1:40, 2:46 at least

Thursday, March 3, 2011