4 Replies Latest reply on Mar 7, 2007 11:12 AM by Christophe Miro

    Date format with parameter

    Manuel Aznar Pérez Newbie

      If i put <s:converdatetime pattern="dd/MM/yyyy">, the date is showed well.

       <h:inputText id="diaLlegada" value="#{lstEstablecimientos.diaLlegada}" required="true">
       <s:convertDateTime pattern="dd/MM/yyyy"/>
       </h:inputText>
      


      But this parameter is at this format in url : "diaLlegada=Feb%202,%202007"

      I tried :

      <converter>
       <converter-for-class>java.util.Date</converter-for-class>
       <converter-class>javax.faces.convert.DateTimeConverter</converter-class>
       <property>
       <property-name>pattern</property-name>
       <property-class>java.lang.String</property-class>
       <default-value>dd/MM/yyyy</default-value>
       </property>
      </converter>
      


      and

       <converter>
       <converter-for-class>java.util.Date</converter-for-class>
       <converter-class>org.jboss.seam.ui.ConvertDateTime</converter-class>
       <property>
       <property-name>pattern</property-name>
       <property-class>java.lang.String</property-class>
       <default-value>dd/MM/yyyy</default-value>
       </property>
       </converter>
      
       <converter>
       <converter-id>org.jboss.seam.ui.ConvertDateTime</converter-id>
       <converter-class>org.jboss.seam.ui.ConvertDateTime</converter-class>
       <property>
       <property-name>pattern</property-name>
       <property-class>java.lang.String</property-class>
       <default-value>dd/MM/yyyy</default-value>
       </property>
      
       </converter>
      


      But the date format don't change.

      How change format date for parameters url?

        • 1. Re: Date format with parameter
          Christophe Miro Newbie

          Did you find an answer?

          i'm having the same problem. I've passed, as a request attribute, a date parameter and the link with the parameter looks like this :

          <a id="_id5" href="/project/personneRecherche.seam?dateNaissance=20+f%C3%A9vr.+2000&codeMorale=&prenom=&nom=&cid=7">Recherche</a>


          I'm in french local and the parameter value looks like "20+févr.+2000".

          Then i got a parse parameter error:

          - Exception
          Exception during request processing: Unparseable date: "20 févr. 2000"
          
          java.text.DateFormat.parse(Unknown Source)
          javax.faces.convert.DateTimeConverter.getAsObject(DateTimeConverter.java:82)
          org.jboss.seam.pages.Param.getValueFromRequest(Param.java:144)
          org.jboss.seam.core.Pages.applyRequestParameterValues(Pages.java:598)
          org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:176)
          org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:57)
          org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:70)
          org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:373)
          javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:75)
          org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:213)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
          org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
          org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
          org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
          org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
          org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
          org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
          org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
          org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
          org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
          org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
          org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
          org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
          java.lang.Thread.run(Unknown Source)


          Have any clue?

          Christophe

          • 2. Re: Date format with parameter
            Christophe Miro Newbie

            I think this can be solved by adding a date converter in the "myPage.page.xml" file, with the date parameter.

            Just i don't know exactly if i can use a standard converter or if i have to implement one on my own.

            I'll keep searching :)

            Christophe

            • 3. Re: Date format with parameter
              Manuel Aznar Pérez Newbie

              Now I use:

              <f:converter converterId="com.xxxx.converters.DateConverter" />
              


              And not:

              <s:convertDateTime pattern="dd/MM/yyyy"/>
              


              Code :

              package com.xxxx.converters;
              
              import javax.faces.convert.DateTimeConverter;
              
              public class DateConverter extends DateTimeConverter {
              
               public static final String pattern = "dd/MM/yyyy";
              
               public DateConverter(){
               this.setPattern(pattern);
               }
              
              }
              


              This works fine.

              • 4. Re: Date format with parameter
                Christophe Miro Newbie

                Ok i've created a date converter inspired by your example, added the converter in my "faces-config.xml" file and then i was able to add the converterId in my files "XXX.page.xml" on the date fields and this works fine :).

                Thanks for the help.

                Christophe