日期:2014-05-16 浏览次数:20409 次
package taglib; import javax.el.ValueExpression; import javax.faces.application.Application; import javax.faces.context.FacesContext; import javax.faces.el.ValueBinding; import javax.faces.webapp.UIComponentTag; import javax.faces.component.UIComponent; import javax.faces.webapp.UIComponentELTag; public class HtmlDirectorySearchTag extends UIComponentTag { public HtmlDirectorySearchTag() { super(); } public String getComponentType(){ return "DirectorySearch"; } public String getRendererType(){ return "DirectorySearchRenderer"; } String border = "0"; String tablebgcolor = null; protected void setProperties(UIComponent component) { super.setProperties(component); // set border if (border != null) { if (isValueReference(border)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ValueBinding vb = app.createValueBinding(border); component.setValueBinding("border", vb); } else component.getAttributes().put("border", border); } // set tablebgcolor if (tablebgcolor != null) { if (isValueReference(tablebgcolor)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ValueBinding vb = app.createValueBinding(tablebgcolor); component.setValueBinding("tablebgcolor", vb); } else component.getAttributes().put("tablebgcolor", tablebgcolor); } } public void release() { super.release(); border = "0"; tablebgcolor = null; } public void setBorder(String border) { this.border = border; } public String getBorder() { return border; } public void setTablebgcolor(String tablebgcolor) { this.tablebgcolor = tablebgcolor; } public String getTablebgcolor() { return tablebgcolor; } }
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"> <taglib> <tlib-version> 0.01 </tlib-version> <jsp-version> 1.2 </jsp-version> <uri> /WEB-INF/components </uri> <description> This tag library contains ajax Jsf demo components </description> <tag> <name> directorysearch </name> <tag-class> taglib.HtmlDirectorySearchTag </tag-class> <description> Renders an input field and returns an HTML table with search results. </description> <attribute> <name>border</name> <description>rendered table border</description> </attribute> <attribute> <name>tablebgcolor</name> <description>rendered table background</description> </attribute> <attribute> <name>id</name> <description>component id</description> </attribute> <attribute> <name>binding</name> <description>binding</description> </attribute> <attribute> <name>value</name> <description>value of input</description> </attribute> <attribute> <name>rendered</name> <description>Is this component rendered?</description> </attribute> </tag> </taglib>
<?xml version='1.0' encoding='UTF-8'?> <!-- =========== FULL CONFIGURATION FILE =====================