1 33 34 package com.icesoft.faces.renderkit.dom_html_basic; 35 36 import javax.faces.component.UIComponent; 37 import javax.faces.component.UIInput; 38 import javax.faces.component.ValueHolder; 39 import javax.faces.context.FacesContext; 40 import javax.faces.convert.Converter; 41 import javax.faces.convert.ConverterException; 42 import javax.faces.el.ValueBinding; 43 44 public abstract class DomBasicInputRenderer extends DomBasicRenderer { 45 46 50 public void setSubmittedValue(UIComponent uiComponent, 51 Object submittedValue) { 52 if (uiComponent instanceof UIInput) { 53 ((UIInput) uiComponent).setSubmittedValue(submittedValue); 54 } 55 } 56 57 Object getValue(UIComponent uiComponent) { 58 Object value = null; 59 if (uiComponent instanceof ValueHolder) { 60 value = ((ValueHolder) uiComponent).getValue(); 61 } 62 return value; 63 } 64 65 75 76 public Object getConvertedValue(FacesContext facesContext, UIComponent 77 uiComponent, Object submittedValue) throws ConverterException { 78 79 Converter converter = null; 81 if (uiComponent instanceof ValueHolder) { 82 converter = ((ValueHolder) uiComponent).getConverter(); 83 } 84 ValueBinding valueBinding = uiComponent.getValueBinding("value"); 88 if (converter == null && valueBinding != null) { 89 Class valueBindingClass = valueBinding.getType(facesContext); 90 if (valueBindingClass != null) { 91 converter = facesContext.getApplication() 92 .createConverter(valueBindingClass); 93 } 94 } 95 96 if (converter != null) { 97 return converter.getAsObject(facesContext, uiComponent, 98 (String ) submittedValue); 99 } else if (submittedValue != null) { 100 return (String ) submittedValue; 101 } else { 102 return null; 103 } 104 } 105 } 106 | Popular Tags |