Author: adubovsky
Date: 2008-11-25 07:33:53 -0500 (Tue, 25 Nov 2008)
New Revision: 11354
Modified:
trunk/test-applications/jsp/src/main/java/editor/Editor.java
Log:
Modified: trunk/test-applications/jsp/src/main/java/editor/Editor.java
===================================================================
--- trunk/test-applications/jsp/src/main/java/editor/Editor.java 2008-11-25 12:32:33 UTC
(rev 11353)
+++ trunk/test-applications/jsp/src/main/java/editor/Editor.java 2008-11-25 12:33:53 UTC
(rev 11354)
@@ -1,16 +1,97 @@
package editor;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.validator.ValidatorException;
+import org.richfaces.component.html.HtmlEditor;
+import util.componentInfo.ComponentInfo;
+
public class Editor {
+ private HtmlEditor htmlEditor;
private String value;
private String width;
private String height;
+ private String theme;
public Editor() {
value = "Collaboration-oriented websites require a human-friendly markup language
for easy entry of formatted text in forum posts, wiki pages, blogs, comments, etc. Seam
provides the <s:formattedText/> control for display of formatted text that
conforms to the Seam Text language. Seam Text is implemented using an ANTLR-based parser.
You don't need to know anything about ANTLR to use it, however.";
width = "400";
height = "200";
+ theme = "simple";
}
+
+ /*
+ * Custom valueChangeListener
+ */
+ public void valueChangeListener(ValueChangeEvent e) {
+ System.out.println("!!! valueChangeListener work !!!");
+ }
+
+ /*
+ * Custom Converter for editor
+ */
+ public Converter getConvert() {
+ return new Converter() {
+ public Object getAsObject(FacesContext context,
+ UIComponent component, String newValue)
+ throws ConverterException {
+
+ System.out.println("!!! getAsObject work !!!");
+
+ if (false)
+ throw new ConverterException(new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, "Converter error",
+ "Error while convert to Object"));
+ return newValue;
+ }
+
+ public String getAsString(FacesContext context,
+ UIComponent component, Object value)
+ throws ConverterException {
+
+ System.out.println("!!! getAsString work !!!");
+
+ if (false)
+ throw new ConverterException(new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, "Converter error",
+ "Error while convert to String"));
+
+ String result = (value == null)?"":value.toString();
+ return result;
+ }
+ };
+ }
+
+ /*
+ * Custom Validator for Editor
+ */
+ public void validate(FacesContext context, UIComponent component,
+ Object value) throws ValidatorException {
+
+ System.out.println("!!! Validator work !!!");
+ if (value != null) {
+
+ if (false) {
+ throw new ValidatorException(new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, "Validation error",
+ "Incorrect input"));
+ }
+ }
+ }
+
+ /*
+ * Add test via reflection
+ */
+ public void addHtmlEditor() {
+ ComponentInfo info = ComponentInfo.getInstance();
+ info.addField(htmlEditor);
+ }
+
public String getValue() {
return value;
}
@@ -34,4 +115,20 @@
public void setHeight(String height) {
this.height = height;
}
+
+ public HtmlEditor getHtmlEditor() {
+ return htmlEditor;
+ }
+
+ public void setHtmlEditor(HtmlEditor htmlEditor) {
+ this.htmlEditor = htmlEditor;
+ }
+
+ public String getTheme() {
+ return theme;
+ }
+
+ public void setTheme(String theme) {
+ this.theme = theme;
+ }
}
Show replies by date