سؤال

I'm using GWT 2.5 in one of my new projects and ran into a small obstacle. The previous versions of GWT had SafeHTML disabled for the HTMLPanel which meant that if I put a large block of text in an HTMLPanel, it would respond like normal HTML, all double+ spaces would be removed and all newlines would be removed. With GWT 2.5, all my spaces are replaced with nbsp; and long lines run out of the screen ignoring all my CSS rules

<ui:style>
    .justify {
        text-align: justify;    
    }
</ui:style>
<g:HTMLPanel styleName="{style.justify}">

LARGE BLOCK OF TEXT THAT 
SOMETIMES GOES FAR OUT OF MY IDE AND OTHER TIMES
ONLY DO
THIS

</g:HTMLPanel>

The above example would look the following in GWT 2.4 (obviously justified):

LARGE BLOCK OF TEXT THAT 
SOMETIMES GOES FAR OUT OF 
MY IDE AND OTHER TIME 
ONLY DO THIS

In GWT2.5, the above example would look like this (with all spaces replaced with "& nbsp;" causing it to overflow its container even with wordwrap enabled):

LARGE BLOCK OF TEXT THAT 
SOMETIMES GOES FAR OUT OF MY IDE AND OTHER TIMES
ONLY DO
THIS

Any idea how to disable SafeHTML in GWT 2.5 for HTMLPanels or any alternative ideas on how I can put "natural HTML" inside my page without having my spaces replaced with "& nbsp;" ?

هل كانت مفيدة؟

المحلول

Got a response from Google Support after logging a bug, who said they can not reproduce the issue I'm having and suggested I have a look at what spaces my code contains (something very obvious which I never thought about). It turns out my IDE, for some strange reason, is adding U+00A0 type spaces instead of U+0020 which is then converted to nbsp;

So if you do see nbsp; in your output, have a look at what type of spaces your IDE is inserting. A big thanks to Google Support for pointing this out!!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top