Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.richfaces.renderkit.html;
  
  import java.util.Map;
  import  javax.faces.component.UIComponent;
  import  javax.faces.context.FacesContext;
  import  javax.faces.context.ResponseWriter;
 import static org.richfaces.renderkit.RenderKitUtils.*;
 
 
 public class InplaceInputRenderer extends InplaceInputRendererBase {
 	
 private static final Attributes PASS_THROUGH_ATTRIBUTES22 = attributes()
 	     .generic("dir","dir")
 	     
 
 	     .generic("lang","lang")
 	     
 
 	     .generic("onclick","onclick","click")
 	     
 
 	     .generic("ondblclick","ondblclick","dblclick","ondblclick")
 	     
 
 	     .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("role","role")
 	     
 
 	     .generic("style","style")
 	     
 
 	     .generic("title","title")
 	     
 ;
 	
 private static final Attributes PASS_THROUGH_ATTRIBUTES23 = attributes()
 	     .generic("tabindex","tabindex")
 	     
 ;
 	
 private static final Attributes ATTRIBUTES_FOR_SCRIPT_HASH22 = attributes()
 	     .generic("state","state")
 	     
 
 	     .generic("saveOnBlur","saveOnBlur")
 	     .defaultValue(true)
 
 	     .generic("showControls","showControls")
 	     .defaultValue(false)
 ;
 	
 private static final Attributes ATTRIBUTES_FOR_SCRIPT_HASH23 = attributes()
 	     .generic("onbegin","onbegin")
 	     
 
 	     .generic("oncomplete","oncomplete")
 	     
 
 	     .generic("onerror","onerror")
 	     
 
 	     .generic("onbeforedomupdate","onbeforedomupdate")
 	     
 
 	     .generic("onselectitem","onselectitem")
 	     
 
 	     .generic("onchange","onchange","change")
 	     
	     .generic("onblur","onblur","blur")
	     
	     .generic("onfocus","onfocus","focus")
	     
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);
InplaceState inplaceState  =  (InplaceState)this.getInplaceState(component); 
String inplaceValue  =  (String)this.getValue(facesContext,component); 
String defaultLabel  =  (String)(((inplaceValue != null) && (inplaceValue.length() != 0)) ? inplaceValue : "\u00A0\u00A0\u00A0"); 
responseWriter.startElement("span"component); 
   {
      Object value = this.concatClasses(this.getContainerStyleClasses(component),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);
      }
      
   }
renderPassThroughAttributes(facesContextcomponent
responseWriter.startElement("span"component); 
   {
      String value = "rf-ii-lbl" + convertToString((isEqual(inplaceValue,component.getAttributes().get("defaultLabel")) ? " rf-ii-dflt-lbl" : ""));
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("class",value,null);
      }
      
   }
   {
      String value = convertToString(clientId) + "Label";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
	Object text = defaultLabel;
	if (text != null) {
		responseWriter.writeText(textnull); 
	}
responseWriter.endElement("span"); 
	if ((!convertToBoolean(component.getAttributes().get("disabled")))) {
	responseWriter.startElement("input"component); 
	  responseWriter.writeAttribute("class","rf-ii-none",null);
   {
      String value = convertToString(clientId) + "Focus";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
   {
      String value = convertToString(clientId) + "Focus";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("name",value,null);
      }
      
   }
  responseWriter.writeAttribute("style","position: absolute; top: 0px; left: 0px; outline-style: none;",null);
  responseWriter.writeAttribute("tabindex","-1",null);
  responseWriter.writeAttribute("type","image",null);
	responseWriter.endElement("input"); 
	responseWriter.startElement("span"component); 
	   {
      String value = this.getEditStyleClass(component,inplaceState);
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("class",value,null);
      }
      
   }
   {
      String value = convertToString(clientId) + "Edit";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
	responseWriter.startElement("input"component); 
	  responseWriter.writeAttribute("autocomplete","off",null);
  responseWriter.writeAttribute("class","rf-ii-fld",null);
   {
      String value = convertToString(clientId) + "Input";
      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);
      }
      
   }
   {
      String value = "width: " + convertToString(this.getInputWidth(component)) + ";";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("style",value,null);
      }
      
   }
  responseWriter.writeAttribute("type","text",null);
   {
      String value = this.getInputValue(facesContext,component);
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("value",value,null);
      }
      
   }
