How to get start date assign to end date

Thameera Nawaratna

    Hi,

    I have a ADF application which required to select (Drop down calendar) "Start Date" and "End Date". Currently when select Start Date, End date not automatically adjust to Start Date. It shows current date.

    Is there a way I can archive this without using Java bean?

    I tried to add "pageFlowScope" to action and call the value to end date through minimum Value. This doesn't give result.

     

    <af:inputDate id="id3" autoSubmit="true" autoComplete="on"
      converter="javax.faces.DateTime" immediate="true"
      action="#{pageFlowScope.dateOne}">
    </af:inputDate>

    <af:inputDate id="id4" autoSubmit="true" autoComplete="on"
      converter="javax.faces.DateTime" immediate="true"
      value='#{pageFlowScope.dateOne}"'>
    </af:inputDate>

     

    If Start Date Selected : "2019/05/05" End Date drop down should show as : "2019/05/05"

    Jdeveloper : 11g

    Deploy on Glassfish : 3.1

      • 1. Re: How to get start date assign to end date
        Timo Hahn

        User, tell us your exact 11g JDev version, please!

         

        You don't need an action method for this. First of all, remove the immediate property from the date components as this will skip validation of the values.

         

        The problem is that you start date is not stored as you have not defined the value property in the start date. Once you do this you can set the value of the startDate to the minValue of hte EndDate and set a partial trigger to update the endDate like

                                <af:inputDate label="Start" id="id1" value="#{bindings.startDate1.inputValue}"

                                              autoSubmit="true"/>

                                <af:inputDate label="End" id="id2" value="#{bindings.endDate1.inputValue}"

                                              minValue="#{bindings.startDate1.inputValue}" autoSubmit="true"

                                              partialTriggers="id1"/>

        Timo

        • 2. Re: How to get start date assign to end date
          dvohra21

          Better still, with no drop-downs involved, use af:chooseDate.

           

          //Choose a Date

          <af:chooseDate id="cd1"/>

           

          //Start Date becomes same as Chosen Date

          <af:inputDate chooseId="cd1"

                        value="#{demoInput.date}"

                        label="Date: "

                        id="id1"/>

           

          //End Date becomes same as Chosen Date

          <af:inputDate chooseId="cd1"

                        value="#{demoInput.date}"

                        label="Date: "

                        id="id2"/>

          • 3. Re: How to get start date assign to end date
            Timo Hahn

            dvohra21 have you tested this code? I don't think so. What you do with this code is to overwrite the start date if the user decides to choose another end date.

             

            Timo

            • 4. Re: How to get start date assign to end date
              dvohra21

              User has indicated the requirement to set End Date to be the same as Start Date.

               

              Regarding test, the functionality of af:chooseDate is well documented.

               

              "Users can then select a date directly within the chooseDate, which will cause the currently focused inputDate to be updated with the selected date."

              https://docs.oracle.com/cd/E24382_01/apirefs.1112/e17491/tagdoc/af_chooseDate.html

              • 5. Re: How to get start date assign to end date
                Timo Hahn

                dvohra21 but your code doesn't set the end date to the start date. You use one date for both. Changing end date will also change start date and the other way around. The user did not ask for that.

                 

                To do this the user can use a set property listener to set the end date to the value of the start date.

                 

                Timo

                • 6. Re: How to get start date assign to end date
                  dvohra21

                  The same question is answered differently in another post and marked correct.

                   

                  Change datatype of both start and end date to Date in EO and VO and also in impl classes if you have, then paste #{bindings.StartDate.inputValue} to min value of end date, and set auto submit true for start date.

                  • 7. Re: How to get start date assign to end date
                    Timo Hahn

                    dvohra21 which is the solution I gave in my first answer. You should read what other users answer to a thread too.

                     

                    Timo

                    • 8. Re: How to get start date assign to end date
                      dvohra21

                      Thanks Timo. A slight difference does exist between your answer and the other answer marked correct in a different message. While your answer is also correct, Thameera needs to update what solution fixed the issue.

                      • 9. Re: How to get start date assign to end date
                        Thameera Nawaratna

                        Thank you all. I tried all the method given and end up using bean. My version is 11.1.2.4,

                         

                        Timo Hahn, I tried your method it gives me null point exception. I think your solution will work, but code is not written by me. It was done by a vendor and the code so messy i don't want to fix everything for now. I use the partial trigger as you mentioned but use the bean.

                         

                        dvohra21 Vendor used only inputDate and I don't want to change the whole code yet. Thanks for the answer.