Author: alevkovsky
Date: 2008-10-30 08:29:32 -0400 (Thu, 30 Oct 2008)
New Revision: 10980
Modified:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/SeamTextConverter.java
Log:
Add converting from html to seam text
Modified:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/SeamTextConverter.java
===================================================================
---
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/SeamTextConverter.java 2008-10-30
11:35:59 UTC (rev 10979)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/SeamTextConverter.java 2008-10-30
12:29:32 UTC (rev 10980)
@@ -39,6 +39,8 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.seam.text.SeamTextLexer;
import org.jboss.seam.text.SeamTextParser;
+import org.richfaces.antlr.HtmlSeamTextLexer;
+import org.richfaces.antlr.HtmlSeamTextParser;
import antlr.ANTLRException;
import antlr.RecognitionException;
@@ -68,7 +70,21 @@
@SuppressWarnings("unchecked")
public Object getAsObject(FacesContext context, UIComponent component,
String value) {
- return value;
+ try {
+ Reader r = new StringReader(value);
+ HtmlSeamTextLexer lexer = new HtmlSeamTextLexer(r);
+ HtmlSeamTextParser parser = new HtmlSeamTextParser(lexer);
+ parser.startRule();
+ return parser.toString();
+ } catch (RecognitionException rex) {
+ // Log a nice message for any lexer/parser errors, users can disable
+ // this if they want to
+ _log.warn("Seam Text parse error: " + rex.getMessage());
+ } catch (ANTLRException ex) {
+ // All other errors are fatal;
+ throw new RuntimeException(ex);
+ }
+ return null;
}
/**
Show replies by date