Re: re-post text encoding in a WOText area?
Re: re-post text encoding in a WOText area?
- Subject: Re: re-post text encoding in a WOText area?
- From: Ramsey Gurley <email@hidden>
- Date: Mon, 18 Oct 2010 09:33:27 -0400
Hi Ted,
That sounds like a coercion that might be better handled in a
validation method rather than the setter. It's basically the same
logic you have now, but you would do it in a method like
public String validateJobDescription(String aJobDescription);
where the method takes the input with the trailing 0 and coerces
aJobDescription into the correct value. This has the added benefit of
allowing you to throw a validation exception if things go wrong and
have the WebObjects plumbing turn that into an error message for the
user. You can read more about validation here:
http://developer.apple.com/legacy/mac/library/documentation/InternetWeb/Reference/WO542Reference/com/webobjects/foundation/NSValidation.html
Ramsey
On Oct 18, 2010, at 4:41 AM, Theodore Petrosky wrote:
Last week I asked whether anyone had seen a problem with inserting
text that was copied from a PDF and pasted into a WOText area.
My client was creating a new object (a job). She copied some meta
data (text) from a PDF and pasted it into a WOText:
<wo:WOText value = "$jobDescription" cols = "40" rows = "8" />
she then clicked the save button that fired the saveChanges() on the
EC.
The new object threw an exception and after looking at the logs I
discovered that the text that was pasted from the PDF had a trailing
byte with a value of '0'. I googled around and came up with a
solution to parse the text before trying to insert it into the
database.
this is the setter for the WOText (now):
public void setJobDescription(String aJobDescription) {
String theString = "";
for(char c:aJobDescription.toCharArray()){
if((c&(char)0xff00)==0 && (int)c != 0 ) {
theString=theString+c;
//NSLog.out.appendln("character = " + (int)c);
}
}
_jobDescription = theString;
}
First, has anyone seen this before (text coming from a PDF with
anomalies that will then require processing) and
B, is there a better solution?
I can not be the only person to have a problem with this. I think it
is unreasonable for me to tell my client, "Just copy and paste the
text into a text editor before copying it again then paste it into
the web page."
:-)
Ted
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden