3 Replies Latest reply on Oct 28, 2010 6:57 PM by kragoth

    Date field Validation

    palani.palanivelsway.gmail.com

      Hi everyone,
      i have some problem in date field validation,


      Between two-date's like (fromdate and todate),



        • 1. Re: Date field Validation

          Could you be more specific?

          • 2. Re: Date field Validation
            palani.palanivelsway.gmail.com
            <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:s="http://jboss.com/products/seam/taglib"
                 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:a="http://richfaces.org/a4j"
                 xmlns:rich="http://richfaces.org/rich"
                 template="../layout/admintemplate.xhtml">
            <ui:define name="body">
            <h:form id="productMaster" styleClass="edit" style="width:740px;">
            <rich:panel>
            <f:facet name="header">#{productMasterHome.managed ? 'Edit' : 'Add'}   #{messages.lblProductMasterDetails}</f:facet>
            <table>
            <tr>
            <td colspan="3">
            <s:decorate id="productAvailableFromField" template="../layout/edit.xhtml">
            <ui:define name="label">
            <h:outputText value="#{messages.lblProductAvailableFrom}"/>
            </ui:define>
            <rich:calendar id="productAvailableFrom1" required="true" requiredMessage="Plz select From Date" value="#{productMasterHome.instance.productAvailableFrom}"
            datePattern="#{ParamUtil.DATE_PATTERN}" boundaryDatesMode="scroll">
            <a:support event="onchanged" ajaxSingle="true" reRender="productAvailableFrom1,productAvailableFromField"/>
            </rich:calendar>
            </td>
            <td>
            <ui:define name="label">
            <h:outputText value="#{messages.lblProductAvailableTo}"/>
            </ui:define>
            <rich:calendar id="productAvailableTo1"  required="true" requiredMessage="Plz select To Date"
            dayStyleClass="disabledClassesProv" value="#{productMasterHome.instance.productAvailableTo}"
            datePattern="#{ParamUtil.DATE_PATTERN}" boundaryDatesMode="scroll">
            <a:support event="onchanged" ajaxSingle="true" reRender="productAvailableTo1"/>
            </rich:calendar>
            </s:decorate>
            </td>
            </tr>
            </table>
            </ui:define>
            </ui:composition>


            If i select fromdate(ex 25-10-2010)from calendar control, the ToDate Calendar Control Should be Display greater than from date (ex : >25-10-2010).

            I need a suggession for the above issue.

            Thanks in advance.
            • 3. Re: Date field Validation
              kragoth
              reRender="productAvailableTo1"
              



              That is where you solve the problem. Whatever method the productAvailableTol is calling to get it's data is probably a fine spot to validate the dates. It's not the best way of doing things but it will work well enough.


              JSF 1.2 doesn't really support dependent validation between components. (It can/has been done but it's not a simple task. If you are really keen on trying then search these forums there are some examples here somewhere).


              JSF 2.0 adds dependent validation I think.