|
From: Matt R. <li...@ra...> - 2004-03-12 13:56:17
|
> On 03-11-2004 23:21 -0500 Daniel Miller <mi...@pa...> wrote:
> > Your first request: make it work with XHTML 1.0 Strict
>
> I'll second that motion. I find it very unpleasant to realize
> that a taglib
> generates non-validating output into my carefully validated pages.
Actually, I've tested this with the current Commons Validator and the
JavaScript doesn't care if you have name="x" on your form or id="x". So
it's really just a question of whether other taglibs generate valid
<form> markup. Struts doesn't generate XHTML 1.0 Strict markup b/c of
the name vs. id attribute. Personally, I aimed for strict compliance
for about a year and found it was more trouble than it was worth.
Transitional works just as good and you still get well-formed XML. Any
reason you prefer Strict over Transitional?
>
> > Second: Only included the necessary JavaScript
>
> Is it not possible to keep the majority of the Javascript in
> a separate .js
> file? This way it only gets loaded once?
The validator in Struts has this capability. At the bottom of a form
you want to validate you just put:
<html:javascript formName="userForm" cdata="false"
dynamicJavascript="true" staticJavascript="false"/>
<script type="text/javascript"
src="<c:url value="/scripts/validator.jsp"/>"></script>
Where /scripts/validator.jsp has:
<%@ page language="java" contentType="javascript/x-javascript" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
prefix="html" %>
<html:javascript dynamicJavascript="false" staticJavascript="true"/>
This pulls from validator-rules.xml and produces the following:
http://demo.raibledesigns.com/appfuse/scripts/validator.jsp
You'll have to likely save it to disk to see the contents.
Matt
|