KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > renderer > html > TextAreaRenderer


1 /**
2  * Copyright 2001-2004 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  **/

5 package org.exoplatform.faces.core.renderer.html;
6
7 import java.io.IOException JavaDoc;
8 import java.util.Map JavaDoc;
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 /**
17  * @author Ove Ranheim (oranheim@yahoo.no)
18  * @since Jun 15, 2004 5:05:45 PM
19  */

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 JavaDoc paramMap = context.getExternalContext().getRequestParameterMap();
26         String JavaDoc value = (String JavaDoc) paramMap.get(uiInput.getName());
27         if (value == null) return ;
28         // Update managed bean (model object)
29
if (!FacesUtil.updateBoundValueBinding(context, component, "text", value)) {
30             uiInput.setText(value);
31         }
32     }
33     
34   public void encodeBegin(FacesContext context, UIComponent component) throws IOException JavaDoc {
35     UITextArea uiTextArea = (UITextArea) component;
36     ResponseWriter w = context.getResponseWriter() ;
37     String JavaDoc 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