Kimi's NutShell

          我荒廢的今日,正是昨日殞身之人祈求的明日

          BlogJava 新隨筆 管理
            141 Posts :: 0 Stories :: 75 Comments :: 0 Trackbacks

          1.Tag類
          package ticker;

          import javax.faces.component.UIComponent;

          import javax.faces.webapp.UIComponentTag;

          public class TickerTag extends UIComponentTag {

          ??? public void release() {

          ??????? // the super class method should be called

          ??????? super.release();

          ??? }

          ??? protected void setProperties(UIComponent component) {

          ??????? // the super class method should be called

          ??????? super.setProperties(component);

          ??? }

          ??? public String getComponentType() {

          ??????? return "ticker";
          ??? }

          ??? public String getRendererType() {

          ??????? // null means the component renders itself

          ??????? return "ticker.renderer";

          ??? }

          }
          2.UI類
          ?? package ticker;

          import java.io.IOException;

          import javax.faces.component.UIOutput;

          import javax.faces.context.FacesContext;

          import javax.faces.context.ResponseWriter;

          public class UITicker extends UIOutput {
          public UITicker(){
          ??? setRendererType("ticker.renderer");??

          }

          ??? public void encodeBegin(FacesContext context) throws IOException {
          ??????? ResponseWriter writer = context.getResponseWriter();
          ??????? writer.write(" <link type='text/css' rel='StyleSheet' href='css/datepicker.css'/> \n" +
          ??????? "<script type='text/javascript' src='js/datepicker.js'></script> \n"+
          ??????? "<script type='text/javascript'> \n " +
          ???????????????????? "var d = new Date();\n" +
          ???????????????????? " var dp = new DatePicker(d,d);\n" +
          ???????????????????? "document.body.appendChild(dp.create());\n" +
          ???????????????????? "</script>");
          ??? }


          ??? public void encodeEnd(FacesContext context) throws IOException {
          ??? }

          }
          3.Tld檔
          ??? <?xml version="1.0" encoding="UTF-8"?>

          <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"

          "

          <taglib>

          ?<tlib-version>1.0</tlib-version>

          ?<jsp-version>1.2</jsp-version>

          ?<short-name>d</short-name>

          ?<uri>http://jsftutorials.com/</uri>


          ?<tag>

          ? <name>ticker</name>

          ? <tag-class>ticker.TickerTag</tag-class>

          ? <body-content>JSP</body-content>

          </tag>

          </taglib>

          4.faces-config 配置
          ?<component>
          ??? <component-type>ticker</component-type>
          ??? <component-class>ticker.UITicker</component-class>
          ? </component>

          ?

          ?

          主站蜘蛛池模板: 安化县| 海淀区| 女性| 阜宁县| 太谷县| 确山县| 韶山市| 甘泉县| 泉州市| 黄石市| 个旧市| 华宁县| 安岳县| 壤塘县| 恩施市| 夏邑县| 尖扎县| 莎车县| 富平县| 桂平市| 涪陵区| 连州市| 平邑县| 遂昌县| 二手房| 临夏市| 云林县| 称多县| 井冈山市| 博客| 遵义市| 五台县| 紫金县| 竹北市| 赣榆县| 汕头市| 台北县| 游戏| 大港区| 杭州市| 宝清县|