You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Kurt Sys <ku...@gmail.com> on 2010/10/23 11:36:21 UTC
ajaxeditablelabel and setescapemodelstrings to false
Hi,
I'm new to Wicket and I'm trying to get the feel of it. So I tried a small
webapp, using a AjaxEditableMultiLineLabel, which so far worked perfectly.
However, if I want it not to escape the html-tags - which is generally a bad
idea, I know - I use 'setEscapeModelStrings(false)'. For some reason, it
doesn't work. It does work, however, when I replace the AjaxEditablePanel
(or AjaxEditableMultiLinePanel) with a Panel or MultiLinePanel. See code
below, I'm using wicket-1.4.12 (and wicket-1.4.12-extensions). What am I
missing here?
Oh yeah, I want to extend it to store the panel content in a database
(together with the content of some other panels, e.g. a title, author and
time), so it's a kind of very lightweight personal wiki-like thingy. It
might be I'm not using the best way to achieve this, but I want to keep the
editable panel :). Any suggestions are welcome of course.
Thx, Kurt
'midregion.html'
> [...]
> <div wicket:id="wikicontent">
> </div>
> <span wicket:id="message">text goes here</span>
> [...]
>
> 'midregion.java'
> import org.apache.wicket.markup.html.CSSPackageResource;
> import org.apache.wicket.markup.html.panel.Panel;
> import org.apache.wicket.markup.html.basic.Label;
> import org.apache.wicket.markup.html.basic.MultiLineLabel;
> import org.apache.wicket.model.IModel;
> import
> org.apache.wicket.extensions.ajax.markup.html.AjaxEditableMultiLineLabel;
> import org.apache.wicket.extensions.ajax.markup.html.AjaxEditableLabel;
>
>
> public class midRegion extends Panel {
>
> public midRegion(String id) {
> super(id);
> add(CSSPackageResource.getHeaderContribution(main.class,
> "css/midRegion.css"));
> //AjaxEditableMultiLineLabel<String> mod = new
> AjaxEditableMultiLineLabel<String>("wikicontent", new contentModel()); //
> not ok
> //AjaxEditableLabel<String> mod = new
> AjaxEditableLabel<String>("wikicontent", new contentModel()); // not ok
> MultiLineLabel mod = new MultiLineLabel("wikicontent", new
> contentModel()); // ok
> add(mod.setEscapeModelStrings(false));
> add(new Label( "message", "<h1>Hello!</h1>"
> ).setEscapeModelStrings(false) ); // this is just another test for using
> setEscapeModelStrings
> }
> }
>
> class contentModel
> implements IModel<String> {
>
> private String content="blablabla <b> bold text </b>";
>
> @Override
> public void setObject(String c) {
> this.content = c;
> }
>
> @Override
> public String getObject(){
> return content;
> }
>
> @Override
> public void detach() {
> }
> }
>
Re: ajaxeditablelabel and setescapemodelstrings to false
Posted by Kurt Sys <ku...@gmail.com>.
Hey all,
anyone...? How can I make 'setEscapeModelStrings(false)' work in a
AjaxEditablePanel?
Thx, Kurt
2010/10/23 Kurt Sys <ku...@gmail.com>
> Hi,
>
> I'm new to Wicket and I'm trying to get the feel of it. So I tried a small
> webapp, using a AjaxEditableMultiLineLabel, which so far worked perfectly.
> However, if I want it not to escape the html-tags - which is generally a bad
> idea, I know - I use 'setEscapeModelStrings(false)'. For some reason, it
> doesn't work. It does work, however, when I replace the AjaxEditablePanel
> (or AjaxEditableMultiLinePanel) with a Panel or MultiLinePanel. See code
> below, I'm using wicket-1.4.12 (and wicket-1.4.12-extensions). What am I
> missing here?
> Oh yeah, I want to extend it to store the panel content in a database
> (together with the content of some other panels, e.g. a title, author and
> time), so it's a kind of very lightweight personal wiki-like thingy. It
> might be I'm not using the best way to achieve this, but I want to keep the
> editable panel :). Any suggestions are welcome of course.
>
> Thx, Kurt
>
> 'midregion.html'
>
>> [...]
>> <div wicket:id="wikicontent">
>> </div>
>> <span wicket:id="message">text goes here</span>
>> [...]
>>
>> 'midregion.java'
>
>> import org.apache.wicket.markup.html.CSSPackageResource;
>> import org.apache.wicket.markup.html.panel.Panel;
>> import org.apache.wicket.markup.html.basic.Label;
>> import org.apache.wicket.markup.html.basic.MultiLineLabel;
>> import org.apache.wicket.model.IModel;
>> import
>> org.apache.wicket.extensions.ajax.markup.html.AjaxEditableMultiLineLabel;
>> import org.apache.wicket.extensions.ajax.markup.html.AjaxEditableLabel;
>>
>>
>> public class midRegion extends Panel {
>>
>> public midRegion(String id) {
>> super(id);
>> add(CSSPackageResource.getHeaderContribution(main.class,
>> "css/midRegion.css"));
>> //AjaxEditableMultiLineLabel<String> mod = new
>> AjaxEditableMultiLineLabel<String>("wikicontent", new contentModel()); //
>> not ok
>> //AjaxEditableLabel<String> mod = new
>> AjaxEditableLabel<String>("wikicontent", new contentModel()); // not ok
>> MultiLineLabel mod = new MultiLineLabel("wikicontent", new
>> contentModel()); // ok
>> add(mod.setEscapeModelStrings(false));
>> add(new Label( "message", "<h1>Hello!</h1>"
>> ).setEscapeModelStrings(false) ); // this is just another test for using
>> setEscapeModelStrings
>> }
>> }
>>
>> class contentModel
>> implements IModel<String> {
>>
>> private String content="blablabla <b> bold text </b>";
>>
>> @Override
>> public void setObject(String c) {
>> this.content = c;
>> }
>>
>> @Override
>> public String getObject(){
>> return content;
>> }
>>
>> @Override
>> public void detach() {
>> }
>> }
>>
>
>