This content has been marked as final.
Show 4 replies
-
1. Re: CDATA and formattedText in RSS XML
gavin.king Feb 16, 2008 4:47 PM (in response to susnet.susanne.susnet.se)Call the Seam Text parser directly in code, instead of using s:formattedText. It's in the org.jboss.seam.text package.
-
2. Re: CDATA and formattedText in RSS XML
susnet.susanne.susnet.se Feb 19, 2008 1:26 AM (in response to susnet.susanne.susnet.se)Thanks for your answer, it solved my problem!
If someone else wonder how, I post my code here. I added the following method to my blogEntry entity:
import java.io.Reader; import java.io.Serializable; import java.io.StringReader; import java.util.*; import javax.faces.context.FacesContext; import javax.persistence.*; import javax.servlet.http.HttpServletResponse; import org.jboss.seam.text.*; public String getFormattedContent() { HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance ().getExternalContext ().getResponse (); response.setContentType ("application/rss+xml"); Reader r = new StringReader(content); SeamTextLexer lexer = new SeamTextLexer(r); SeamTextParser parser = new SeamTextParser(lexer); try { parser.startRule(); } catch (Exception e) { System.out.println(e.getMessage()); } return parser.toString(); }
where content is the String property containing the seam text.
-
3. Re: CDATA and formattedText in RSS XML
tony.herstell1 Jul 20, 2008 2:49 PM (in response to susnet.susanne.susnet.se)This code appears not to work.
Some problem with new SeamTextParser(lexer)Any ideas?
-
4. Re: CDATA and formattedText in RSS XML
susnet.susanne.susnet.se Jul 20, 2008 9:58 PM (in response to susnet.susanne.susnet.se)This code I use in production with Seam 2.0.2.SP1 and it works just fine. It is the same as the code above except that I add the
CDATA
strings to start and end of the string that i return (and also don't print the CDATA string in the xhtml file).public String getFormattedContent() { HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance ().getExternalContext ().getResponse (); response.setContentType ("application/rss+xml"); Reader r = new StringReader(content); SeamTextLexer lexer = new SeamTextLexer(r); SeamTextParser parser = new SeamTextParser(lexer); try { parser.startRule(); } catch (Exception e) { System.out.println(e.getMessage()); } StringBuilder formattedContentBuilder = new StringBuilder(); formattedContentBuilder.append("<![CDATA["); formattedContentBuilder.append(parser.toString()); formattedContentBuilder.append("]]>"); return formattedContentBuilder.toString(); }