ValidateAll and decorate problems...
skidvd.seamframework.abilsoft.com Mar 14, 2009 11:24 PMHello,
I am new to s:validateAll and s:decorate, so I'm hoping someone can help me find the problems in my code..... I'm using Seam 2.1.1.GA with RichFaces 3.3.0.GA, hibernate-annotations-3.3.0.GA, hibernate-validator-3.1.0.GA and hibernate-distribution-3.3.1.GA.
I have the following template for decoration:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:rich="http://richfaces.org/rich" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:ts="http://myfaces.apache.org/sandbox" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:e="http://www.ensuren.com/facelets/ensuren"> <s:label styleClass="#{invalid?'error':''}"> <ui:insert name="label" style="float:left; text-align: right;"/> </s:label> <s:span class="#{invalid?'error':''}" style="float: right;"> <s:validateAll> <ui:insert/> </s:validateAll> <s:span styleClass="required" rendered="#{required}">*</s:span> <s:graphicImage src="/images/error.jpg" rendered="#{invalid}"/> <s:graphicImage src="/images/checkmark.gif" rendered="#{! invalid}"/> </s:span> <s:message styleClass="error"/> </ui:composition>
I reference that template in the following form...
<a4j:form id="discoveryListEditForm"> <a4j:outputPanel ajaxRendered="true"> <rich:messages style="color:red;"></rich:messages> </a4j:outputPanel> <h:panelGrid columns="1"> <a4j:outputPanel> <s:decorate id="subnetDecoration" template="/templates/editField.xhtml"> <ui:define name="label"><h:outputText value="#{msgs.subnetHeader}"/></ui:define> <h:inputText id="subnet" value="#{discoveryListController.selectedItem.subnet}" required="true"> <a4j:support event="onblur" reRender="subnetDecoration"/> </h:inputText> </s:decorate> <s:decorate id="netmaskDecoration" template="/templates/editField.xhtml"> <ui:define name="label"><h:outputText value="#{msgs.netmaskHeader}" /></ui:define> <h:inputText id="netmask" value="#{discoveryListController.selectedItem.netmask}" required="true"> <a4j:support event="onblur" reRender="netmaskDecoration"/> </h:inputText> </s:decorate> </a4j:outputPanel> <a4j:commandButton value="#{msgs.addButtonActionLabel}" rendered="#{discoveryListController.operationName == 'ADD'}" action="#{discoveryListController.doIt}" reRender="contentView:discoveryListForm:discoveryListTable,contentView:discoveryListForm:discoveryListTableScroller,contentView:discoveryListForm:discoveryListPageCount" oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('discoveryListEditPanel')}.hide();" status="mainStatus"/> <a4j:commandButton value="#{msgs.editButtonActionLabel}" rendered="#{discoveryListController.operationName == 'EDIT'}" action="#{discoveryListController.doIt}" reRender="subnet, netmask" oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('discoveryListEditPanel')}.hide();" status="mainStatus"/> </h:panelGrid> </a4j:form>
The form references a component as follows:
@Name( "discoveryList" ) public class DiscoveryList implements Serializable { private static final long serialVersionUID = 1734458878690387538L; /** * Specifies the subnet indicated in this DiscoveryList (the unique id) */ @NotNull(message="The subnet is a required field") @Length(max=15, message="The subnet cannot be longer than 15 characters") @Pattern(regex="^\\d\\{1,3\\}\\.\\d\\{1,3\\}\\.\\d\\{1,3\\}\\.\\d\\{1,3\\}$", message="The subnet must be in the format \\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}") protected String subnet_ = null; /** * Specifies the netmask to go along with the netmask attribute */ @NotNull(message="The netmask is a required field") @Length(max=15, message="The metmask cannot be longer than 15 characters") @Pattern(regex="^\\d\\{1,3\\}\\.\\d\\{1,3\\}\\.\\d\\{1,3\\}\\.\\d\\{1,3\\}$", message="The netmask must be in the format \\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}") protected String netmask_ = null; /** * @return the subnet */ public String getSubnet() { System.out.println( "getSubnet returns " + subnet_ ); return subnet_; } /** * @param subnet the subnet to set */ public void setSubnet( String subnet ) { System.out.println( "setSubnet called with [" + subnet + "]" ); this.subnet_ = subnet; } /** * @return the netmask */ public String getNetmask() { return netmask_; } /** * @param netmask the netmask to set */ public void setNetmask( String netmask ) { this.netmask_ = netmask; } }
I have several problems with the above.....
1) While I get some indication from the server log that the hibernate is getting invoked when the setters are called onblur
16:04:24,947 ERROR [STDERR] Mar 14, 2009 4:04:24 PM org.hibernate.validator.Version <clinit> INFO: Hibernate Validator 3.1.0.GA 16:04:25,036 ERROR [STDERR] Mar 14, 2009 4:04:25 PM org.hibernate.annotations.common.Version <clinit> INFO: Hibernate Commons Annotations 3.1.0.GA
There are no facesMessages, error icons, error formatting or form submission prevention that would indicate that the Validators are actually being executed or enforced when invalid input is put in the form.....
2) The icons for invalid and ! invalid never appear at in the form.
I would greatly appreciate any and all help with this as I am unable to make any progress after multiple hours of attempt and googling.
TIA!