Re: WOText Conversion to HTML On The Fly
Re: WOText Conversion to HTML On The Fly
- Subject: Re: WOText Conversion to HTML On The Fly
- From: Hsu <email@hidden>
- Date: Sun, 29 Jun 2003 22:00:56 -0700
Couldn't you just bind to a WOString with escapeHTML set to "NO" ?
Karl
On Sunday, June 29, 2003, at 08:25 PM, Dan Faber wrote:
I do a lot of presenting text from Strings. I paste the string (or text
from a word processing document) into a WOTextBox and then can
immediately show the text as HTML. In my case, I am currently doing
some processing of the text before going to HTML, in this case taking
xml text and creating java objects which then present their text on the
web page.
By far the easiest way I have found to do this is:
1. create another component ("Message component" or MC) and place it in
the webobjects builder page where you want the HTML text to appear as a
"custom web object", the last icon on the bar to the right.
2. strip the MC of the HTML tags, and put in "append to response" code,
which adds the text to the response. Here is an example:
import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;
public class DisplayNote extends WOComponent {
protected WOComponent returnPage;
public DisplayNote(WOContext context) {
super(context);
}
public void appendToResponse (WOResponse aResponse, WOContext
aContext) {
//we need to add the note text at the bottom
TPStringToHTML stringConverter = new TPStringToHTML();
if (parent() instanceof EditMessageText) {
textToDisplay = ((EditMessageText)parent()).inputText();
}
//use other checks here to reuse this component for other parent
components...
aResponse.appendContentData(stringConverter.convertTextToHTML(currStrin
g
));
aResponse.appendContentString("<br>");
}
}
TPStringToHTML is simply a formatter I wrote to convert all the '\r'
characters to <br> tags. It takes a string as input, and outputs NSData
with the changes made.
This seems to be working real well for me, and I am using it in several
places. Hope this helps.
Dan
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
--
I am going to pose a question. Can you answer?
Please ask your question.
I have already asked.
I have already answered.
What did you answer?
What did you ask?
I asked nothing.
I answered nothing.
Homepage:
http://homepage.mac.com/khsu/index.html
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.