sliderinput.java
来自「tbuy1.1.5是在netbeans环境下用JSF技术编写的一个论坛tbuy1」· Java 代码 · 共 79 行
JAVA
79 行
/* * SliderInput.java * * Created on 2007-9-25, 7:12:56 * * To change this template, choose Tools | Templates * and open the template in the editor. */package biz.tbuy.common.components.test;import java.io.IOException;import javax.faces.component.UIComponentBase;import javax.faces.context.FacesContext;import javax.faces.context.ResponseWriter;/** * * @author Administrator */public class SliderInput extends UIComponentBase{ public SliderInput() { setRendererType(null); } public String getFamily() { return null; } String maxval = "100"; String forid = null; String horizontal = "true"; String length = "300"; @Override public void encodeBegin(FacesContext fc) throws IOException { if (getAttributes().get("maxval") != null) { maxval = (String)getAttributes().get("maxval"); } if (getAttributes().get("for") != null) { forid = (String)getAttributes().get("for"); } if (getAttributes().get("horizontal") != null) { horizontal = (String)getAttributes().get("horizontal"); } if (getAttributes().get("length") != null) { length = (String)getAttributes().get("length"); } String comp_id = this.getId(); String valchangehandler = "valchangehandler" + comp_id; String destinationDiv = "dest" + comp_id; forid = getBaseClientId(fc) + forid; ResponseWriter rw = fc.getResponseWriter(); rw.write("<div id=\"" + destinationDiv + "\">" + "<!-- slider goes here --></div>" + "<script>var " + destinationDiv + " = document.getElementById(\"" + destinationDiv + "\");" + destinationDiv + ".appendChild(JSSlider.getInstance(\"" + comp_id + "\", " + horizontal + ", " + "10, " + length + ", 0, undefined, undefined, \"" + valchangehandler + "\", false).render());" + " function " + valchangehandler + "(newStartPercent0To100, newEndPercent0To100) " + "{ var slideval = Math.round(" + maxval + "*newStartPercent0To100/100); document.getElementById(\"" + forid + "\").value = slideval; " + "}</script>"); } private String getBaseClientId(FacesContext fc) { String clientId = getClientId(fc); return clientId.substring(0, clientId.indexOf(":") + 1); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?