Disable HTML Encoding In Widgets

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Disable HTML Encoding In Widgets

BrettS
Hi,

I have a problem with OFBiz doing HTML encoding of characters that I don't want encoded. Specifically, OFBiz is replacing "<" and ">" with:
&lt;
 
&gt;
 (encoded strings) in a widget.

Can someone tell me how to fix this issue please? Details as follows.

I have the following snippet of code in a file called browser.ftl file:
----------------------------------------
<html>
<head>
${browserProfile.metaTag}
...
----------------------------------------
${browserProfile.metaTag} *should* return a string in this format:
<meta name="foo" content="foo2"/>


If I map the browser.ftl file in controller.xml via a widget as shown below:
<view-map name="browser" type="screen" page="component://ecommerce/widget/BrowserScreens.xml#browser"/>

then unfortunately, OFBiz will replace "<" and ">" with encoded strings.

However, if (as a test) I map the browser.ftl file *directly* as shown below:
<view-map name="browser" type="ftl" page="browser.ftl"/>

Then, OFBiz does *not* encode the string and I get the correct output.

Any suggestions how I can stop my widget encoding these characters?

Regards

Brett S

P.S. this is what BrowserScreens.xml looks like.


----------------------------------------
<screen name="CommonDecorator">
<section>
    <widgets>
        <platform-specific><html><html-template location="component://ecommerce/webapp/ecommerce/browser/includes/header.ftl"/></html></platform-specific>

                        <decorator-section-include name="body"/>

                        <platform-specific><html><html-template location="component://ecommerce/webapp/ecommerce/browser/includes/footer.ftl"/></html></platform-specific>
    </widgets>
</section>
</screen>

<screen name="browser">
<section>
    <widgets>
                        <decorator-screen name="CommonDecorator">
                                <decorator-section name="body">
                                        <platform-specific><html><html-template location="component://ecommerce/webapp/ecommerce/browser.ftl"/></html></platform-specific>
                                </decorator-section>
                        </decorator-screen>
    </widgets>
</section>
</screen>

----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Disable HTML Encoding In Widgets

Scott Gray-2
Hi Brett,

You need to wrap the variable in the following method:
${StringUtil.wrapString(browserProfile.metaTag)}

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 22/02/2010, at 3:46 AM, BrettS wrote:

>
> Hi,
>
> I have a problem with OFBiz doing HTML encoding of characters that I don't
> want encoded. Specifically, OFBiz is replacing "<" and ">" with: &lt; &gt;
> (encoded strings) in a widget.
>
> Can someone tell me how to fix this issue please? Details as follows.
>
> I have the following snippet of code in a file called browser.ftl file:
> ----------------------------------------
> <html>
> <head>
> ${browserProfile.metaTag}
> ...
> ----------------------------------------
> ${browserProfile.metaTag} *should* return a string in this format:
> <meta name="foo" content="foo2"/>
>
>
> If I map the browser.ftl file in controller.xml via a widget as shown below:
> <view-map name="browser" type="screen"
> page="component://ecommerce/widget/BrowserScreens.xml#browser"/>
>
> then unfortunately, OFBiz will replace "<" and ">" with encoded strings.
>
> However, if (as a test) I map the browser.ftl file *directly* as shown
> below:
> <view-map name="browser" type="ftl" page="browser.ftl"/>
>
> Then, OFBiz does *not* encode the string and I get the correct output.
>
> Any suggestions how I can stop my widget encoding these characters?
>
> Regards
>
> Brett S
>
> P.S. this is what BrowserScreens.xml looks like.
>
>
> ----------------------------------------
> <screen name="CommonDecorator">
> <section>
>    <widgets>
> <platform-specific><html><html-template
> location="component://ecommerce/webapp/ecommerce/browser/includes/header.ftl"/></html></platform-specific>
>
> <decorator-section-include name="body"/>
>
> <platform-specific><html><html-template
> location="component://ecommerce/webapp/ecommerce/browser/includes/footer.ftl"/></html></platform-specific>
>    </widgets>
> </section>
> </screen>
>
> <screen name="browser">
> <section>
>    <widgets>
> <decorator-screen name="CommonDecorator">
> <decorator-section name="body">
> <platform-specific><html><html-template
> location="component://ecommerce/webapp/ecommerce/browser.ftl"/></html></platform-specific>
> </decorator-section>
> </decorator-screen>
>    </widgets>
> </section>
> </screen>
>
> ----------------------------------------
> --
> View this message in context: http://n4.nabble.com/Disable-HTML-Encoding-In-Widgets-tp1564243p1564243.html
> Sent from the OFBiz - Dev mailing list archive at Nabble.com.


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Disable HTML Encoding In Widgets

BrettS
That did the trick.

Thanks Scott!

Regards

Brett S