2 Replies Latest reply on Jul 25, 2007 12:08 PM by Pierre De Paepe

    <h:selectOneListBox> & <s:convertDateTime>

    Pierre De Paepe Newbie

      Hello,

      I have to offer 3 dynamic dates on a selectOneListbox.

      This code:

      <h:selectOneListbox id="start" value="#{sV.start}" styleClass="sessionInput">
       <s:convertDateTime pattern="MM/dd/yyyy"/>
       <f:selectItems value="#{sV.availableStarts}" />
      </h:selectOneListbox>


      Render:

      <select id="starting:start" name="starting:start" size="3" class="sessionInput">
       <option value="07/25/2007">Wed Jul 25 09:00:31 CEST 2007</option>
       <option value="07/26/2007">Thu Jul 26 09:00:31 CEST 2007</option>
       <option value="07/27/2007">Fri Jul 27 09:00:31 CEST 2007</option>
      </select>


      So we can see that the pattern of selectItems is correctly set on value. But when i try to validate my form, <h:message/> return that the data is not a correct option.
      Which is strange as this code works :

      <h:inputText id="start" value="#{sV.start}" required="true" styleClass="sessionInput">
       <s:convertDateTime pattern="MM/dd/yyyy"/>
       <a:support event="onblur" reRender="startDecorate"/>
      </h:inputText>
      <s:selectDate for="start">
       <h:graphicImage url="img/dtpick.gif" style="margin-left:5px"/>
      </s:selectDate>
      


      Any idea about this?

        • 1. Re: <h:selectOneListBox> & <s:convertDateTime>
          Pierre De Paepe Newbie

          I become quite crasy about this issue.

          My Entity:


          @Basic @Future @Temporal(TemporalType.TIMESTAMP)
          public Date getStart()
          {
          return start;
          }

          public void setStart(Date start)
          {
          this.start = start;
          }


          The way i test my select list:


          @Transient
          public ArrayList<SelectItem> getAvailableStarts(){
          ArrayList<SelectItem> si = new ArrayList<SelectItem>();
          for(int i = 0; i < 3; i++){
          Date d = new Date()
          si.add(new SelectItem(d, df.format(d)));
          }
          return si;
          }


          Xhtml :

          <h:selectOneListbox value="#{sV.start}">
          <s:convertDateTime pattern="MM/dd/yyyy"/>
          <f:selectItems value="#{sV.availableStarts}" />
          </h:selectOneListbox>


          Return the three present dates. If i submit the @Future returns well that my date have to be in the future. If i remove the annotation, it returns that the option is not valid.
          Any idea please?

          • 2. Re: <h:selectOneListBox> & <s:convertDateTime>
            Pierre De Paepe Newbie

            Edit "code" not "quote". :/

            I become quite crasy about this issue.

            My Entity:

            @Basic @Future @Temporal(TemporalType.TIMESTAMP)
             public Date getStart()
             {
             return start;
             }
            
             public void setStart(Date start)
             {
             this.start = start;
             }
            


            The way i test my select list:

            @Transient
            public ArrayList<SelectItem> getAvailableStarts(){
             ArrayList<SelectItem> si = new ArrayList<SelectItem>();
             for(int i = 0; i < 3; i++){
             Date d = new Date()
             si.add(new SelectItem(d, df.format(d)));
             }
             return si;
            }
            


            Xhtml :

            <h:selectOneListbox value="#{sV.start}">
             <s:convertDateTime pattern="MM/dd/yyyy"/>
             <f:selectItems value="#{sV.availableStarts}" />
             </h:selectOneListbox>
            


            Return the three present dates. If i submit the @Future returns well that my date have to be in the future. If i remove the annotation, it returns that the option is not valid.
            Any idea please?