KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > component > UIText


1 /*******************************************************************************
2  * Copyright 2001-2003 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.component;
6
7 import org.exoplatform.commons.utils.HtmlUtil;
8 import org.exoplatform.faces.core.component.UISimpleForm;
9 import org.exoplatform.faces.core.component.UITextArea;
10 import org.exoplatform.faces.core.component.model.ComponentCell;
11 import org.exoplatform.faces.core.component.model.FormButton;
12 import org.exoplatform.faces.core.component.model.ListComponentCell;
13 import org.exoplatform.faces.core.component.model.Row;
14 import org.exoplatform.faces.core.event.ExoActionEvent;
15 import org.exoplatform.faces.core.event.ExoActionListener;
16 /**
17  * Wed, March 22, 2004 @ 23:14
18  * @author: Tuan Nguyen
19  * @email: tuan08@users.sourceforge.net
20  * @version: $Id: UIPageConfiguration.java,v 1.3 2004/08/07 18:11:24 tuan08 Exp $
21  */

22 public class UIText extends UISimpleForm {
23   final static public String JavaDoc PREVIEW_MODE_ACTION = "previewMode" ;
24   final static public String JavaDoc EDIT_MODE_ACTION = "editMode" ;
25   
26   private UITextArea textInput_ ;
27   private ListComponentCell actions_ ;
28   
29   public UIText() {
30     super("textForm", "post", null) ;
31     setId("UIText");
32     textInput_ = new UITextArea("text" , "") ;
33     add(new Row().
34         add(new ComponentCell(this, textInput_))) ;
35     actions_ = new ListComponentCell() ;
36     add(new Row().
37         add(actions_.addColspan("2").addAlign("center"))) ;
38   }
39   
40   public void addEditButton(String JavaDoc label, String JavaDoc action, Class JavaDoc listener) {
41     actions_.add(new FormButton(label, action, EDIT_MODE)) ;
42     addActionListener(listener, action) ;
43   }
44   
45   public void addViewButton(String JavaDoc label, String JavaDoc action, Class JavaDoc listener) {
46     actions_.add(new FormButton(label, action, VIEW_MODE)) ;
47     addActionListener(listener, action) ;
48   }
49   
50   public String JavaDoc getText() { return textInput_.getValue(); }
51   public void setText(String JavaDoc page) {
52     if (page != null) textInput_.setValue(page) ;
53     else textInput_.setValue("") ;
54   }
55   
56   public void setXMLText(String JavaDoc text) {
57     if (text != null) {
58       text = HtmlUtil.showXmlTags(text) ;
59       textInput_.setValue(text) ;
60     } else {
61       textInput_.setValue("") ;
62     }
63   }
64   
65   public class PreviewModeActionListener extends ExoActionListener {
66         public void execute(ExoActionEvent event) throws Exception JavaDoc {
67           UIText uiText = (UIText) event.getSource();
68       uiText.setMode(VIEW_MODE) ;
69         }
70   }
71   
72   public class EditModeActionListener extends ExoActionListener {
73         public void execute(ExoActionEvent event) throws Exception JavaDoc {
74       UIText uiText = (UIText) event.getSource();
75       uiText.setMode(VIEW_MODE) ;
76         }
77   }
78 }
Popular Tags