-
1. Re: formattedText with dynamic content - escaping
pmuir Nov 20, 2007 11:19 AM (in response to appendix)No, we have no built in class for doing this, but it could be an interesting addition for SeamText, so it would be interesting to see what you come up with.
-
2. Re: formattedText with dynamic content - escaping
appendix Nov 22, 2007 4:17 AM (in response to appendix)Hi Pete,
thank you for showing interest.
I gave the whole situation a brief thought and came to the conclusion that a generic approach that transparently escapes rich text tokens in s:formattedText would be hard to implement, because the method would have to differentiate somehow between formatting rich text tokens and tokens that are simply in the text as characters, so I'm using a pretty simple, but working, approach right now.
I'm having a Seam managed Java Bean called "ste" (short for seam text escaper), which offers a method "esc(String s)" that escapes the rich text tokens using a Stringtokenizer.
So in the message bundle I can escape certain properties, that could contain rich text tokens which needs to be escaped like that:newGroupCreated.text=The new group '*#{ste.esc(group.name)} (#{ste.esc(group.nameShort)})*' was created successfully.
Now 'newGroupCreatet.text' can be used in <s:formattedText /> even if 'group.name' contains characters like underscore or slash without breaking the generated HTML.
If anyone is interested, I can post the code as well, but it's nothing spectacular.
Best regards,
Kurt