JSF and Facelets
Attempt to combine JSF and JSP is like trying to make foot hard into the glove: It may do, but there is a better solution before an expedient measure. In this article, JSF enthusiastic supporter of Rick Hightower introduces his favorite on the content of Facelets: easy HTML-style templating and reusable composite components.
As the recent Java? Server Appearance (JSF) project work, I am very fortunate for the first time using Facelets. About Facelets, my favorite is that it allows me to create reusable composite components. Be able to come up with a page (for example, JSP) and turn it into components, for my JSF development is really a great advantage. My conclusion is what? If not Facelets, then JSF can not be obtained from the largest gains.
JSF and Java Server Pages technology mismatch between, JSF development is a serious problem. The question is how to integrate JSP's dynamic content JSF component-based model. JSP attaches great importance to generate dynamic content output, but JSF requires JSP to coordinate the component model. For this task goes beyond the original purpose of JSP, so had a Distance.
Most JSF developers simply learn to deliberations to address these problems, but it is like a pillow on the hammer, injuring his head will eventually fall. Facelets is a more comprehensive solution: for JSF component model tailored templating language.
Facelets has the following attractive features:
鈼?Templating (like Tiles)
鈼?Composite Components
鈼?Custom logic tags
鈼?expression language
鈼?Development of the designer-friendly page
鈼?Create component library
These features than I expected to be more relevant and uniform. In this article, I discussed the first two: templating and composite components. I use Web-based application for the suspect for my family who developed a JSF application, I put it to use Facelets view update instead of Tiles. Before reading further, should download the sample code. If you want to discuss together with the operation, also need to install Facelets.
Facelets Overview
For Facelets may do the greatest wrong assumption that it is only a substitute for Tiles. Facelets much more than that: it is the new way of thinking JSF.
JSP is the kind of template of the language generated servlet. Subject and JSP servlet's doGet () and doPost () method is equivalent to (that is, as jspService () method). JSF custom tags (such as f: view and h: form) is called JSF components to render the current state of their own. JSF component model is independent of the life cycle of the generated JSP servlet's life cycle. This independence is a source of confusion.
Different with JSP, Facelets templating language that, from the start, on account of the life cycle of JSF components. Use Facelets, generated template build the component tree, not the servlet. This allows better reuse, as components can be combined into one component.
Facelets custom tags to reduce the preparation needs to use JSF. Facelets itself can use the JSF custom components. Communication JSF and Facelets requires very little special code: to do all the work is Facelet JSF tag library components declared. In the Facelets templating language can be used directly JSF components, without any additional development.
Facelets template framework
Building design in the provision of a template for the component framework, Facelets and Tapestry (see Resources) similar. However, we have the background for JSP, Facelets seem friendly and more than Tapestry. It allows the use of the familiar style of JSTL tags and JSTL / JSF / JSP expression language style. Greatly reduce the learning curve means you can start developing more rapidly.
Facelets allows the definition can be included directly into the page, or easily added to the Facelet tag library of components. Happily actually defined in the Facelets custom tag (composite components and JSP custom tag like tag) is very fast. Set to use these components, Facelets also allows the definition of site templates (and a smaller template). This is similar to using the Tiles, but less definition files. JSF components can also be customized for internal use Facelets, because the Facelets API provides JSF components can be easily integrated with the interface.
From Tiles to JSF and Facelets
As mentioned earlier, where the sample Web application to use for my on the JSF for the skeptics to create the sample series. It is an online CD store inventory management, create, read, update, and delete (CRUD) list. It includes a form to allow users to enter a new system, CD, a radio button list, allows the user to select the music category. When the user selects a classification, it immediately triggers some javascript form submission back to server. Application also includes a CD list, the user can list the title or the artist's CD on order.
The original application received from the Tiles view, support, and now I'll build Facelets view. I will start replacing the example with Facelets Tiles support beginning, and then write complex components.
相关链接:
How To Become A DBA From A BeginnerXviD to MP4M2TS to MKVCall Of Operations Of Foreign CarriersTaobao Alipay betrayal?Sonic Foundry Vegas 4.0 Image SHARPENING novice Collection 28MKV TO ZuneIS Audit and Supervision ComparisonEasy to use Adventure And RoleplayListed company s three key financial indicatorsMoving To The Countryside To The Computer Through Three Banks10 training managers to work effectivelyadvanced video editing 2for YOU Science - Screen SaversPicked Shell ToolsInfomation Cartoons - Screen SaversFlash MX Overview 1