Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Hours and minutes in Calendar

    Hello,
    when I click on the save button of the EventEditor, I would save on the server the values of the fields startHours, startMinutes, startAMPM, endHours, endMinutes, endAMPM of the EventEditor, but I get only the fields description, name, startDate and endDate.
    StartDate and endDate fields have as value only the date without the time.
    What I have to do?

    #2
    See this thread, in particular, this response.

    Comment


      #3
      I have tried to override the transformRequest function but this solution doesn't work. This is the code:

      @Override
      protected Object transformRequest(DSRequest dsr) {

      JavaScriptObject data = dsr.getData();
      String res="";

      Date startDate = dsr.getAttributeAsDate("startDate");
      int startHours = startDate.getHours();
      JSOHelper.setAttribute(data, "startHours", startHours);
      int startMin = startDate.getMinutes();
      JSOHelper.setAttribute(data, "startMinutes", startMin);

      Date endDate = dsr.getAttributeAsDate("endDate");
      int endHours = endDate.getHours();
      JSOHelper.setAttribute(data, "endHours", endHours);
      int endMin = endDate.getMinutes();
      JSOHelper.setAttribute(data, "endMinutes", endMin);


      res="_operationType="+dsr.getOperationType()+"&_dataSource="+dsr.getDataSource()+"&name="+dsr.getAttributeAsString("name")+"&description="+dsr.getAttribute("description")+"&startDate="+startDate+"&endDate="+endDate+"&startHours="+startHours+"&startMinutes="+startMin+"&endHours="+endHours+"&endMinutes="+endMin;

      return res;
      }


      The function return a string because I use RestDataSource.
      I get this error in the firefox page:

      n is null
      [Break on this error] function ucf(i){var h,j,k,l,m,n,o,p,c,a,...+uI+n+vI+j+wI+o+xI+p+yI+k+zI+l;return m}


      I've tried also to return only the standard field (operationType, dataSource, name, description,startDate, endDate) but on the server side I get only null values.

      What's the problem?

      Thanks
      Last edited by nhora; 8 Jan 2009, 01:52.

      Comment


        #4
        Take a second look at the post you were referred to. Return value should be a JavaScriptObject containing the properties you want to appear as HTTP parameters.

        Comment


          #5
          As written in the post you were referred to:

          As mentioned in the docs for transformRequest, you need to return the "data", and not the DSRequest. "data" will be a JavaScriptObject like above in all cases except when using RestDataSource in which case it will be the actual String value of the parameters.

          So I've returned a string....

          Comment


            #6
            That's unfortunate wording, the reality is, in both cases you return a JavaScriptObject. The RestDataSource expects a string only when using dataProtocol "postMessage", which is not the case here.

            Comment


              #7
              This solution doesn't work :-(
              I get this error:

              i is null
              [Break on this error] function ubf(e){var d,f,g,h,i,j,k,c,a,b;...=f.jsdate.getMinutes();d[iI]=h;return d}

              and this is the code used:

              @Override
              protected Object transformRequest(DSRequest dsr) {
              JavaScriptObject data = dsr.getData();

              Date startDate = dsr.getAttributeAsDate("startDate");
              int startHours = startDate.getHours();
              JSOHelper.setAttribute(data, "startHours", startHours);
              int startMin = startDate.getMinutes();
              JSOHelper.setAttribute(data, "startMinutes", startMin);

              Date endDate = dsr.getAttributeAsDate("endDate");
              int endHours = endDate.getHours();
              JSOHelper.setAttribute(data, "endHours", endHours);
              int endMin = endDate.getMinutes();
              JSOHelper.setAttribute(data, "endMinutes", endMin);

              return data;
              }

              Comment


                #8
                I've tried to return the data without add anything, in this way:

                @Override
                protected Object transformRequest(DSRequest dsr) {

                JavaScriptObject data = dsr.getData();
                return data;

                }


                On the server side I get this response:

                startDate=2009-01-05&description=testDescr&name=testName&endDate=2009-01-05


                So, I think the problem is that startDate and endDate don't contain the time, thus the function startDate.getHours() and startDate.getMinutes() don't work.

                What have I missed? Should I set any other thing?

                Comment


                  #9
                  Another small error in that other post. It should be data.getAttribute(), not dsr.getAttribute().

                  Comment


                    #10
                    Neither data.getAttribute() nor data.getAttributeAsDate() exists. Moreover data doesn't contain the time in the startDate and endDate fields.
                    Last edited by nhora; 8 Jan 2009, 07:18.

                    Comment


                      #11
                      Looks like there were a number of flaws in that sample code. Use the JSOHelper to get the startDate and endDate from the "data" object.

                      Comment


                        #12
                        Also this time I got an error:

                        m is null
                        [Break on this error] function ubf(i){var h,j,k,l,m,n,o,g;h=(g...=j.jsdate.getMinutes();h[iI]=l;return h}

                        The code used is this:

                        @Override
                        protected Object transformRequest(DSRequest dsr) {

                        JavaScriptObject data = dsr.getData();



                        Date startDate = JSOHelper.getAttributeAsDate(data, "startDate");
                        int startHours = startDate.getHours();
                        JSOHelper.setAttribute(data, "startHours", startHours);
                        int startMin = startDate.getMinutes();
                        JSOHelper.setAttribute(data, "startMinutes", startMin);


                        Date endDate = JSOHelper.getAttributeAsDate(data, "endDate");
                        int endHours = endDate.getHours();
                        JSOHelper.setAttribute(data, "endHours", endHours);
                        int endMin = endDate.getMinutes();
                        JSOHelper.setAttribute(data, "endMinutes", endMin);



                        return data;
                        }

                        Comment


                          #13
                          transformRequest() is called for or all operationTypes: fetch, add, update, remove. You need to change your code so it executes only for update and add.

                          Comment


                            #14
                            You can check for the operation type via the method DSRequest.getOperationType()

                            Comment

                            Working...
                            X