bostonaholic
April 21st, 2009, 05:28 PM
I've got an issue where I have a JTextPane the user supplies plain text. When the text is persisted to the DB and brought back to the screen. Random spaces are being removed.
Here's some code:
In the panel
noteTextArea.setContentType("text/html");
HTMLDocument ntaDoc = (HTMLDocument)noteTextArea.getDocument();
ntaDoc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
ntaDoc.setPreservesUnknownTags(false);
In the controller
//setting the text of the note
noteValue.setText(getPanel().noteTextArea.getText( ));
So, the user would type
Is this note going to have the same problems with the space issues? This is attaching a note through the member profile via Attach > Note. Let's cross our fingers that this does not happen again. Please.
And then what's persisted to the DB is a CLOB with the value
<html>\n <head>\n\n </head>\n <body>\n <p>\n Is this note going to have the same problems with the space issues? \n This is attaching a note through the member profile via Attach > Note. \n Let's cross our fingers\n that this does not happen again. Please. </p>\n </body>\n</html>\n
When another JPanel reads that from the DB, it comes out to be
Is this note going to have the same problems with the space issues?This is attaching a note through the member profile via Attach > Note.Let's cross our fingers that this does not happen again. Please.
Notice that I bolded where spaces have been removed.
What can I do to fix this? Thanks.
Here's some code:
In the panel
noteTextArea.setContentType("text/html");
HTMLDocument ntaDoc = (HTMLDocument)noteTextArea.getDocument();
ntaDoc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
ntaDoc.setPreservesUnknownTags(false);
In the controller
//setting the text of the note
noteValue.setText(getPanel().noteTextArea.getText( ));
So, the user would type
Is this note going to have the same problems with the space issues? This is attaching a note through the member profile via Attach > Note. Let's cross our fingers that this does not happen again. Please.
And then what's persisted to the DB is a CLOB with the value
<html>\n <head>\n\n </head>\n <body>\n <p>\n Is this note going to have the same problems with the space issues? \n This is attaching a note through the member profile via Attach > Note. \n Let's cross our fingers\n that this does not happen again. Please. </p>\n </body>\n</html>\n
When another JPanel reads that from the DB, it comes out to be
Is this note going to have the same problems with the space issues?This is attaching a note through the member profile via Attach > Note.Let's cross our fingers that this does not happen again. Please.
Notice that I bolded where spaces have been removed.
What can I do to fix this? Thanks.