TextArea renders apostrophes(and speech marks) incorrectly
I'm pretty new to Wicket. Could someone please tell me why speech marks and apostrophes get rendered by a textarea as a bunch of numbers and a # sign? Here is a bit of code:
public class QuestionOptions extends BasePage{
private int ID;
private String text;
private TextArea optionText,questionText;
private DropDownChoice isOptionCorrect;
private InvalidInputIndicator optionsLabel,isCorrectLabel;
private FeedbackPanel feedback;
public QuestionOptions(final int ID, String questiontext){
this.ID=ID;
text=questiontext;
Form form=new Form("optionsform开发者_运维技巧");
add(form);
feedback=new FeedbackPanel("msgs");
form.add(feedback);
feedback.setOutputMarkupId(true);
questionText=new TextArea("text",new Model(text));
questionText.setEnabled(false);
form.add(questionText);
The idea is that, when designing an MCQ question a lecturer can add different options to the question. The problem is: if the question text contains speech marks or apostrophes, they get rendered in a funny manner. For example the word 'don't' is rendered as don't. If anyone could provide me with a solution to this problem I'd be very grateful.
The basic problem you are having is that quotes, question marks, and other special characters are rendered using special html codes. What seems to be happening is they are being converted to their special tags. Here's a site that should be able to help you generate a helper function which will detect quotes and other special symbols which you can then convert to their proper html code.
for instance, if you encountered a " in the textarea text, you might want to convert that to "
Here's the website that should help, http://www.learningmovabletype.com/a/000235display_code/
Also if that doesn't work, you might try escaping the special characters. Again you would have to write a helper function to detect them. When hitting a quote you would add a backslash before it like so: " -> \"
questionText.setEscapeModelStrings(false);
精彩评论