1 5 package org.exoplatform.faces.core.renderer.html; 6 7 import java.io.IOException ; 8 import java.util.Map ; 9 10 import javax.faces.component.UIComponent; 11 import javax.faces.context.FacesContext; 12 import javax.faces.context.ResponseWriter; 13 import org.exoplatform.faces.FacesUtil; 14 import org.exoplatform.faces.core.component.UITextArea; 15 16 20 public class TextAreaRenderer extends HtmlBasicRenderer { 21 22 public void decode(FacesContext context, UIComponent component) { 23 UITextArea uiInput = (UITextArea) component; 24 if(!uiInput.isEditable() || uiInput.isReadonly()) return ; 25 Map paramMap = context.getExternalContext().getRequestParameterMap(); 26 String value = (String ) paramMap.get(uiInput.getName()); 27 if (value == null) return ; 28 if (!FacesUtil.updateBoundValueBinding(context, component, "text", value)) { 30 uiInput.setText(value); 31 } 32 } 33 34 public void encodeBegin(FacesContext context, UIComponent component) throws IOException { 35 UITextArea uiTextArea = (UITextArea) component; 36 ResponseWriter w = context.getResponseWriter() ; 37 String value = uiTextArea.getText() ; 38 if (value == null) value = "" ; 39 w.write("<textarea "); 40 w.write(" id='"); w.write(uiTextArea.getId()); w.write("'") ; 41 w.write(" name='"); w.write(uiTextArea.getName()); w.write("'") ; 42 if (uiTextArea.getCols() != null) { 43 w.write(" cols='"+uiTextArea.getCols()+"'") ; 44 } 45 if (uiTextArea.getRows() != null) { 46 w.write(" rows='"+uiTextArea.getRows()+"'") ; 47 } 48 if (uiTextArea.getClazz() != null) { 49 w.write(" class='"); w.write(uiTextArea.getClazz()); w.write("'") ; 50 } 51 if (uiTextArea.getKeyDown() != null) { 52 w.write(" onKeyDown='"); w.write(uiTextArea.getKeyDown()); w.write("'") ; 53 } 54 if (uiTextArea.getKeyUp() != null) { 55 w.write(" onKeyUp='"); w.write(uiTextArea.getKeyUp()); w.write("'") ; 56 } 57 if(!uiTextArea.isEditable() || uiTextArea.isReadonly()) { 58 w.write(" readonly='readonly' "); 59 } 60 w.write(">") ; 61 w.write(value) ; 62 w.write("</textarea>") ; 63 } 64 } | Popular Tags |