<document>

A JSF page may produce state that depending on the functionality of the page can be quite large as in the number of components and in the sheer volume of data associated with them. When serialized for sending to the client or replicating across servers in a cluster smaller state will produce numerous benefits ranging from more efficient use of bandwidth to lower memory requirements and lower CPU usage.

To achieve smaller size Resin's JSF State Management uses Hessian Serialization for packaging objects composing JSF state into a network-transferable object. As opposed to Java Serialization, Hessian takes advantage of a more compact storage scheme specified for Hessian Protocol.

While adhering to the JSF Spec Resin takes advantage of its custom built JSP code generator that is capable of recognizing JSF tags and, when UIComponent can be inferred, creating an instance of the component instead of creating an instance of the tag, and plugging the component instance directly into the Component Tree. This is what the JSP code generated in Fast JSF mode might look like:

HtmlOutputText _jsp_comp_1 = Utils.add(jsf_context, request, response, javax.faces.component.html.HtmlOutputTest.class); _jsp_comp_1.setValueExpression("value", _value_expr_0);

as opposed to the code generated in regular mode:

_jsp_HtmlOutputTextTag_1 = new HtmlOutputTextTag(); _jsp_HtmlOutputTextTag_1.setPageContext(pageContext); _jsp_HtmlOutputTextTag_1.setParent((javax.servlet.jsp.tagext.Tag) _jsp_FacesViewTag_0); _jsp_HtmlOutputTextTag_1.setJspId("jsp2"); _jsp_HtmlOutputTextTag_1.setValue(pageContext.createExpr(_value_expr_0, "#{msgs.title}", java.lang.Object.class)); _jsp_HtmlOutputTextTag_1.doStartTag(); _jsp_HtmlOutputTextTag_1.doEndTag();

As you can see from the above Resin will produce code that creates less objects, easing the load on JVM Garbage Collection, and making fewer calls, easing the load on CPU during page creation.

Setting mode to Fast JSF is done via using a fast-jsf flag in WEB-INF/resin-web.xml as in the code below:

<web-app xmlns="http://caucho.com/ns/resin"> <jsp fast-jsf='true'/> </web-app>

Resin will automatically infer correct UIComponent type for all Actions supplied with Resin which includes all JSF 1.2 standard Actions from http://java.sun.com/jsf/html and http://java.sun.com/core spaces. Enabling custom components to take advantage of fast-jsf takes creating a mapping file that will be located by Resin at application startup. The file might look like the following:

<jsf-taglib xmlns="http://caucho.com/ns/resin"> <uri>http://java.sun.com/jsf/html</uri> <jsf-tag> <name>column</name> <component-class>javax.faces.component.html.HtmlColumn</component-class> </jsf-tag> ... <jsf-tag> <name>commandButton</name> <component-class>javax.faces.component.html.HtmlCommandButton</component-class> </jsf-tag> <jsf-taglib>

The mapping file needs to have `ftld` extension. Resin will look for files with ftld extension on web application's classpath. E.g. `org/ajax4jsf/taglib/ajax4jsf.ftld`

The children of the `jsf-taglib` tag do the following

- Element `uri` maps to the taglib uri from the corresponding `.tld` file
- Element `jsf-tag` defines a mapping by binding a tag `name` to `component-class`

If you run into a case where supplying an `.ftld` and setting `fast-jsf` to true does not work for your library please provide feedback asking in the forums or mailing list. A fallback to to non fast-jsf mode is always available via setting the value of fast-jsf to false.

Web Beans can significantly reduce XML configuration required for your web application. By using annotations from `javax.webbeans` package a Java Bean can be turned into a Web Bean by supplying it with a @Component annotation like so:

package example; import javax.webbeans.*; @Component public class FooBean { }

Annotations `@Named` and one of`@ApplicationScoped`, `@ConversionScoped` , `@SessionScoped`,`@RequestScoped`, `@Dependant` (parent's scope) will give the Web Bean a name and scope:

package example; import javax.webbeans.*; @Component @Named("foo") @SessionScoped public class FooBean { }

The following block of annotation `@Component @Named("foo") @SessionScoped` atop of a bean is equivalent to the XML fragment below that would need to be placed into faces-config.xml

<example> <managed-bean> <managed-bean-name>quiz</managed-bean-name> <managed-bean-class>com.corejsf.QuizBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean>

Don't forget to place an emtpy web-beans.xml file into your classpath under `META-INF` directory to enable Web Beans for the context. <web-beans xmlns="http://caucho.com/ns/resin"/>

Web Beans has become a technology integrated into Resin's core and will work well with other Caucho's technologies. You can learn more about Web Beans and Resin at Resin IOC

</document>