Hi I have applied the conditional validation as following in my Actionvalidation.xml.this works fine while showing error but if I change the value from - Select One - to some question the validation error remains there only
<field-validator type="fieldexpression"> <param name="expression"><![CDATA[#secQuestion eq '- Select One -]]></param> <message>Please select Question</message> </field-validator> Can anybody tell me where is my mistake Regards Anshu -----Original Message----- From: Leo Barrientos C. [mailto:[EMAIL PROTECTED] Sent: Friday, June 06, 2008 12:59 PM To: users@appfuse.dev.java.net Subject: Re: [appfuse-user] conditional validation Better, an example for spring! Look this: Configuration: <bean id="modeloValidator" class="com.opensistemas.ksjfhksjfhksjdhf.webapp.validators.ModeloValidator"> <property name="modeloManager" ref="modeloManager"/> </bean> <bean id="modeloFormController" class="com.opensistemas.ksjfhksjfhksjdhf.webapp.controller.ModeloFormControl ler"> <property name="validator" ref="modeloValidator"/> <property name="successView" value="redirect:gestion_de_modelos.html?action=listarModelos"/> <property name="formView" value="modeloform"/> <property name="marcaManager" ref="marcaManager"/> <property name="modeloManager" ref="modeloManager"/> <property name="tipoEquipoManager" ref="tipoEquipoManager"/> <property name="empresaManager" ref="empresaManager"/> <property name="atributoTipoEquipoManager" ref="atributoTipoEquipoManager"/> </bean> In the configuration of the form see the validator property. In the form (jsp - see formView property): .... <form:select path="tipoEquipo.id" id="tipoEquipo.id" onchange="javascript:cambioTipoEquipo();" > <%@ include file="/common/blankOption.jsp"%> <c:forEach var='vtipoEquipo' items='${tiposEquipo}'> <option value="<c:out value="${vtipoEquipo.id}"/>" <c:if test="${modelo.tipoEquipo.id == vtipoEquipo.id}">selected</c:if> > <c:out value="${vtipoEquipo.nombre}"/> </option> </c:forEach> </form:select> .... Look in the jsp - the related object has a path. And finally in the Validator : public class ModeloValidator implements Validator { private ModeloManager manager; public void setModeloManager(ModeloManager manager){ this.manager = manager; } public boolean supports(Class clazz) { return Modelo.class.isAssignableFrom(clazz); } public void validate(Object target, Errors errors) { Modelo modelo = (Modelo) target; ValidationUtils.rejectIfEmpty(errors, "nombre", "required.nombre", "Name required"); // encontrarTodos= findAll List<Modelo> modeloPersistentes = manager.encontrarTodos(modelo.getNombre()); try { if (modeloPersistentes.size() > 0) throw new Exception(); } catch (Exception e){ //carga error errors.reject("nombre.error", "Ya existe un modelo con este nombre, seleccione otro."); } //El id del objeto modelo.tipoEquipo try { //Default value is selected? if (modelo.getTipoEquipo().getId().equals(new Long(0))) throw new Exception(); } catch (Exception e){ //carga error errors.reject("tipoEquipo.error", "Debe seleccionar un tipo de equipo"); } } } Anshu Dhamija schrieb: > Can you please provide a link for full explanation > > Regards > Anshu > -----Original Message----- > From: Leo Barrientos C. [mailto:[EMAIL PROTECTED] > Sent: Friday, June 06, 2008 12:42 PM > To: users@appfuse.dev.java.net > Subject: Re: [appfuse-user] conditional validation > > > Use a custom beanValidator. > > If category is a object related to your "target" entity use > path=category.id to binding in the form. > > > > > nshu Dhamija schrieb: > >> Hi >> >> I have a drop down in which there are values along with select >> category. >> >> select category will be selected by default now I want to apply >> validation that user need to select a value other than select >> category otherwise it should show validation error. Can anyone help me >> >> //Regards// >> >> Anshu >> >> > > > -- Leo Barrientos C. Director de Operaciones Madrid. Open Sistemas de Información Internet Fono: +34 902 10 73 96 Correo: [EMAIL PROTECTED] Web: http://www.opensistemas.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]