Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.richfaces.renderkit.html;
  
  import java.util.List;
  import java.util.Map;
  import  javax.faces.component.UIComponent;
  import  javax.faces.context.FacesContext;
  import  javax.faces.context.ResponseWriter;
 import  org.ajax4jsf.javascript.JSReference;
 import static org.richfaces.renderkit.RenderKitUtils.*;
 
 
 public class SelectRenderer extends SelectRendererBase {
 	
 private static final Attributes PASS_THROUGH_ATTRIBUTES22 = attributes()
 	     .generic("accept","accept")
 	     
 
 	     .generic("accesskey","accesskey")
 	     
 
 	     .generic("align","align")
 	     
 
 	     .generic("alt","alt")
 	     
 
 	     .bool("checked","checked")
 	     
 
 	     .generic("dir","dir")
 	     
 
 	     .generic("lang","lang")
 	     
 
 	     .generic("maxlength","maxlength")
 	     
 
 	     .generic("onclick","onclick","click")
 	     
 
 	     .generic("ondblclick","ondblclick","dblclick")
 	     
 
 	     .generic("onkeydown","onkeydown","keydown")
 	     
 
 	     .generic("onkeypress","onkeypress","keypress")
 	     
 
 	     .generic("onkeyup","onkeyup","keyup")
 	     
 
 	     .generic("onmousedown","onmousedown","mousedown")
 	     
 
 	     .generic("onmousemove","onmousemove","mousemove")
 	     
 
 	     .generic("onmouseout","onmouseout","mouseout")
 	     
 
 	     .generic("onmouseover","onmouseover","mouseover")
 	     
 
 	     .generic("onmouseup","onmouseup","mouseup")
 	     
 
 	     .generic("onselect","onselect")
 	     
 
 	     .generic("role","role")
 	     
 
 	     .generic("size","size")
 	     
 
 	     .uri("src","src")
 	     
 
 	     .generic("tabindex","tabindex")
 	     
 
 	     .generic("title","title")
 	     
 
 	     .uri("usemap","usemap")
 	     
 ;
 	
 private static final Attributes ATTRIBUTES_FOR_SCRIPT_HASH22 = attributes()
 	     .generic("onbegin","onbegin")
	     
	     .generic("oncomplete","oncomplete")
	     
	     .generic("onerror","onerror")
	     
	     .generic("onbeforedomupdate","onbeforedomupdate")
	     
	     .generic("onchange","onchange","change")
	     
	     .generic("onblur","onblur","blur")
	     
	     .generic("onselectitem","onselectitem","selectitem")
	     
	     .generic("onfocus","onfocus","focus")
	     
	     .generic("onlistshow","onlistshow","listshow")
	     
	     .generic("onlisthide","onlisthide","listhide")
	     
	     .generic("showControl","showControl")
	     
	     .generic("defaultLabel","defaultLabel")
	     
	     .generic("enableManualInput","enableManualInput")
	     .defaultValue(false)
	     .generic("selectFirst","selectFirst")
	     .defaultValue(true)
	     .generic("disabled","disabled")
	     .defaultValue(false)
private static String convertToString(Object object
 {
		return object != null ? object.toString() : "";
	}
private static boolean isEqual(Object o1Object o2
 {
		if (o1 != null) {
	return o1.equals(o2);
else {
	//o1 == null
	return o2 == null;
	}
private static boolean convertToBoolean(Object object
 {
		if (object == null) {
	return false;
if (object instanceof Boolean) {
    return (Booleanobject;
return Boolean.valueOf(object.toString());
	}
public void doEncodeEnd(ResponseWriter responseWriter, FacesContext facesContext, UIComponent component
	 {
		String clientId = component.getClientId(facesContext);
List clientSelectItems  =  (List)this.getConvertedSelectItems(facesContext,component); 
Object disabled  =  (Object)component.getAttributes().get("disabled"); 
responseWriter.startElement("div"component); 
   {
      Object value = this.concatClasses("rf-sel",component.getAttributes().get("styleClass"));
      if(null != value &&
      shouldRenderAttribute(value)
      ) {
        responseWriter.writeAttribute("class",value,null);
      }
      
   }
   {
      String value = clientId;
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
   {
      Object value = component.getAttributes().get("style");
      if(null != value &&
      shouldRenderAttribute(value)
      ) {
        responseWriter.writeAttribute("style",value,null);
      }
      
   }
responseWriter.startElement("span"component); 
  responseWriter.writeAttribute("class","rf-sel-cntr",null);
responseWriter.startElement("input"component); 
   {
      String value = convertToString(clientId) + "selValue";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
   {
      String value = clientId;
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("name",value,null);
      }
      
   }
  responseWriter.writeAttribute("type","hidden",null);
   {
      String value = this.getInputValue(facesContext,component);
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("value",value,null);
      }
      
   }
responseWriter.endElement("input"); 
String label  =  (String)this.getSelectLabel(facesContext,component); 
responseWriter.startElement("input"component); 
  responseWriter.writeAttribute("autocomplete","off",null);
   {
      String value = "rf-sel-inp" + convertToString((isEqual(label,component.getAttributes().get("defaultLabel")) ? " rf-sel-dflt-lbl" : ""));
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("class",value,null);
      }
      
   }
      if(null != disabled && ( Boolean.valueOf(disabled.toString()) || "disabled".equals(disabled.toString())) ) {
        responseWriter.writeAttribute("disabled","disabled",null);
      }
   {
      String value = convertToString(clientId) + "Input";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
   {
      String value = convertToString(clientId) + "Input";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("name",value,null);
      }
      
   }
      if("readonly".equals((convertToBoolean(component.getAttributes().get("enableManualInput")) ? "" : "readonly")) || Boolean.valueOf((convertToBoolean(component.getAttributes().get("enableManualInput")) ? "" : "readonly")) ) {
        responseWriter.writeAttribute("readonly","readonly",null);
      }
  responseWriter.writeAttribute("type","text",null);
   {
      String value = label;
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("value",value,null);
      }
      
   }
renderPassThroughAttributes(facesContextcomponent
responseWriter.endElement("input"); 
	if (convertToBoolean(component.getAttributes().get("showButton"))) {
		if (convertToBoolean(component.getAttributes().get("disabled"))) {
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-sel-btn rf-sel-btn-dis",null);
   {
      String value = convertToString(clientId) + "Button";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-sel-btn-arrow",null);
	responseWriter.endElement("span"); 
	responseWriter.endElement("span"); 
		if ((!convertToBoolean(component.getAttributes().get("disabled")))) {
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-sel-btn",null);
   {
      String value = convertToString(clientId) + "Button";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-sel-btn-arrow",null);
	responseWriter.endElement("span"); 
	responseWriter.endElement("span"); 
responseWriter.endElement("span"); 
responseWriter.startElement("div"component); 
   {
      String value = this.getListCss(component);
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("class",value,null);
      }
      
   }
   {
      String value = convertToString(clientId) + "List";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
renderListHandlers(facesContextcomponent);;
responseWriter.startElement("div"component); 
  responseWriter.writeAttribute("class","rf-sel-shdw",null);
responseWriter.startElement("div"component); 
  responseWriter.writeAttribute("class","rf-sel-shdw-t",null);
responseWriter.endElement("div"); 
responseWriter.startElement("div"component); 
  responseWriter.writeAttribute("class","rf-sel-shdw-l",null);
responseWriter.endElement("div"); 
responseWriter.startElement("div"component); 
  responseWriter.writeAttribute("class","rf-sel-shdw-r",null);
responseWriter.endElement("div"); 
responseWriter.startElement("div"component); 
  responseWriter.writeAttribute("class","rf-sel-shdw-b",null);
responseWriter.endElement("div"); 
responseWriter.startElement("div"component); 
  responseWriter.writeAttribute("class","rf-sel-lst-dcrtn",null);
responseWriter.startElement("div"component); 
  responseWriter.writeAttribute("class","rf-sel-lst-scrl",null);
   {
      String value = this.encodeHeightAndWidth(component);
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("style",value,null);
      }
      
   }
responseWriter.startElement("div"component); 
   {
      String value = convertToString(clientId) + "Items";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
encodeItems(facesContextcomponentclientSelectItems);;
responseWriter.endElement("div"); 
responseWriter.endElement("div"); 
responseWriter.endElement("div"); 
responseWriter.endElement("div"); 
responseWriter.endElement("div"); 
responseWriter.startElement("script"component); 
  responseWriter.writeAttribute("type","text/javascript",null);
Map<StringObjectoptions = new LinkedHashMap<StringObject>(); 
addToScriptHash(options"clientSelectItems"clientSelectItemsnullnull);
addToScriptHash(options"itemCss""rf-sel-opt"nullnull);
addToScriptHash(options"selectItemCss"this.concatClasses("rf-sel-sel",component.getAttributes().get("selectItemClass")), nullnull);
addToScriptHash(optionsfacesContextcomponentnull);
addToScriptHash(options"filterFunction"this.getClientFilterFunction(component), nullnull);
	Object text = "new RichFaces.ui.Select(\"" + convertToString(clientId) + "\", " + convertToString(toScriptArgs(options)) + ");";
	if (text != null) {
		responseWriter.writeText(textnull); 
	}
responseWriter.endElement("script"); 
responseWriter.endElement("div"); 
	}
public boolean getRendersChildren() 
 {
		return true;
	}
New to GrepCode? Check out our FAQ X