banner



How To Add A Link To Jsf Template Client

Open-source Spider web template system

Facelets
Stable release

2.0 / June 28, 2009 (2009-06-28)

Written in Coffee
Operating organization Cross-platform
Blazon Web template arrangement
Website facelets.dev.java.net Edit this on Wikidata
Facelets standalone
Stable release

i.i.fifteen / November 24, 2009 (2009-xi-24)

Preview release

1.2-dev / November 10, 2006 (2006-xi-ten)

Written in Coffee
Operating system Cross-platform
Size 5.07 MB (archived)
Type Spider web template system
License Apache License ii.0
Website facelets.java.cyberspace

In computing, Facelets is an open up-source Web template system under the Apache license and the default view handler technology (aka view declaration linguistic communication) for Jakarta Server Faces (JSF; formerly JavaServer Faces). The language requires valid input XML documents to work. Facelets supports all of the JSF UI components and focuses completely on edifice the JSF component tree, reflecting the view for a JSF application.

Although both JSP and JSF technologies take been improved to work better together, Facelets eliminates the bug noted in Hans Bergsten's article "Improving JSF by Dumping JSP"[one]

Facelets draws on some of the ideas from Apache Tapestry,[2] [3] and is similar enough to draw comparing. The project is conceptually similar to Tapestry's, which treats blocks of HTML elements every bit framework components backed past Java classes. Facelets also has some similarities to the Apache Tiles framework with respect to support templating as well every bit composition.

Facelets was originally created by Jacob Hookom in 2005[iii] as a separate, alternative view declaration language for JSF i.1 and JSF i.2 which both used JSP as the default view declaration language. Starting from JSF ii.0, Facelets has been promoted by the JSF expert group to be the default view declaration language. JSP has been deprecated as a legacy fall back.[four] [five]

Element conversion [edit]

In Facelets, templates tags from a tag library can be entered in two forms: directly as a qualified xml chemical element or indirectly via the jsfc attribute on an arbitrary non-qualified chemical element. In the latter case the Facelet compiler will ignore the actual chemical element and will process the element as-if it was the 1 given past the jsfc attribute.

The post-obit instance shows the straight usage of qualified tags:

                        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0                        Transitional//EN" "http://world wide web.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">            <html            xmlns=            "http://world wide web.w3.org/1999/xhtml"            xmlns:h=            "http://java.sunday.com/jsf/html"            >            <body>            <h:form>            <h:outputText            value=            "Welcome, #{loggedInUser.proper name}"            disabled=            "#{empty loggedInUser}"            />            <h:inputText            value=            "#{bean.belongings}"            />            <h:commandButton            value=            "OK"            action=            "#{bean.doSomething}"            />            </h:form>            </torso>            </html>          

Using the jsfc attribute, the same code can as well be expressed equally the example given below:

                        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0                        Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">            <            html            xmlns            =            "http://world wide web.w3.org/1999/xhtml"            xmlns:h            =            "http://java.sun.com/jsf/html"            >            <            torso            >            <            form            jsfc            =            "h:form"            >            <            span            jsfc            =            "h:outputText"            value            =            "Welcome, #{loggedInUser.name}"            disabled            =            "#{empty loggedInUser}"            />            <            input            type            =            "text"            jsfc            =            "h:inputText"            value            =            "#{edible bean.property}"            />            <            input            type            =            "submit"            jsfc            =            "h:commandButton"            value            =            "OK"            activeness            =            "#{bean.doSomething}"            />            </            class            >            </            body            >            </            html            >          

The above code can exist viewed in a browser, and edited with conventional WYSIWYG pattern tools. This is not possible when straight using the qualified tags. Nevertheless, directly using qualified tags is the most pop fashion of using Facelets in practice [6] and is the style most used in books and examples.[7] [8]

Templating [edit]

Facelets provides a facility for templating.[9] [x] A Facelets file can reference a chief template and provide content for the placeholders this master template defines. The file that references such a template is called the template client. Template clients themselves tin can again exist used as a template for other template clients and equally such a hierarchy of templates can be created.

The following shows an example of a unproblematic master template:

templates/master_template.xhtml

                        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML ane.0                        Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">            <html            xmlns=            "http://www.w3.org/1999/xhtml"            xmlns:h=            "http://java.lord's day.com/jsf/html"            xmlns:ui=            "http://java.sunday.com/jsf/facelets"            >            <h:head>            <meta            http-equiv=            "content-blazon"            content=            "text/html;charset=UTF-8"            />            <meta            http-equiv=            "pragma"            content=            "no-cache"            />            </h:head>            <h:body>            Standard header text for every folio.            <ui:insert            proper name=            "body_content"            />            Standard footer text for every page.            </h:trunk>            </html>          

The to a higher place code contains a default HTML 'frame' and a single placeholder called body_content. A template client can utilise this template equally follows:

