Project

General

Profile

How can i change the HTML-language of the generated web-site?

Added by matthias pfuhl over 11 years ago

Dear Community,

we want to use JWt as our new main gui-framework.

When I started to work with JWt I got one big problem:

A Screenreader has to read the page in future, but the Screenreader has to read it in german!

But the generated HTML contains the following line:

So my question is: How can I modify this line or the arguments of a generated HTML-page?

Greetings,

Sonny


Replies (21)

RE: How can i change the HTML-language of the generated web-site? - Added by Wim Dumon over 11 years ago

Hello Sonny,

This is unfortunately hard-coded. Is there a different way that you can tell the screenreader which language it should use? A tag on WApplication->root() maybe?

BR,

Wim.

RE: How can i change the HTML-language of the generated web-site? - Added by matthias pfuhl over 11 years ago

Hello Wim,

this is maybe possible! But how can I add any tags there?

The .html-Skeletons u use, contain this line:

<html $_HTMLATTRIBUTES_$>

... is it not possible the change some attributes?

How is it about the

-Tag, can I change the language for this tag?

Thanks for your help so far!

Sonny

PS: The reason why we test the JWt-Framework is: We want our product to be barrier-free - that means that everybody (also half- or full-blind people) could use our product. And our current framework (Vaadin) does not support this! JWt support this very well, so far, but if the Screenreader reads only english, we have to search again :/

RE: How can i change the HTML-language of the generated web-site? - Added by Wim Dumon over 11 years ago

Matthias,

We certainly don't want such a small tag to become a blocking issue, so if necessary we'll make this configurable (or omit it from the HTML tag). If you want to experiment with this: the HTMLATTRIBUTES are set in WebRenderer.java.

Maybe you can use a metaheader (WApplication.addMetaHeader()) to set the language?

Could you try to call WApplication.root().setAttributeValue() to override the language?

Best regards,

Wim.

RE: How can i change the HTML-language of the generated web-site? - Added by matthias pfuhl over 11 years ago

Hey Wim,

I was on vacation, so I couldn't test ur suggestions so far.

But now I did.

I don't want to change/edit your WebRenderer.java, I think the other possibilities are a way better.

But if nothing else work, I would edit it.

Currently I try to find out, if there is a meta-tag, which tells all screen-readers the right language.

There are a lot of different screen-reader - unfortunally we have to serve all :/.

Also a good solution would be, to tell all of our customers with a screen-reader to set the language by hand.

The getRoot().serAttributValue(); works! But what is the Attributs-Name (I tried "lang" and nothing changed) ?

Thanks for your help and support so far!

Matthias aka Sonny

RE: How can i change the HTML-language of the generated web-site? - Added by Wim Dumon over 11 years ago

Matthias,

getRoot() returns the toplevel WContainer widget in your application. In Wt, a WContainer is rendered as a

. So if you call setAttribute() on getRoot(), you'll add an attribute to a

in which the entire user interface will be rendered (which is not the toplevel div in the DOM tree in the browser - Wt adds some extra structure for advanced features to work). As per HTML spec, the 'lang' attribute should indeed set the language of a sub-part of a page - in this case almost everything that will include text. getRoot().setAttributeValue("lang", "de") should therefore work.

Looking at http://www.w3.org/International/questions/qa-html-language-declarations it seems to be common to set the lang of the html tag to the proper value. So probably it's best if we make this configurable.

Please share your results, so that we can take the proper action.

BR,

Wim.

RE: How can i change the HTML-language of the generated web-site? - Added by matthias pfuhl over 11 years ago

Hey Wim,

getRoot().setAttributeValue("lang", "de") doesn't work... the language is still "en".

Tomorrow i'll try to change the WebRenderer.java.

If you are make it configurable, it would be a solution, but so far we have to avoid this kinda.

Recently we got a new problem with the Internet Explorer.

Sometimes when I call my application I got a "Refusing to respond." in the browser.

Do you got any idea what this is, or what that triggers?

So far thank you a lot,

Matthias

RE: How can i change the HTML-language of the generated web-site? - Added by Wim Dumon over 11 years ago

Hello Matthias,

There will be more explanation on this error in the log file. Basically, the session is in an illegal state and JWt doesn't provide details in the browser because this may indicate a hack attempt.

Can you provide us with the information from the log file, and an exact description of what you did to come to this error? (including changes to wt_config.xml, eventually special configuration of the browser (no JS/...), ...)

Best regards,

Wim.

RE: How can i change the HTML-language of the generated web-site? - Added by matthias pfuhl over 11 years ago

Hey Wim,

what log-files do you mean? The console of Ecplise showed only this, when I use the IE:

14:55:28,117 INFO [WtServlet] Session created: 35B156C192A41CAE7AE6153C9371323E (#sessions = 4)

14:55:28,118 INFO [WEnvironment] UserAgent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)

When I use Firefox, it prints:

14:55:03,530 INFO [WtServlet] Session created: 517A99CA702B04F96CE2BEEB77A5D74E (#sessions = 3)

14:55:03,530 INFO [WEnvironment] UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0

...and Chrome:

14:56:55,176 INFO [WtServlet] Session created: E2861F18CB8A7BEBCB9CEEF50B281C11 (#sessions = 4)

14:56:55,177 INFO [WEnvironment] UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11

so.. so far I can't see a real difference, but on Chrome, and Firefox it works. Only IE prints the message in the browser. There is also no ERR or something in the Eclipse-console.

Thank you,

Matthias

RE: How can i change the HTML-language of the generated web-site? - Added by Wim Dumon over 11 years ago

Yes those are the log files I refer to. Is this the only thing you see when you get the error in IE? Can you give some more lines of logging?

BR,

Wim.

RE: How can i change the HTML-language of the generated web-site? - Added by Sascha Broich about 11 years ago

Hello,

I'm a coworker of Matthias and I have gathered some more information regarding the "Refusing to respond" message in Internet Explorer.

First the log for Chrome:

11:43:45,517 INFO  [WtServlet] Session created: 18E6869166D8FEB8CC9FA84D3A0FCEBE (#sessions = 2)
11:43:45,517 DEBUG [WtServlet] Handling: (18E6869166D8FEB8CC9FA84D3A0FCEBE): /idtsc-ui/bf/ GET /idtsc-ui/bf / null
11:43:45,517 INFO  [WEnvironment] UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
11:43:45,518 DEBUG [WebSession] Setting to expire in 10s
11:43:45,532 DEBUG [WtServlet] Handling: (18E6869166D8FEB8CC9FA84D3A0FCEBE): /idtsc-ui/bf GET /idtsc-ui/bf  wtd=18E6869166D8FEB8CC9FA84D3A0FCEBE&request=style
11:43:45,767 DEBUG [WtServlet] Handling: (18E6869166D8FEB8CC9FA84D3A0FCEBE): /idtsc-ui/bf GET /idtsc-ui/bf  wtd=18E6869166D8FEB8CC9FA84D3A0FCEBE&sid=-971780162&htmlHistory=true&deployPath=%2Fidtsc-ui%2Fbf&request=script&rand=1166750622
11:43:45,767 DEBUG [WebSession] Setting to expire in 10800s

And then for the IE

11:45:16,249 INFO  [WtServlet] Session created: F5DA93CA746214AEE1F77CFC92B26B7D (#sessions = 3)
11:45:16,249 DEBUG [WtServlet] Handling: (F5DA93CA746214AEE1F77CFC92B26B7D): /idtsc-ui/bf/ GET /idtsc-ui/bf / null
11:45:16,249 INFO  [WEnvironment] UserAgent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
11:45:16,250 DEBUG [WebSession] Setting to expire in 10s
11:45:16,263 DEBUG [WtServlet] Handling: (F5DA93CA746214AEE1F77CFC92B26B7D): /idtsc-ui/bf GET /idtsc-ui/bf  wtd=F5DA93CA746214AEE1F77CFC92B26B7D&request=style
11:45:16,265 DEBUG [WtServlet] Handling: (F5DA93CA746214AEE1F77CFC92B26B7D): /idtsc-ui/bf GET /idtsc-ui/bf  wtd=F5DA93CA746214AEE1F77CFC92B26B7D&request=resource&resource=blank
11:45:16,273 DEBUG [WtServlet] Handling: (F5DA93CA746214AEE1F77CFC92B26B7D): /idtsc-ui/bf GET /idtsc-ui/bf  null

RE: How can i change the HTML-language of the generated web-site? - Added by Sascha Broich about 11 years ago

Hi,

it's me again.

I found the cause of the IE trouble. It's the "Lookahead Downloader" of the IE since version 8. It parses for urls while loading the main page to early download them.

This confuses the WtServlet and so it stops with the known message.

To disable the behaviour of the IE you have to insert a meta http-equiv header with Content-Type. At least this is the solution I found on the web.

So in our WApplication constructor we have now the following code:

if(env.getAgent().name().startsWith("IE"))
{
    addMetaHeader(MetaHeaderType.MetaHttpHeader,"Content-Type","text/html; charset=utf-8");
}

It would be better if the WtServlet could handle the default behaviour of the IE (preloading the history-iframe) but at least it's an easy workaround.

Regards,

Sascha

RE: How can i change the HTML-language of the generated web-site? - Added by Wim Dumon about 11 years ago

Hello Sascha,

So what you're saying is that the loading of the history frame causes the 'Refusing to respond' error? That's really weird. As soon as the first page is generated, the history frame can be loaded...

I'd like to reproduce this to investigate it further. Do you see this all the time, with all versions of IE>8? Do you have any non-default configuration set (JS disabled, progressive bootstrap, ...)?

Sorry my reply took so long, I was traveling.

Best regards,

Wim.

RE: How can i change the HTML-language of the generated web-site? - Added by Sascha Broich about 11 years ago

Yeah, it is weird. Not every IE we used, regardless which version, did show this behaviour. But if one IE showed it, then it was reproducible.

It seems to be a timing problem. Probably when the Lookahead Downloader finds the history frame url and loads it before the main page loading is finished. Because of the complicated nature (milliseconds decide) debugging seems almost impossible. Only the debug log shows it: "request=resource&resource=blank".

After doing the workaround the IE loads all in correct order et voila - it works.

RE: How can i change the HTML-language of the generated web-site? - Added by Sascha Broich about 11 years ago

Okay, the solution is not the solution. It worked temporarily. Don't know why.

As far as I am now, the WApplication is not created for IE.

The request that should look like

/idtsc-ui/bf?wtd=4B3744AEE6FE8110FA2FDB68A4E36D65&sid=-1977951637&htmlHistory=true&deployPath=%2Fidtsc-ui%2Fbf&request=script&rand=-511393505

is actually this:

/idtsc-ui/bf/

There is no querystring. So the IE seems to fail to append them.

Now I'm digging into the bootstrap + javascript for IE.

Regards,

Sascha

RE: How can i change the HTML-language of the generated web-site? - Added by Wim Dumon about 11 years ago

Sascha,

That's not normal at all. Is this with one specific version of IE that you have these problems? If we can reproduce it here, we'll fix it for you, but we have never seen this.

That URL is computed in Boot.js. If you can easily reproduce this, copy the non-minified Boot.js over the minified one, then add 'debugger' somewhere in the script, and then step through the script with the IE developer tools in order to find out where it goes wrong. Or find a way for us to reproduce this...

BR,

Wim.

RE: How can i change the HTML-language of the generated web-site? - Added by Sascha Broich about 11 years ago

As far as I can see, the difference in processing Boot.js is this.

IE9 goes into the "if (!htmlHistory && canonicalUrl.length > 1) " part and calls "../bf#/" which leads to the refuse.

Chrome goes into the else part and calls the loadScript function.

if (needSessionInUrl) {
...
} else if (ajax) {
  var canonicalUrl = '../bf#/',
      hashInfo = '';
  if (!htmlHistory && canonicalUrl.length > 1) {
;
    /* Otherwise we do not get a page reload */
    if (canonicalUrl.charAt(0) == '#')
      canonicalUrl = '../' + canonicalUrl;
    setUrl(canonicalUrl);
  } else {
    if (hash.length > 1 && hash.charAt(0) == '/') {
      hashInfo = '&_=' + encodeURIComponent(hash);
;
    }

    var allInfo = hashInfo + scaleInfo + htmlHistoryInfo + deployPathInfo;
;
    loadScript(selfUrl + allInfo + '&request=script&rand=' + rand(),
               null);
;
;
  }
}

The WebSession is in state "Loaded" but the requestE is null for IE instead of "script" as it is for Chrome.

And so it delivers the "Refuse to respond".

IE not loading Mainpage - Added by Sascha Broich about 11 years ago

The now working solution - with Boot.js - is:

I replaced

setUrl(canonicalUrl);

with

var allInfo = hashInfo + scaleInfo + htmlHistoryInfo + deployPathInfo;
loadScript(selfUrl + allInfo + '&request=script&rand=' + rand(), null);

from the else part.

I'm not sure if this breaks something else, but so far it works with IE8 and IE9.

RE: How can i change the HTML-language of the generated web-site? - Added by Wim Dumon about 11 years ago

Hello Sascha,

Did you turn off cookie support in servlet container? This must be turned off or there will be other things failing too (like multiple tabs in one browser). See e.g. the hello example in Wt, it depends on the servlet container how to turn off the cookies.

BR,

Wim.

RE: How can i change the HTML-language of the generated web-site? - Added by Sascha Broich about 11 years ago

Hello Wim,

no, we don't have cookie support turned off.

Because the JWT is only one servlet among others we don't want to do this.

And it hasn't affected our website so far.

Regards,

Sascha

RE: How can i change the HTML-language of the generated web-site? - Added by Wim Dumon about 11 years ago

Hello Sacha,

You should be able to disable cookies on a per war file basis. Don't expect JWt to work correctly if you did not turn off the cookies.

BR,

Wim.

RE: How can i change the HTML-language of the generated web-site? - Added by Sascha Broich about 11 years ago

Hello Wim,

in our WAR is not only the JWT based stuff but also other.

And we see no problem with JWT and cookies as far as we use it. Multiple Tabs are not used, neither in browser nor in application.

The only heavy problem we had was the one with the IE. And this is working now too after my code adaption.

Regards,

Sascha

    (1-21/21)