renderPassThroughAttributes(facesContextcomponent
	renderInputHandlers(facesContextcomponent);;
	responseWriter.endElement("input"); 
		if (convertToBoolean(component.getAttributes().get("showControls"))) {
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn-prepos",null);
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn-pos",null);
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn-shdw",null);
   {
      String value = convertToString(clientId) + "Btnshadow";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn-shdw-t",null);
	responseWriter.endElement("span"); 
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn-shdw-l",null);
	responseWriter.endElement("span"); 
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn-shdw-r",null);
	responseWriter.endElement("span"); 
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn-shdw-b",null);
	responseWriter.endElement("span"); 
	responseWriter.startElement("span"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn-cntr",null);
   {
      String value = convertToString(clientId) + "Btn";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
	responseWriter.startElement("input"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn",null);
   {
      String value = convertToString(clientId) + "Okbtn";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
   {
      String value = convertToString(clientId) + "Okbtn";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("name",value,null);
      }
      
   }
  responseWriter.writeAttribute("onmousedown","this.className='rf-ii-btn-p'",null);
  responseWriter.writeAttribute("onmouseout","this.className='rf-ii-btn'",null);
  responseWriter.writeAttribute("onmouseup","this.className='rf-ii-btn'",null);
   {
      String value = this.getResourcePath(facesContext,"org.richfaces","ico_ok.gif");
      if(null != value && value.length()>0) {
        responseWriter.writeURIAttribute("src",value,null);
      }
   }
  responseWriter.writeAttribute("tabindex","-1",null);
  responseWriter.writeAttribute("type","image",null);
	responseWriter.endElement("input"); 
	responseWriter.startElement("input"component); 
	  responseWriter.writeAttribute("class","rf-ii-btn",null);
   {
      String value = convertToString(clientId) + "Cancelbtn";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("id",value,null);
      }
      
   }
   {
      String value = convertToString(clientId) + "Cancelbtn";
      if(null != value &&
         value.length()>0
      ) {
        responseWriter.writeAttribute("name",value,null);
      }
      
   }
  responseWriter.writeAttribute("onmousedown","this.className='rf-ii-btn-press'",null);
  responseWriter.writeAttribute("onmouseout","this.className='rf-ii-btn'",null);
  responseWriter.writeAttribute("onmouseup","this.className='rf-ii-btn'",null);
   {
      String value = this.getResourcePath(facesContext,"org.richfaces","ico_cancel.gif");
      if(null != value && value.length()>0) {
        responseWriter.writeURIAttribute("src",value,null);
      }
   }
  responseWriter.writeAttribute("tabindex","-1",null);
  responseWriter.writeAttribute("type","image",null);
	responseWriter.endElement("input"); 
	responseWriter.endElement("span"); 
	responseWriter.endElement("span"); 
	responseWriter.endElement("span"); 
	responseWriter.endElement("span"); 
	responseWriter.endElement("span"); 
	responseWriter.startElement("script"component); 
	  responseWriter.writeAttribute("type","text/javascript",null);
	Map<StringObjectoptions = new LinkedHashMap<StringObject>(); 
addToScriptHash(options"readyCss"this.concatClasses("rf-ii",component.getAttributes().get("readyStateClass")), nullnull);
addToScriptHash(options"noneCss"this.concatClasses("rf-ii-none",component.getAttributes().get("noneStateClass")), nullnull);
addToScriptHash(options"changedCss"this.concatClasses("rf-ii-chng",component.getAttributes().get("changedClass")), nullnull);
addToScriptHash(options"editCss"this.concatClasses("rf-ii-act",component.getAttributes().get("activeClass")), nullnull);
addToScriptHash(options"editEvent"this.getEditEvent(component), nullnull);
addToScriptHash(options"defaultLabel"defaultLabelnullnull);
addToScriptHash(optionsfacesContextcomponentnull);
	{
	Object text = "new RichFaces.ui.InplaceInput(\"" + convertToString(clientId) + "\", " + convertToString(toScriptArgs(options)) + ");";
	if (text != null) {
		responseWriter.writeText(textnull); 
	}
	responseWriter.endElement("script"); 
responseWriter.endElement("span"); 
	}
New to GrepCode? Check out our FAQ X