I have a web page(.jsp) created using struts tag libraries. when I try to validate the web page in w3c.org, all the struts tags are coming up as undefined. E.g <html:button> is undefined . The DOCTYPE I have used is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Please let me know how to resolve the issue. Or can't we make a struts based web page as W3C compliant.
...
Why are you trying to validate a page before rendering?
Are Struts tags (or any other custom tag) valid HTML tags? Of course not.
Validation should occur after the page is rendered.
Related
Problem:
My project is using Struts Framework, specifically the html:button tag explained here on Struts Apache Documentation
The issue is the html:button tag turns into
<input>
, failing w3c compliance tests. The tag needs to turn into
<input/>
Reason:
I use an html tag specifying xhtml, which is in a template file used in all my other files. All the other files are not converted to xhtml though since the tag is in the template file. Is there a way to make all the other files xhtml, without using an html tag?
The solution to this problem is to add
<html:xhtml/>
after all the taglib tags on each jsp page
Example of taglib tag:
<%# taglib uri="/taglib/htmlstrut" prefix="html"%>
I ran my website through Validator and it returned two errors, both of which relating to the official Twitter follow button code.
The code for the larger button is:
Follow #gary
<script type="text/javascript">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
Validator returned these errors when checking my site as XHTML 1.0 Transitional:
there is no attribute "data-show-count"
and
there is no attribute "data-size"
So what is the deal here? Obviously these two attributes exists. Removing the data-size will return the smaller version of the button.
It should work with HTML5 Doctype.
I'm trying to cleanup my xhtml validation -- I'm running my pages through the W3C validator. For some puzzling reason it's not passing on input fields with the autocomplete="off" attribute:
<input name="kwsearch" id="sli_search_1" type="text" autocomplete="off" onfocus="if(this.defaultValue==this.value) this.value='';"
onblur="if(this.value=='')this.value=this.defaultValue;" class="searchbox" value="Search" />
I'm using this doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
And this is the validation error:
Line 410, Column 81: there is no attribute "autocomplete"
…li_search_1" type="text" autocomplete="off" onfocus="if(this.defaultValue==thi…
I thought this was okay with the W3C -- but, maybe it's still in "submission" phase?
http://www.w3.org/Submission/web-forms2/#autocomplete
Thoughts?
The Web forms specification has nothing to do with HTML 4 / XHTML. Sadly, autocomplete will not pass validation.
I think the only way to achieve valid HTML 4 /XHTML with autocomplete turned off is adding the attribute on page load using JavaScript. Sucks, I know - but I think it's the only way.
autocomplete is a HTML5 attribute, so use a HTML5 document type declaration, if you need it.
That W3C link is for the web forms stuff, not core XHTML. It might be possible to pull in the extra DTD for the web forms and get the page to validate.
If you need autocomplete( browsers do support it ), then try extending your doctype, like in this XHTML 1.1 below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
<!ATTLIST form autocomplete (on|off) #IMPLIED>
]>
I've just banged up against this irritating conflict between browsers and standards. I ended up getting around it by running javascript ON THE PAGE, not waiting for window.onLoad or $(document).ready(), to add the attribute to all elements with the class no-browser-autocomplete. Then i went through my app removing autocomplete="off" and adding this class instead.
Obviously this will fail in browser environments not running javascript.
The reason that i do it on the page, rather than in a dom ready block, is that if you wait for dom ready, the browser's already autocompleted it, at least in Firefox (which i'm testing it in).
So, this is at the start of one of the javascript files i include in my app layout:
//this needs to run BEFORE all of the loaded/ready events fire, that's why it's not in the dom.ready function
$(".no-browser-autocomplete").attr("autocomplete", "off");
$(function(){
//dom ready
});
I need to validate a web application in html 4.01 transitional. In my project im working on skeletons/head.jsp to add meta tags. The problem is that i want to add tags like:
<meta name="robots" content="follow">
without the enclosing tag. And the document type is defined on skeleton.xml as HTML 4.01 Transitional. But when erase the slash the WorkShop Framework (Eclipse) fails if no exist ending tag.
It's the head.js where I have to put the meta tags?
“But when erase the slash the program fails.”
I’m not familiar with WebLogic, but when you say “the program fails”, do you mean your website stops working? Or the resulting HTML page doesn’t validate?
How can I modify the conditions for which MyEclipse will throw up warning flags? I'd be happy to hear a generic solution, but here is my specific problem for the curious/if it turns out to be relevant:
<html xmlns="http://www.w3.org/1999/xhtml">
<wicket:panel>
<p>
<object type="text/html" width="750" height="360" wicket:id="htmlRendition"></object>
</wicket:panel>
</html>
causes warnings "Undefined attribute name (xmlns)," "Unknown tag (wicket:panel)" and "Undefined attribute name (wicket:id)." Oddly, there are no errors for most HTML files paired with Wicket Java files, only files with the format ClassName$InnerClassName.html.
I use the following in my HTML files for Wicket:
<!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"
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
I know some IDEs (IntelliJ) for example allow you to register a dtd to validate your xml files. This article looks to apply to XML documents, but perhaps HTML files work or can be configured to work similarly:
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.wst.xmleditor.doc.user/topics/cxmlcat.html
In the project properties, you can turn off different types of validation. For example, you can say that you don't want DTD validation of XML files, or HTML validation, etc.
Myeclipse example is here.