Reputation: 791
In my html file I have a div tag like this,
<div wicket:id="editorArea">Type Here</div>
I am using a JavaScript library called bootstrap-wysiwyg to make this div tag a text are which we can type rich text. When the person types text, div tag's html content updates to represent the text content in html. I want to retrieve it in to the Java code of the html file in wicket. I tried to do it by creating reference variable to div tag like following,
WebMarkupContainer editorArea=new WebMarkupContainer("editorArea");
String text=editorArea.getMarkup().toString(true)
But this don't give me the updated HTML content. I give only the initial html content. what is the problem here?
Upvotes: 1
Views: 2261
Reputation: 1984
getMarkup() only gives you the markupfile for the component if I read the javadoc right. Try either
editorArea.getModelObject()
or
editorArea.getValue()
The first one is preferred but because the editorArea is a WebMarkupContainer it might not work as intended.
Upvotes: 0
Reputation: 5575
Take a look at AjaxEditableLabel from the wicket-extensions.
The Label will update it's model with the typed content
There is an example at the Wicket Library, showing how it can be used. This example uses an CompoundPropertyModel but can easily adapable to work with other types of models too.
Upvotes: 1
Reputation: 31
You probably need to add editorArea to the html code first
WebMarkupContainer editorArea=new WebMarkupContainer("editorArea");
add(editorArea);
String text=editorArea.getMarkup().toString(true)
Upvotes: 2