Results 1 to 4 of 4

Thread: form:form date

  1. #1
    Join Date
    May 2010
    Posts
    12

    Post 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. #2

    Default

    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.

  3. #3
    Join Date
    May 2010
    Posts
    12

    Post tnx senoctar

    Quote 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?

  4. #4
    Join Date
    May 2010
    Posts
    12

    Post 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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •