[ http://issues.apache.org/struts/browse/STR-1878?page=all ] David Evans reopened STR-1878: ------------------------------
Assign To: David Evans (was: Struts Developer Mailing List) > multiple radio button javascript validation broken > -------------------------------------------------- > > Key: STR-1878 > URL: http://issues.apache.org/struts/browse/STR-1878 > Project: Struts Action 1 > Type: Bug > Components: Action > Versions: 1.1 Final > Environment: Operating System: Windows XP > Platform: PC > Reporter: fulvio > Assignee: David Evans > Priority: Critical > > Hello, guys > I have some problems validating multiple radio buttons and checkboxes, > selections on the client side. Tracking down to the javascript code > defined in validator-rules.xml, I found that the validateRequired(form) > function doesn't deal with multiple checkboxes, selections at all. For > multiples radios, checkboxes etc, the field.type = undefined. I try to use > a nightly build, but nothing diff happend. On the server side, the validation > is normal. > If you it will be able to answer me, would be very grateful. I am > annexing jsp, validation.xml and struts-config.xml you to analyze. > tks! > **************************deleteme.jsp****************************************** > ********** > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> > <html:html> > <HEAD> > <BODY> > <html:errors /> > <html:form action="/saida2" onsubmit="return validateDeleteme(this);" > method="get"> > <FIELDSET TITLE="r1"> > <html:checkbox property="r1" value="r1"> r1</html:checkbox> > <br> > <html:checkbox property="r1" value="r2"> r2</html:checkbox> > <br> > <html:checkbox property="r1" value="r3"> r3</html:checkbox> > <br> > <html:checkbox property="r1" value="r4"> r4</html:checkbox> > <br> > <html:checkbox property="r1" value="r5"> r5</html:checkbox> > <br> > </FIELDSET> > <html:submit /> > </html:form> > </BODY> > </html:html> > **************************deleteme.jsp****************************************** > ********** > **************************struts- > config.xml**************************************************** > <?xml version="1.0" encoding="ISO-8859-1" ?> > <!DOCTYPE struts-config PUBLIC > "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" > "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> > <!-- > > This is a blank Struts configuration file with an example > > welcome action/page and other commented sample elements. > > > > Tiles and the Struts Validator are configured using the factory defaults > > and are ready-to-use. > > > > NOTE: If you have a generator tool to create the corresponding Java > classes > > for you, you could include the details in the "form-bean" declarations. > > Otherwise, you would only define the "form-bean" element itself, with > the > > corresponding "name" and "type" attributes, as shown here. > > --> > <struts-config> > <!-- ==================================== Data Source Configuration --> > <!-- > > <data-sources> > > <data-source> > > <set-property > > property="autoCommit" > > value="false"/> > > <set-property > > property="description" > > value="Example Data Source Configuration"/> > > <set-property > > property="driverClass" > > value="org.postgresql.Driver"/> > > <set-property > > property="maxCount" > > value="4"/> > > <set-property > > property="minCount" > > value="2"/> > > <set-property > > property="password" > > value="mypassword"/> > > <set-property > > property="url" > > value="jdbc:postgresql://localhost/mydatabase"/> > > <set-property > > property="user" > > value="myusername"/> > > </data-source> > > </data-sources> > > --> > <!-- ======================================== Form Bean Definitions --> > <!-- > > O formulário contém os campos com as seguintes validações: > * Nome (requerido, pode somente ser caracter alfabético); > * Sobrenome (requerido, pode somente ser caracter alfabético); > * Data de nascimento (requerido; deve obedecer a > máscara âdd/mm/aaaaâ); > * Endereço (requerido); > * Cep (requerido; deve obedecer a máscara ânnnnnn-nnnâ); > * Cidade (requerido, pode somente ser caracter alfabético); > * Estado (requerido, pode somente ser caracter alfabético e > obedecer a máscara âwwâ); > * Cartão de Crédito (requerido; deve ser um número de > cartão > de crédito válido); > * Email (deve ser email válido); > * Altura (requerido; deve estar entre 1,00 e 2,30); > * Telefone (deve ser somente número; deve ter no mÃnimo 9 > números; ); > > --> > <form-beans> > <form-bean name="cadastro" > type="org.apache.struts.validator.DynaValidatorForm"> > <form-property name="nome" type="java.lang.String" /> > <form-property name="sobrenome" > type="java.lang.String" /> > <form-property name="nascimento" > type="java.lang.String" /> > <form-property name="endereco" > type="java.lang.String" /> > <form-property name="cep" type="java.lang.String" /> > <form-property name="cidade" type="java.lang.String" /> > <form-property name="estado" type="java.lang.String" /> > <form-property name="cartaoCredito" > type="java.lang.String" /> > <form-property name="email" type="java.lang.String" /> > <form-property name="altura" type="java.lang.String" /> > <form-property name="telefone" > type="java.lang.String" /> > </form-bean> > <form-bean name="deleteme" > type="org.apache.struts.validator.DynaValidatorForm"> > <form-property name="r1" type="java.lang.String > []"></form-property> > </form-bean> > </form-beans> > <!-- ================================= Global Exception Definitions --> > <global-exceptions> > <!-- sample exception handler > > <exception > > key="expired.password" > > type="app.ExpiredPasswordException" > > path="/changePassword.jsp"/> > > end sample --> > </global-exceptions> > <!-- =================================== Global Forward Definitions --> > <global-forwards> > <!-- Default forward to "Welcome" action --> > </global-forwards> > <!-- =================================== Action Mapping Definitions --> > <action-mappings> > <action path="/saida" > type="org.apache.struts.actions.ForwardAction" input="/entrada.jsp" > parameter="/saida.jsp" name="cadastro" scope="request"></action> > <action path="/saida2" > type="org.apache.struts.actions.ForwardAction" input="/deleteme.jsp" > parameter="/saida2.jsp" name="deleteme" scope="request"></action> > <!-- sample input and input submit actions > > > > <action > > path="/Input" > > type="org.apache.struts.actions.ForwardAction" > > parameter="/pages/Input.jsp"/> > > > > <action > > path="/InputSubmit" > > type="app.InputAction" > > name="inputForm" > > scope="request" > > validate="true" > > input="/pages/Input.jsp"/> > > > > end samples --> > </action-mappings> > <!-- ===================================== Controller Configuration --> > <controller > processorClass="org.apache.struts.tiles.TilesRequestProcessor" /> > <!-- ================================ Message Resources Definitions --> > <message-resources parameter="resources.application" /> > <!-- ======================================= Plug Ins Configuration --> > <!-- ========== Tiles plugin =================== --> > <!-- > --> > <!-- > This plugin initialize Tiles definition factory. This later can > takes some > parameters explained here after. The plugin first read > parameters from web.xml, then > overload them with parameters defined here. All parameters are > optional. > The plugin should be declared in each struts-config file. > - definitions-config: (optional) > Specify configuration file names. There can be several comma > separated file names (default: ?? ) > - moduleAware: (optional - struts1.1) > Specify if the Tiles definition factory is module aware. If > true (default), > there will be one factory for each Struts module. > If false, there will be one common factory for all module. In > this later case, > it is still needed to declare one plugin per module. The > factory will be > initialized with parameters found in the first initialized > plugin (generally the > one associated with the default module). > true : One factory per module. (default) > false : one single shared factory for all modules > - definitions-parser-validate: (optional) > Specify if xml parser should validate the Tiles configuration > file. > true : validate. DTD should be specified in file header. > (default) > false : no validation > > Paths found in Tiles definitions are relative to the main > context. > --> > <!-- comment following if struts1.0.x --> > <plug-in className="org.apache.struts.tiles.TilesPlugin"> > <set-property property="definitions-config" value="/WEB- > INF/tiles-defs.xml" /> > <set-property property="moduleAware" value="true" /> > <set-property property="definitions-parser-validate" > value="true" /> > </plug-in> > <!-- end comment if struts1.0.x --> > <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> > <set-property property="pathnames" value="/WEB-INF/validator- > rules.xml,/WEB-INF/validation.xml" /> > </plug-in> > </struts-config> > **************************struts- > config.xml**************************************************** > **************************validation.xml**************************************** > ************ > <?xml version="1.0" encoding="ISO-8859-1" ?> > <!DOCTYPE form-validation PUBLIC > "-//Apache Software Foundation//DTD Commons Validator Rules > Configuration 1.0//EN" > "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd"> > <form-validation> > <!-- > This is a blank Validator form file with a commented examples. > --> > <global> > <!-- An example global constant > <constant> > <constant-name>postalCode</constant-name> > <constant-value>^\d{5}\d*$</constant-value> > </constant> > end example--> > </global> > <formset> > <!-- Form adicionado por Fulvio Longhi.'. --> > <form name="cadastro"> > <field property="nome" depends="required,mask"> > <arg0 key="nome.label" /> > <var> > <var-name>mask</var-name> > <var-value>^[a-zA-Z]*$</var-value> > </var> > </field> > <field property="sobrenome" depends="required,mask"> > <arg0 key="sobrenome.label" /> > <var> > <var-name>mask</var-name> > <var-value>^[a-zA-Z ]*$</var-value> > </var> > </field> > <field property="nascimento" depends="required,date"> > <arg0 key="nascimento.label" /> > <var> > <var-name>datePatternStrict</var-name> > <var-value>dd/MM/yyyy</var-value> > </var> > </field> > <field property="endereco" depends="required"> > <arg0 key="endereco.label" /> > </field> > <field property="cep" depends="required,mask"> > <arg0 key="cep.label" /> > <var> > <var-name>mask</var-name> > <var-value>^\d{5}(-\d{3})?$</var-value> > </var> > </field> > <field property="cidade" depends="required,mask"> > <arg0 key="cidade.label" /> > <var> > <var-name>mask</var-name> > <var-value>^[a-zA-Z ]*$</var-value> > </var> > </field> > <field property="estado" depends="required,mask"> > <arg0 key="estado.label" /> > <var> > <var-name>mask</var-name> > <var-value>^[A-Z]{2}$</var-value> > </var> > </field> > <field property="cartaoCredito" > depends="required,creditCard"> > <arg0 key="cartaoCredito.label" /> > </field> > <field property="email" depends="required,email"> > <arg0 key="email.label" /> > </field> > <field property="altura" > depends="required,float,floatRange"> > <arg0 key="altura.label" /> > <arg1 name="floatRange" key="${var:min}" > resource="false" /> > <arg2 name="floatRange" key="${var:max}" > resource="false" /> > <var> > <var-name>min</var-name> > <var-value>1.00</var-value> > </var> > <var> > <var-name>max</var-name> > <var-value>2.30</var-value> > </var> > </field> > <field property="telefone" depends="required,mask"> > <arg0 key="telefone.label" /> > <var> > <var-name>mask</var-name> > <var-value>^\(?(\d{3})\)?[-| ]?(\d{3})[- > | ]?(\d{4})$</var-value> > </var> > </field> > </form> > <form name="deleteme"> > <field property="r1" depends="required"> > <arg0 key="todosActionForm.required.label" /> > </field> > </form> > </formset> > <!-- An example formset for another locale > <formset language="fr"> > > <constant> > <constant-name>postalCode</constant-name> > <constant-value>^[0-9a-zA-Z]*$</constant-value> > </constant> > > </formset> > --> > </form-validation> > **************************validation.xml**************************************** > ************ > Fulvio Alessander Longhi de Souza .'. > Analista Assistente de Informática > Tecnologia - BB - Brasil -- 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]