Re: String.equals not working in IE
I had implemented something similar to your first suggestion, I just thought I had missed something obvious. The second suggestion is interesting. I'll be mulling over both, thanks! On Jan 9, 7:39 am, Thomas Broyer wrote: > On Jan 7, 1:46 am, TM wrote: > > > > > > > Here is the scenario: > > > I have a TextArea on my page that displays a couple of paragraphs > > pulled from the database for editing. When the form is submitted the > > TextArea contents are checked to see if any changes have been made. > > > Here is the Java code to test for changes: > > > if (newFormText.equals(originalDBText)) > > formChanged = false; > > > This works fine for Firefox but fails on IE. > > > I had a hunch it was the returns between the paragraphs so I URL- > > encoded the text to see. > > > Original text from db: paragraph%0D%0A%0D%0Aparagraph > > > IE sends back this: paragraph%0A%0Aparagraph > > > while FF sends back: paragraph%0D%0A%0D%0Aparagraph > > > The classic Unix/DOS carriage return / line feed problem. > > > So even if the text is unchanged by the user the browser may sent back > > different text. > > > I may be missing something obvious, but I would have thought this > > would be something GWT or Javascript took care of automatically. > > > Is there a quick fix / best practice / alternative method available? > > Have a look at the JavaDoc for > setText:http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/g...) > > In your case, I'd either: > - normalize the text (replace \r\n with \n before comparing strings) > - "normalize" the "original text" by retrieving it from the TextArea > just after you set it, so what you compare it later you don't have to > "normalize" anything yet again. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: String.equals not working in IE
On Jan 7, 1:46 am, TM wrote: > Here is the scenario: > > I have a TextArea on my page that displays a couple of paragraphs > pulled from the database for editing. When the form is submitted the > TextArea contents are checked to see if any changes have been made. > > Here is the Java code to test for changes: > > if (newFormText.equals(originalDBText)) > formChanged = false; > > This works fine for Firefox but fails on IE. > > I had a hunch it was the returns between the paragraphs so I URL- > encoded the text to see. > > Original text from db: paragraph%0D%0A%0D%0Aparagraph > > IE sends back this: paragraph%0A%0Aparagraph > > while FF sends back: paragraph%0D%0A%0D%0Aparagraph > > The classic Unix/DOS carriage return / line feed problem. > > So even if the text is unchanged by the user the browser may sent back > different text. > > I may be missing something obvious, but I would have thought this > would be something GWT or Javascript took care of automatically. > > Is there a quick fix / best practice / alternative method available? Have a look at the JavaDoc for setText: http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/ui/TextBoxBase.html#setText(java.lang.String) In your case, I'd either: - normalize the text (replace \r\n with \n before comparing strings) - "normalize" the "original text" by retrieving it from the TextArea just after you set it, so what you compare it later you don't have to "normalize" anything yet again. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
String.equals not working in IE
Here is the scenario: I have a TextArea on my page that displays a couple of paragraphs pulled from the database for editing. When the form is submitted the TextArea contents are checked to see if any changes have been made. Here is the Java code to test for changes: if (newFormText.equals(originalDBText)) formChanged = false; This works fine for Firefox but fails on IE. I had a hunch it was the returns between the paragraphs so I URL- encoded the text to see. Original text from db: paragraph%0D%0A%0D%0Aparagraph IE sends back this: paragraph%0A%0Aparagraph while FF sends back: paragraph%0D%0A%0D%0Aparagraph The classic Unix/DOS carriage return / line feed problem. So even if the text is unchanged by the user the browser may sent back different text. I may be missing something obvious, but I would have thought this would be something GWT or Javascript took care of automatically. Is there a quick fix / best practice / alternative method available? -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.