template_client.xhtml

                        <ui:composition            template=            "/templates/master_template.xhtml"            xmlns=            "http://www.w3.org/1999/xhtml"            xmlns:ui=            "http://java.sun.com/jsf/facelets"            >            <ui:ascertain            name=            "body_content"            >            This is a template client page that uses the master template.            </ui:define>            </ui:composition>          

The above code makes use of the template /templates/master_template.xhtml and provides content for the placeholder in that template. The final outcome will be a page called template_client.xhtml that has the content of /templates/master_template.xhtml, just with <ui:insert name="body_content"/> replaced by 'This is a template client folio that uses the chief template.'.

Content re-employ [edit]

In addition to templating, Facelets provides support for re-utilize past letting the user include content that resides in a dissimilar file. Including such content can be done in three different means:

  • Referencing a file
  • Custom tags
  • Composite components

Referencing a file [edit]

The simplest fashion to include the content of another Facelet is referencing information technology past name using the <ui:include> tag.[eleven] [12] This causes the content in the referenced file to be directly included in the calling Facelet by the Facelets compiler. Also re-using content at multiple locations, this tin can be used to interruption downward a large Facelet into smaller parts.

The following shows an example:

templates/master_template.xhtml

                        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0                        Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">            <html            xmlns=            "http://www.w3.org/1999/xhtml"            xmlns:h=            "http://java.lord's day.com/jsf/html"            xmlns:ui=            "http://java.dominicus.com/jsf/facelets"            >            <ui:include            src=            "html_head.xhtml"            />            <h:body>            Standard header text for every page.            <ui:insert            name=            "body_content"            />            Standard footer text for every page.            </h:body>            </html>          

html_head.xhtml

                        <ui:composition            xmlns=            "http://www.w3.org/1999/xhtml"            xmlns:h=            "http://coffee.sun.com/jsf/html"            >            <h:head>            <meta            http-equiv=            "content-type"            content=            "text/html;charset=UTF-8"            />            <meta            http-equiv=            " pragma"            content=            "no-cache"            />            </h:head>            </ui:composition>          

Custom tags [edit]

Facelets supports indirection for including content via custom tags.[13] Such a custom tag tin can exist associated with a Facelet in a taglib file. Occurrences of that tag will then be replaced with the content of the associated Facelet.

The following shows an example of this:

templates/master_template.xhtml

                        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0                        Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">            <html            xmlns=            "http://www.w3.org/1999/xhtml"            xmlns:h=            "http://java.sun.com/jsf/html"            xmlns:ui=            "http://java.sun.com/jsf/facelets"            xmlns:my=            "http://example.com/my"            >            <ui:include            src=            "html_head.xhtml"            />            <h:body>            Standard header text for every page.            <my:spacer>            <ui:insert            name=            "body_content"            />            Standard footer text for every page.            </h:body>            </html>          

The lawmaking above uses the tag <my:spacer> to mark the point in the Facelet where content is to be inserted. Such a tag has to be alleged in a Taglib file where it can be associated with a Facelet as follows:

example.taglib.xml

                        <?xml version="1.0" encoding="UTF-8"?>            <facelet-taglib            xmlns=            "http://java.sun.com/xml/ns/javaee"            xmlns:xsi=            "http://world wide web.w3.org/2001/XMLSchema-case"            xsi:schemaLocation=            "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/spider web-facelettaglibrary_2_0.xsd"            version=            "ii.0"            >            <namespace>http://example.com/my</namespace>            <tag>            <tag-proper name>spacer</tag-proper noun>            <source>spacer.xhtml</source>            </tag>            </facelet-taglib>          

The following shows an example of what the actual content Facelet could await like:

spacer.xhtml

                        <ui:composition            xmlns=            "http://www.w3.org/1999/xhtml"            xmlns:ui=            "http://java.dominicus.com/jsf/facelets"            xmlns:h=            "http://java.sun.com/jsf/html"            >            <h:outputText            value=            "&amp;nbsp;"            escape=            "false"            />            </ui:limerick>          

Composite components [edit]

Besides including content directly, Facelets provides the composite component machinery that makes content bachelor as a first-class JSF component.[14] [fifteen] Composite components do not need to be declared in a Taglib file, but instead have to be put in a special directory. By convention the content is and then automatically assigned a namespace and a tag name. The namespace is constructed of the stock-still cord 'http://java.sun.com/jsf/composite/' concatenated with the directory proper name in which the content file resides relative to the 'resource' directory.[sixteen] The tag name becomes the file proper name without the .xhtml suffix.

The following shows an example of this:

resource/my/spacer.xhtml

                        <ui:composition            xmlns=            "http://www.w3.org/1999/xhtml"            xmlns:ui=            "http://java.sun.com/jsf/facelets"            xmlns:h=            "http://java.dominicus.com/jsf/html"            xmlns:cc=            "http://java.dominicus.com/jsf/composite"            >            <cc:interface/>            <cc:implementation>            <h:outputText            value=            "&amp;nbsp;"            escape=            "false"            />            </cc:implementation>            </ui:composition>          

