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: Marek Wawrzyczny <email@hidden>
- Date: Mon, 30 Jun 2003 15:40:34 +1000
I think the problem is far more complex than that, we ran into it
ourselves.
Situation:
==========
A user copies a bunch of formatted text from a MS Word document. Pastes
it into a form on the website.
Problem:
========
MS Word puts invisible formatting characters into the text, the
clipboard preserves these characters.
Symptoms:
=========
the website suddenly displays these weird characters, usually as '?'.
Get one irritated customer on the phone.
Solution:
=========
Well in our application we attacked this from two areas.
One , we asked the users to paste the text into a plain text file first
and then onto the form. That at removed the chars. Won't please the
customers too much.
Two, I believe we attempted to remove non ASCI chars on input (on form
submit). This is also a good place to do any other formatting, <P>,
<BR> and so on. That way there's no need to do any conversions on data
display.
On Monday, Jun 30, 2003, at 15:00 Australia/Sydney, Hsu wrote:
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(currStri
ng
));
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.
--
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.
Marek Wawrzyczny
software engineer
-------------------------->
ish group pty ltd
7 Darghan St Glebe 2037 Australia
phone +61 2 9660 1400 fax +61 2 9660 7400
http www.ish.com.au | email email@hidden
_______________________________________________
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.