participate


JavaServer Faces - jsf and xhtml
<<   Back to Forum  |   Give us Feedback
10 Duke Stars available
This topic has 8 replies on 1 page.
graham_s
Posts:7
Registered: 1/6/98
jsf and xhtml   
Dec 14, 2004 6:46 AM

 
Hi,
just a quick question: is there any way to make jsf render as valid xhtml (or, failing that, as valid html)? A quick google turned up nothing. Or is there a 3rd party renderer that does this?

thanks,

Graham
 
edburns
Posts:45
Registered: 3/4/98
Re: jsf and xhtml   
Dec 14, 2004 9:00 AM (reply 1 of 8)  (In reply to original post )

 
I've posted your answer on my blog at http://blog.sun.com/roller/page/edburns/20041214#the_basics_of_rendering_xhtml

Ed (JSR-252 spec-co-load)
 
graham_s
Posts:7
Registered: 1/6/98
Re: jsf and xhtml   
Dec 15, 2004 2:17 AM (reply 2 of 8)  (In reply to #1 )

 
I've posted your answer on my blog at
http://blog.sun.com/roller/page/edburns/20041214#the_b
asics_of_rendering_xhtml

Ed (JSR-252 spec-co-load)

Ed,
thanks for this. I'm flattered to be in your blog!

I'm new to jsf; just having a look with a view to using this on a forthcoming project. It looks excellent. I've been using the current 1.1_01 version.

I've been going through the supplied examples. Generally, I quite like dropping the pages I've produced into the w3c validator at: http://validator.w3.org/, which is where this came up. If I take a page with otherwise validates as xhtml transitional and add:

<h:inputText id="y" value="#{Bean001.y}" validator="#{Bean001.validate}" />

I get out:

<input id="helloForm:y" type="text" name="helloForm:y" value="">

This tag is not closed, and so the validator rejects the page.

I had a quick look at the jsf code drop on the java.net site and (although I haven't compiled it) that code does seem to close all the tags (method endElement in HtmlResponseWriter).

The only other, very minor, thing I've found the validator objecting to was not having 'type="XX"' attributes in <script> tags .

But, as I say, the whole thing looks excellent, and I apologise in advance if I've misunderstood something, as quite likely I have.

Graham
 
BosmonJDC
Posts:1
Registered: 2/9/05
Re: jsf and xhtml   
Feb 9, 2005 6:18 AM (reply 3 of 8)  (In reply to #1 )

 
Ed. Thanks for this reply - however I'm not convinced of the approach of listing "some XHTML practices" that the default renderkit adheres to, as opposed to actually declaring that it adheres to the standard. In particular, JSF makes no attempt to escape & (ampersand) characters that occur in attributes, in particular in URLs - I note MyFaces does not do this either. This could be achieved by alteration of the ResponseWriterImpl. I am aware that "proper" XML escaping could well cause the resulting URLs to become unrecognisable in non-XHTML-aware browsers, but I am disappointed there seems to be little discussion of this important issue.
As it stands, the output of the default renderkit cannot be parsed by standard XML parsers.
 
slonopotamus
Posts:1
Registered: 17.08.05
Re: jsf and xhtml   
Aug 16, 2005 3:33 PM (reply 4 of 8)  (In reply to #1 )

 
JSF output really doesn't seem to be valid XHTML :(

JSPX:
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:jsp="http://java.sun.com/JSP/Page"
    version="2.0">
  <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"
                      session="false" />
  <jsp:output doctype-public="-//W3C//DTD XHTML 1.1//EN"
              doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
              doctype-root-element="html" omit-xml-declaration="false" />
  <f:view>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>title</title></head>
    <body>
    <h:form><p>text</p></h:form>
    </body></html>
  </f:view>
</jsp:root>


Result:
<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>title</title></head><body><form id="_id0" method="post" action="/index.faces;jsessionid=472A9F3A62261173DFFEB6046A0ECBD1" enctype="application/x-www-form-urlencoded"> 
<p>text</p><input type="hidden" name="_id0" value="_id0" /></form></body></html> 


Everything is perfect except for hidden input field. It isn't allowed to be right in <form> tag.
 
Gamigin
Posts:71
Registered: 11/2/05
Re: jsf and xhtml   
Jan 3, 2006 1:30 PM (reply 5 of 8)  (In reply to #4 )

 
Everything is perfect except for hidden input field.
It isn't allowed to be right in <form> tag.

I've noticed the exact same thing. According to the official W3C validator, <input> elements (including hidden ones) can't go directly inside a <form> element without being embedded within a formatting element such as <p>, <h3>, <td>.

This will cause JSF pages to always fail (slightly) validation. This is with Sun JSF 1.1_01.

I am confident that this isn't an error on my part. Ed Burn's says on his blog that JSF generates 100% valid XHTML. I'm guessing this discrepency is either:
- Misunderstanding on Sun's part of XHTML spec.
- Recent change to XHTML.
- This is fixed in newer versions of JSF (1.2) that Sun is working on but developers like myself are not.
 
csimsek
Posts:1
Registered: 12/26/06
Re: jsf and xhtml   
Dec 26, 2006 8:01 AM (reply 6 of 8)  (In reply to #5 )

 
I'm getting same problem too.

I want to use XHTML 1.1 for my web site. When I use <f:form> tag for putting a form to my page, it's rendering like <form id=".." name="..." .... But the form tag's name element is illegal for XHTML 1.1. So, my page dose not validating for W3C's validator.

Also, JSF's hidden input areas are locating to just under the <form> tag. But XHTML 1.1 standards say that: "input elements must be in a <div> (or etc.) element".

Regards.
 
hammoud
Posts:83
Registered: 6/21/01
Re: jsf and xhtml   
Dec 26, 2006 10:08 PM (reply 7 of 8)  (In reply to #6 )

 
I posted the problem with name attribute and hidden fields in this issue:
https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=465

Currently RI supports only XHTML transitional.
You can vote for Issue 404 to push XHTML strict
 
John.Markh
Posts:1
Registered: 4/20/06
Re: jsf and xhtml   
May 31, 2009 5:07 AM (reply 8 of 8)  (In reply to #4 )

 
You are a super star!
and, it is possible to put hidden fields into a
<div></div>
block by using:
<h:panelGroup layout="block" styleClass="none"></h:panelGroup>


John.
 
This topic has 8 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 64
  • Guests : 124

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums