Source Code: | htmLib.zip (1,777 Kb) |
The HTML Layout Tag Library
contains components for almost all of the standard HTML tags and attributes based on the HTML 4.01 specification. The excluded tags for the library are the interaction tags, such as form
, input
, select
, and textarea
. The library allows you to use old-fashioned HTML layout tags mixed in with JSF components without having to use the f:verbatim
tag.
This resolves a problem developers face who begin working with standard JSF libraries and then notice that some features are missing that they had used previously in working with other JSP-centric technologies such as Struts. The stumbling block is that most JSF tags will not allow you to insert a pure HTML tag as a child node. One way around this is to use the f:verbatim
tag, but this tag does not allow JSF components inside (as a descendent of the f:verbatim
element). This has the unfortunate result of discouraging developers from using JSF tags that provide layout such as h:panelGrid
, h:panelGroup
, h:column
. The HTML Layout Tag Library
eliminates this problem, easing the transition to JSF for newbies.
The library contain tags that are rendered into their HTML analogs. You use the tags in the library as you would their HTML analogs (per the W3C documentation) with the following differences:
- Each library tag contains a
rendered
attribute. If it is set tofalse
, the tag and its children are not rendered. - If the library tag contains an
id
attribute, the standard JSF convention forid
attributes is applied. Theid
's value will be replaced with the componentclientId
's value - If you want to keep the same value for the
id
in the rendered result, use ansid
attribute instead. - Each tag has a
binding
attribute. So, you can use the component binding. The component class name for each tag is built based on tag name using thecom.exadel.htmLib.components.UI
pattern. Where the
is a name of the tag starts with a capital letter.
For example,htm:table
-com.exadel.htmLib.components.UITable
htm:b
-com.exadel.htmLib.components.UIB
- Each attribute, except the
id
attribute, supports value binding. You can use something like#{foo.bar}
instead of a static literal value. - Each attribute, except the
id
attribute, supports jsp scriplets. You can use something like<%=foo%>
instead of a static literal value. - The following attribute names are changed due the name convention problem:
class
withstyleClass
for
withforAttribute
char
withcharAttribute
How to Download
Download htmLib.jar (72.4K) file and put it into the WEB-INF/lib
folder of your JSF application.
How to Use
Add the following taglib declaration at the top of the page:
<%@ taglib uri="http://jsftutorials.net/htmLib" prefix="htm" %>
After that, you can use the tags (htm:table
, htm:tr
, htm:td
, htm:colgroup
, htm:br
and so on) in the rest of the page.
For JSF Studio Users
If you want to have this library in the Palette, once the htmLib.jar
file is added to the project, drag and drop the htmLib.tld
file from the JSF Project view onto the Exadel Palette
. The library will then become available for click-n-insert. No other configuration is required.
0 comments:
Post a Comment