The higher up Facelet is automatically available as a component in namespace 'http://coffee.dominicus.com/jsf/composite/my' and tag name 'spacer'

Parameterized includes [edit]

To customize included content, Facelets allows parameters to exist used. Via those parameters, objects can be passed into the included content, where they tin can be used every bit variables. For the <ui:include> mechanism the <ui:param> tin can be used for this,[17] while for the custom tags and composite components, normal tag attributes can be used. Composite components require parameters to be declared in their interface section,[18] while for custom tags there is no such requirement and values provided for arbitrary attributes are made bachelor equally variables with the same name as said attribute.

See besides [edit]

  • JavaServer Faces

References [edit]

  1. ^ Bergsten, Hans (June nine, 2004). "Improving JSF past Dumping JSP". ONJava. O'Reilly Media. Archived from the original on 2018-04-05.
  2. ^ "Facelets: JavaServer Faces View Definition Framework". java.net. Archived from the original on 2016-12-31.
  3. ^ a b Hookom, Jacob (Baronial 17, 2005). "Within Facelets Function 1: An Introduction". JSFCentral. Archived from the original on 2020-01-05.
  4. ^ Burns, Ed; Schalk, Chris (2009). JavaServer Faces 2.0, The Consummate Reference. McGraw-Hill. ISBN978-0-07-162509-8. p. 55: The good group decided to move frontward with Facelets as the ground for new features while letting JSP remain as a backward compatibility layer.
  5. ^ Burns, Ed; Kitain, Roger, eds. (Nov 8, 2010). JavaServer Faces Specification, Version 2.ane. JCP (Technical written report) (MR2 ed.). Oracle. JSR-314. p. 10-1: Facelets is a replacement for JSP that was designed from the outset with JSF in mind. New features introduced in version 2 and later are only exposed to page authors using Facelets. JSP is retained for backwards compatibility.
  6. ^ "Newest 'jsf' Questions". stackoverflow.com . Retrieved 22 November 2016.
  7. ^ JavaServer Faces 2.0, The Consummate Reference by Ed Burns and Chris Schalk
  8. ^ Core JavaServer Faces (third Edition) by David Geary and Cay S. Horstmann
  9. ^ "JSF 2 fu, Part 2: Templating and composite components". ibm.com. 2 June 2009. Retrieved 22 November 2016.
  10. ^ "ui (JSF 2.0 Page Decraration Language: Facelets Variant)". oracle.com . Retrieved 22 November 2016.
  11. ^ "include (JSF ii.0 Page Decraration Language: Facelets Variant)". oracle.com . Retrieved 22 Nov 2016.
  12. ^ "Some things to remember: Facelets ui:include considered powerful". pilhuhn.blogspot.com. 4 Dec 2009. Retrieved 22 Nov 2016.
  13. ^ "Custom JSF components with Facelets". wordpress.com. 29 February 2008. Archived from the original on 19 October 2016. Retrieved 22 Nov 2016.
  14. ^ "composite(JSF 2.0 Page Decraration Linguistic communication: Facelets Variant)". oracle.com . Retrieved 22 November 2016.
  15. ^ "What's New in JSF two?". wordpress.com. 31 July 2009. Retrieved 22 November 2016.
  16. ^ JSR 314, 10.3.3.1, http://jcp.org/en/jsr/detail?id=314
  17. ^ "param(JSF 2.0 Page Decraration Language: Facelets Variant)". oracle.com . Retrieved 22 November 2016.
  18. ^ "interface (JSF 2.0 Page Decraration Linguistic communication: Facelets Variant)". oracle.com . Retrieved 22 November 2016.

Bibliography [edit]

  • Wadia, Zubin; Marinschek, Martin; Saleh, Hazem; Byrne, Dennis (September 22, 2008). The Definitive Guide to Apache MyFaces and Facelets (1st ed.). Apress. p. 400. ISBN978-1-59059-737-8. Archived from the original on January ii, 2010. Retrieved September iv, 2009.
  • Wadia, Zubin; Aranda, Bruno (May 26, 2008). Facelets Essentials: Guide to JavaServer Faces View Definition Framework (1st ed.). Apress. p. 84. ISBN978-one-4302-1049-viii. Archived from the original on Jan viii, 2010. Retrieved September 4, 2009.

External links [edit]

  • "Introduction to Facelets" Chapter 8 of The Djakarta EE Tutorial
  • Facelets Programmer Documentation at the Wayback Machine (archived 2016-12-31)
  • Hightower, Richard (February 21, 2006). "Facelets fits JSF like a glove". Java. DeveloperWorks. IBM. Archived from the original on 2021-02-24.
  • Facelets Home Folio at the Wayback Machine (archived 2017-04-04)

How To Add A Link To Jsf Template Client,

Source: https://en.wikipedia.org/wiki/Facelets

Posted by: deloachcrehose.blogspot.com

0 Response to "How To Add A Link To Jsf Template Client"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel