hourglass issue on firefox when switching tabs - ajax

I have a very strange problem in my web application.
I am using icefaces with jsf and on some of my pages (please do not ask for the code because it's a lot of it:) I see the hourglass effect appearing on firefox.
I can clearly confirm that is because, somehow, the jsf cycle is not entirely finished. (all the components are visible but validation is not working).
Please note that this issue does not appear if I press F5 but only when I switch some tabs, which basically change the content of the main form)...
Are you guys having any suggestion? Google did not help me...nor Firebug...
UPDATE:
- after further investigation with Firebug it seems that when I do an ajax POST, it does not load the scripts and css which are inside the <body> </body> (you will see in the answer why it puts some css and scripts here) tag...but only the ones from <head>...</head>

Issue solved!!! (please see my update before continuing reading this answer)
I had this code in my main template:
<head>
<ui:include
src="/WEB-INF/jsf/common/templates/main/commonResources-include.xhtml" />
</head>
Now please note that commonResources-include.xhtml has this code (please note html tags!)
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
..code..
</html>
It seems that whenever you use these facelets components to be included, templating etc you MUST use <ui:composition> tags and not <html>, because html tags will confuse the rendering engine of the browser! What is strange is that a lot of examples from the internet use html tags for these facelets which do not give issues in helloWorld examples but can be a pain in complex applications!
So, the final code:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
..code..
</ui:composition>

Related

Issue with Thymeleaf th:href, the link seems not to be created and thus not clickable

I have a simple html page, "index.html". I'm testing server.servlet.context-path=/test and i'm testing on the webpage the redirection on itself, nothing more. For some reason that I can't understand, even with the docs about thymeleaf https://www.thymeleaf.org/doc/articles/standardurlsyntax.html
<a th:href="#{/index.html}">Reload page</a>
It's just displaying "Reload page" and I can't even click on it. My goal is to be able to click on it and to be redirected to /test/index.html, as I thought this would be the accurate method.
Feel free to give me any advice on how to do so, or why isn't it working the way it's supposed to be.
Thanks you very much for your time !
EDIT : Here are the dependencies thymeleaf-related I'm using :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head>
<title>Test page</title>
</head>
<body>
<a th:href=#{/index.html}>Reload page</a>
</body>
</html>
This is the exact page I'm using. If I remove the xmlns in the html tag, the th:ref is marked as "Undefined attribute name (th:href)." Which made me think that when I have the xmlns (as it is right now) the attribute is correctly defined.

"Stray doctype" error in firefox source code viewer

Since I learned to serve XHTML pages as XML, I have started noticing something odd: whenever I view an XHTML page in the Firefox source code viewer, the DOCTYPE is always marked as an error. According to the tooltip I get from mousing over it, the error in question is a "stray doctype". From what I understand, a "stray doctype" means that there is an extra DOCTYPE in the middle of the document where it doesn&apos;t belong, which is certainly not the case here.
Here&apos;s an example - this markup will pass validation, and display correctly in all modern browsers:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--FF source viewer will mark the preceding two lines as an error.-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type"
content="application/xhtml+xml; charset=utf-8" />
<title>Sample XHTML Page</title>
</head>
<body>
<p>This is an example.</p>
</body>
</html>
This error message is especially odd, considering that these pages pass validation perfectly, and that a single parsing error would normally break the page.
I am the developer of this feature. You have found a bug. (Filed just now.) Thanks.
View Source syntax highlighting is based on the HTML parser, because our XML parser is not suited for the purpose and XML is rare enough that it doesn't make sense to put resources into implementing proper XML View Source. Hence, the XML View Source feature is a hack on the HTML parser and this aspect doesn't work quite right.
The error appears because the file is saved as UTF-8 BOM instead of UTF-8. Open the file in Notepad and change its encoding.
In addition to #Public Sphere's answer.
This warning can also occur when using <!DOCTYPE html>.
Probably the same warning is then also shown for the <html>, <head> and <body> tags (stray start tag "html").
To check if UTF-8 BOM is the problem:
Click the 'network' tab
Click the first request
On right details panel, click 'Response' tab and expand 'Response Payload'
You'll see the raw response now.
A red dot is in front of the doctype line,
and on hover it displays "\ufeff"
To easily find the files that could cause the problem, you can, in Linux, use this grep to find all files with BOM:
grep -rl $'\xEF\xBB\xBF' .

Firefox Addon HTML Validator showing Canvas not recognized

I'm using the HTML Validator Addon in Firefox 4 (great tool I might add).
However, I'm not sure the validation is working the way it should. I'm getting an error saying 'Canvas is not recognized'.
My doctype and html tags are set as follows:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
I believe this is supposed to be the HTML5 way for setting doctypes.
Is there something I'm missing?!
Try removing xmlns="http://www.w3.org/1999/xhtml" from the <html> element.

in coldfusion, variables in what scope can be passed to and iframe page?

i wrote 2 pages to test this problem, but the server complaints error. i don't know why, anyone can explaint it? great thanks.
this is 1.cfm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Page Title</title>
</head>
<body>
<cfscript>
a="aaaaaaaaaaa";
b="bbbbbbbbbbb";
request.r1="rrrrrrr111111111";
request.r2="rrrrrrrr222222222";
session.s1="sssssssssss11111111111";
session.s2="sssssssssss2222222222";
</cfscript>
<iframe src="2.cfm" width="600" height="400" name="myframe" scrolling="yes">
</iframe><br />
variables
<cfdump var="#variables#">
request
<cfdump var="#request#">
session
<cfdump var="#session#">
</body>
</html>
and this is 2.cfm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>2.cfm</title>
</head>
<body>
variables
<cfdump var="#variables#">
request
<cfdump var="#request#">
session
<cfdump var="#session#">
</body>
</html>
It seems like you're misunderstanding a basic concept of web-page requests.
An iframe, while displayed as a portion of the rendering page, is in fact its own request, entirely separate from the original page request.
Session variables would be shared between the two of them (assuming you have sessions enabled in Application.cfm/Application.cfc), and although it's unlikely that you'll get into a race condition by setting variables from a parent page (1.cfm) and reading them from a child page in an iframe (2.cfm), it's just not a great idea (best practice).
Request variables set in the parent page (1.cfm) will not be available to the page in the iframe (2.cfm), as it is a separate request.
Like the Request scope is private to each request (but shared to all templates and objects), the "variables" scope is private to each template (but shared among them when using cfinclude).
While your iframe will have access to its own request and variables scopes, they will not be the same scope as the original page (1.cfm).
This is a fairly basic concept of programming in general, and also of ColdFusion. If you're finding it difficult to grasp, you might consider picking up a copy of the ColdFusion Web Application Construction Kit, which can take you from complete novice to beginner-intermediate level fairly quickly.
Do you have an Application.cfm in the directory you're running these tests in?
If you add the following line into a file called Application.cfm and the root of the directory it should work.
<cfapplication name="test_app" sessionmanagement="true">
I tested your two files and without the Application.cfm it broke, with it present it works fine.
I think Ian's on the right track here with his observation that to use session variables, one needs to have sessionmanagement enabled, however I think suggesting using Application.cfm for this is a bit anachronistic.
If one is using a version of CF from CFMX7 onwards, the recommended way to manage the application framework is via Application.cfc, and the equivalent to Ian's code would be:
<cfcomponent>
<cfset this.name = "test_app">
<cfset this.sessionManagement = true>
</cfcomponent>

Strict doctype preventing access to DOM variable in FireFox

I don't know if this is a well known 'thing' or something new in whatever version of Firefox it just updated itself too - but in either case I have no idea how to google for this question so I'll have to ask it here.
I have a DIV in my DOM that I am trying to directly access by id, in the most simplest form like this:
alert(btnTest.id);
This works fine in all browsers, but was causing issues in firefox that actually led to the browser being in a strange 'broken' state.
The error I was getting was 'btnTest is not defined'. I did not get this error in Safari, Internet Explorer or Chrome.
I assumed I had mismatched HTML tags, or javascript curly braces or something else missing. Eventually after stripping everything out I tried removing the DOCTYPE. Suddenly in Firefox (v 3.0.10) it started returning the correct ID as expected.
What is going on!!! ?? Surely 'strict' mode should allow me to access named elements, and if not then why do all the other browsers let me.
Note: I can easily work around it with $('#btnTest')[0].id, which is what I'm going to have to do now until i can figure out a better solution.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="blueCircles">
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
$(function() {
alert("ID retrieved through jQuery: " + $('#btnTest')[0].id);
alert("ID retrieved by accessing global variable: " + btnTest.id);
});
</script>
</head>
<body>
<div id="btnTest">
</div>
</body>
</html>
There is nothing in any W3C specification that says object references should be established in the global scripting scope for elements with id attributes. This is considered to uneccessarily pollute the global namespace and can result in confusing errors.
Firefox establishes the references when running in quirks mode for the purposes of IE compatibility. Johnny Stenback explains in the third comment on the bug for adding this support why this isn't supported in standards mode:
This feature does affect standard
compliant code that for instance
checks for the existance [sic] of a global
variable to set it only once. With
this change, that "varible" [sic] may now be
a reference to an element in the
document, and the code may not work
the way the developer intended.
That's the reason we decided to make
this quirks only.

Resources