![]() | ||||||||||
| documentation examples changes overview quick start installation command-line configuration guide: admin admin amber bam caching clustering database deployment ejb 3.0 embedding filters hessian ioc jsf jsp logging messaging performance quercus/php remoting scheduled tasks security server push servlets third-party troubleshooting virtual hosting watchdog webapp xml and xslt | jsf - java server faces
As of Resin version 3.1.6 Resin supports JSF 1.2. JSF specification defines a base set components for capturing user input and displaying output. Resin implements the spec from the ground up to take advantage of Resin's unique, high performance features. The two most notable features that make Resin's JSF fast are use of serialization mechanism implemented in Hessian protocol for JSF state handling and a fast-jsf mode of JSP generation. Along with the features orientated at performance advantage Resin's JSF offers integration with Web Beans (JSR 299). If you are using JSF's managed bean facility you can go straight to minimizing the amount of XML configuration by using Web Beans defined ways instead (will be shown below). 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 the 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: Fast-JSF JSP Generated Code
HtmlOutputText _jsp_comp_1
= Utils.add(jsf_context, request, response, HtmlOutputTest.class);
_jsp_comp_1.setValueExpression("value", _value_expr_0);
as opposed to the code generated in regular mode: Regular JSP Generated Code
_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 Resin's Fast JSFSetting mode to Fast JSF is done via using a fast-jsf flag in WEB-INF/resin-web.xml as in the code below: Fast-JSF resin-web.xml
<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: ftld for custom Actions
<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 The children of the
If you run into a case where supplying an Web Beans can significantly reduce XML configuration required for your
web application. By using annotations from Use @Component to make Java Bean a WebBean
package example;
import javax.webbeans.*;
@Component
public class FooBean {
}
Annotations
Use @Named and @SessionScope to name a WebBean and specify its scope
package example;
import javax.webbeans.*;
@Component
@Named("foo")
@SessionScoped
public class FooBean {
}
The following block of annotation
<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
e.g. WEB-INF/classes/META-INF/web-beans.xml
<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 Since version 3.2.0 resin offers JSF Developer Aid that allows to quickly introspect state of a Component Tree captured at the end of each phase and displayed in a tabbed view. The EL Experessions displayed in the view are navigable to screens that display backing data. Alone with the state, the Aid displays information for all request headers and parameters, and, attributes set on request, session and application. Enabling the JSF Developer Aid
To enable the Aid place a line WEB-INF/resin-web.xml
<web-app xmlns='http://caucho.com/ns/resin'>
<jsf enable-developer-aid='true'/>
</web-app>
Once the Aid is enabled a JSF Dev Aid link will appear in the right bottom corner of a page as on the picture below. ![]()
If desired, the position of the link can be changed via a Link position
<web-app xmlns='http://caucho.com/ns/resin'>
<jsf enable-developer-aid='true' developer-aid-link-style='position:absolute; bottom:1; right:1'/>
</web-app>
Aid's main pageThe main page lists available views and controls that allow saving the information into a binary file or loading from a file saved earlier. Persisted to a file, captured state may be shared with other developers, attached to QA bug reports and so on. ![]() Aid's Request Info pageRequest Info page will show headers and parameters contained in HTTP request. ![]() Aid's View States
The aid captures state of the ![]() Aid's EL Expression DisplayExpressions encoutered during introspection of a Component Tree become links and navigate to a page that display result of evaluation of that expression. ![]()
| |||||||||