struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig McClanahan (JIRA)" <j...@apache.org>
Subject [jira] Moved: (SHALE-65) [Shale] client side commons validation not working inside a dataList
Date Wed, 26 Apr 2006 06:14:51 GMT
     [ http://issues.apache.org/struts/browse/SHALE-65?page=all ]

Craig McClanahan moved STR-2817 to SHALE-65:
--------------------------------------------

      Project: Shale  (was: Struts Action 1)
          Key: SHALE-65  (was: STR-2817)
    Component:     (was: Shale)
      Version:     (was: Nightly Build)
    Assign To:     (was: Struts Developer Mailing List)

> [Shale] client side commons validation not working inside a dataList
> --------------------------------------------------------------------
>
>          Key: SHALE-65
>          URL: http://issues.apache.org/struts/browse/SHALE-65
>      Project: Shale
>         Type: Bug

>  Environment: Operating System: All
> Platform: All
>     Reporter: Paul Devine
>  Attachments: shale_debug.war
>
> Overview:
> I was using Shale nightly build 20060328. See
> http://www.mail-archive.com/user%40struts.apache.org/msg44124.html for pertinent
> mailing list discussion. For inputs inside a dataList a row index is included in
> the clientId to guarantee uniqueness on the html input id's. For example
> "myForm:myDataList_0:someRequiredField" for the first row,
> "myForm:myDataList_1:someRequiredField" for the second, and so on. But in
> the rendering of the javascript by the struts validatorScript tag, the
> clientId of the input components lose their row index.
> To reproduce:
> Deploy the jsp file whose source is included at the end of this description into
> a minimal myfaces web-app. Drop into WEB-INF/lib the shale-core dependency files
> and a myfaces-1.1.1 "all" jar. 
> Start the web-app and open http://localhost:8080/shale_debug/index.jsf.  Do a
> view source on the html and you will see two <input> fields with their id's
> "someForm:someDataList_0:someRequiredField" and
> "someForm:someDataList_0:someRequiredField". But in the validation javascript
> function required() you'll see only one input
> "someForm:someDataList:someRequiredField".   If you submit the form without
> filling out the required fields you will notice that a javascript error occurs
> causing client side validation to be skipped. The server-side validation works ok.
> The full list of jars you need in WEB-INF/lib is :
> commons-beanutils.jar, commons-chain.jar,commons-codec-1.3.jar,
> commons-digester.jar, commons-fileupload.jar, commons-logging.jar,
> commons-validator.jar, shale-core.jar, myfaces-all-1.1.1.jar
>  
> ==================================
> The source for the index.jsp is as follows:
> ==================================
> <%@ page language="java"
> import="java.util.*,org.apache.shale.dialog.impl.DialogImpl"%>
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
> <%@ taglib uri="http://myfaces.apache.org/extensions" prefix="t"%>
> <%@ taglib uri="http://struts.apache.org/shale/core" prefix="s" %>
> <%
> /* Put a couple of Shale DialogImpl objects into the session (we just need an
> object with a getter and a setter
>  * and this class is readily accessible)
>  */
> List inputObjects = new ArrayList();
> inputObjects.add(new DialogImpl());
> inputObjects.add(new DialogImpl());
> session.setAttribute("someInputObjects",inputObjects);
> %>
> <f:view>
> <%--
> A form with a dataList of inputs. The client side id's of the components will be
> someForm:someDataList_0:someRequiredField and
> someForm:someDataList_1:someRequiredField
> --%>
> <h:form id="someForm" onsubmit="return validateForm(this);">
>   <t:dataList id="someDataList" value="#{someInputObjects}" var="object"
> rowIndexVar="index">
>     <h:outputLabel value="Name"/>
>     <h:inputText id="someRequiredField" value="#{object.name}" size="20"
> required="true">
>       <s:commonsValidator type="required" arg="Name" server="true" client="true"/>
>     </h:inputText><h:message for="someRequiredField" errorClass="errorMessage"/>
>   </t:dataList>
> <%--
> The dataList is now closed. Before we close out the form, write out the
> validator javascript. But
> this results in a mismatch on the client side id's in the required function.
> Note the uniqueness
> indexes _0 and _1 are missing. Because we are outside the 
> dataList there is no "row index" anymore (and for some reason the HtmlInputText
> components `calculate`
> their clientId's again when asked for getClientId from Shale's ValidatorScript
> findCommonsValidators method
> Here's what the validatorScript comes up with:-
> function required() { 
>   this[0] = new Array("someForm:someDataList:someRequiredField", "Name is
> required.", new Function("x", "return {}[x];"));
> }
> --%>
>   <s:validatorScript functionName="validateForm"/>
>   <h:commandButton action="submit"/>
> </h:form>
> </f:view>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message