Announcement Announcement Module
Collapse
No announcement yet.
form:form date Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • form:form date

    hi

    anyone knows how to send a date in a form:form ?

    i use <form:input for text

    but i have 3 selects
    <select days>,<select month>, <select years>
    <select name="day" class="entradatxt">
    <c:forEach var="ini" begin="1" end="31">
    <option value="${ini}">${ini}</option>
    </c:forEach>
    </select>


    &nbsp;
    <select name="month" class="entradatxt">
    <c:forEach var="mes" items="${registro.meses}">
    <option value="${mes.id}">${mes.nombre}</option>
    </c:forEach>
    </select>

    &nbsp; <select name="year" class="entradatxt">
    <c:forEach var="init" begin="1910" end="2002">
    <option value="${init}">${init}</option>
    </c:forEach>
    </select>


    in my commandName="mybean" i have a date of birth
    how can send this 3 values ??


    tnx

  • #2
    If you want to use this way of specifying dates then spring binding can't help you. It can only do one-to-one fileld/parameter binding.

    Either place three integer fields in your command (year, month, day) and bind to those. You can construct the date later when setting it to the business object.
    If you need to bind directly to your business object (or for some reason you really need Date in your command), then override "onBind" method of your controller and manually convert the request parameters to Date.

    Comment


    • #3
      tnx senoctar

      Originally posted by senoctar View Post
      If you want to use this way of specifying dates then spring binding can't help you. It can only do one-to-one fileld/parameter binding.

      Either place three integer fields in your command (year, month, day) and bind to those. You can construct the date later when setting it to the business object.
      If you need to bind directly to your business object (or for some reason you really need Date in your command), then override "onBind" method of your controller and manually convert the request parameters to Date.
      then if i want to put them i need to place those 3 selects in the commandName="myBean" ?

      use form:select , when i submit thise bind the selected option?

      Comment


      • #4
        I got it

        as you say,

        i create 3 attibutes in myBean and reuse the forEach:

        <form:select path="dia" class="entradatxt">
        <c:forEach var="ini" begin="1" end="31">
        <form:option value="${ini}" label="${ini}"/>
        </c:forEach>
        </form:select>
        &nbsp;
        <form:select path="mes" class="entradatxt">
        <c:forEach var="mes" items="${registro.meses}">
        <form:option value="${mes.id}" label="${mes.nombre}"/>
        </c:forEach>
        </form:select>
        &nbsp;
        <form:select path="anio" class="entradatxt">
        <c:forEach var="init" begin="1910" end="2002">
        <form:option value="${init}" label ="${init}" />
        </c:forEach>
        </form:select>

        just onli miss vaildate the date formed, i thing i do it with jquery

        tnx
        Cya

        Comment

        Working...
        X