Announcement

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

    Calendar widget and DB connection

    Hello,

    in my application I want to use the calendar widget to create a calendar that would be specific for each user.
    So I need to link this calendar to my db to save the events.

    I thought that I just had to extend the Calendar class and to override the addEvent, removeEvent and updateEvent methods to integrate my RPC calls to store events in the DB. But this is not working : I think that the method that is called when you add an event is still the Calendar one and not the one in my extended class.

    Off course I have already added a datasource to my calendar but it's the same problem whe I override the addData on that datasource to call my RPCs : it's not working neither.

    May you help me to understand how I can deal with that as the synchro between DB and Calendar is mandatory in most of the applications using a Calendar widget.

    Regards

    #2
    I have given up on trying to modify the Calendar component. Too much of the functionality is in JavaScript, and things that should just work work - like overriding the daybodyclick method don't.

    To do what you want to do, you want to modify the data source rather then the calendar widget. If you are using XML, then it's simply a matter of using RESTDataSource. If not, you can use a generic data source and extend it and have that call your RPC methods to do stuff.

    Comment


      #3
      that's a pity to have such widget without a simple way to connect it to a DB because without db connection you loose all the interest of that widget imo.

      Whatever, if I get you well I should use the setTransform method in my datasource to catch the add, update and remove actions and then call my RPCs services to update my MySQL DB, it is right ?
      Did you manage to do that for your own needs ?

      Regards

      Comment


        #4
        Hi olinsha,
        I think you are not fully aware of SmartGWT's datasource capabilities. Calendar is a DataBound widget like ListGrid or TreeGrid. Simply create a DataSource and assign it to the Calendar and any changes to the calendar will propagate to the DataSource. Have a look at the DataBound Calendar sample in the showcase as well as the RestfulDataSource sample which illustrates how fetch / update / remove / filter operations are passed to the server. Once the request is received by the server, it is for you to write server side code to read from / update the database.

        If you're looking for a simple way to connect any databound component to a database without writing any server side code, SmartGWT Enterprise Edition (EE) will do this for you.

        If you are not familiar with DataSource's, Please read chapter 8 on Data Integration in the Quick Start guide.

        Comment


          #5
          Originally posted by jprismon
          I have given up on trying to modify the Calendar component. Too much of the functionality is in JavaScript, and things that should just work work - like overriding the daybodyclick method don't.
          The dayBodyClick event is raised when a day is clicked in "Month" view. The docs will be updated to reflect this. I verified that it works fine.

          Comment


            #6
            Originally posted by smartgwt.dev
            Hi olinsha,
            I think you are not fully aware of SmartGWT's datasource capabilities. Calendar is a DataBound widget like ListGrid or TreeGrid. Simply create a DataSource and assign it to the Calendar and any changes to the calendar will propagate to the DataSource. Have a look at the DataBound Calendar sample in the showcase as well as the RestfulDataSource sample which illustrates how fetch / update / remove / filter operations are passed to the server. Once the request is received by the server, it is for you to write server side code to read from / update the database.

            If you're looking for a simple way to connect any databound component to a database without writing any server side code, SmartGWT Enterprise Edition (EE) will do this for you.

            If you are not familiar with DataSource's, Please read chapter 8 on Data Integration in the Quick Start guide.
            Hello,
            I know for the Datasource, i have already linked a Datasource to my Calendar. But this is not a real client / server interaction, the datasource is still on client side.
            I don't want to invest in smartclientEE because I just develop a small web app for my own use, i'm not a company.

            I checked the samples of Calendar widget many times, believe me :) , but in the showcase everything is a little bit fake : all the data are loaded from a client-side array and the event we can create will be lost as soon as we quit the application.
            I would like to put in place a Calendar that can advise the real server of any update,save,delete done on the events.

            So my only requirement is to be able to intercept the actions done on events to be able to make my proper call to my server-side services to update my MySQL DB.
            May you indicate me how i can proceed for that ? Or it's not possible with the existing widget ?
            (in fact it would be great to have a handler on the calendar to intercept the modifications on events. I have tried the onEventChanged method on the according handler but it's not working.

            Regards

            Comment


              #7
              Once you have setup a RestDataSource with add/update/delete URL's you should be able to intercept the call in transformRequest

              Comment


                #8
                Originally posted by smartgwt.dev
                The dayBodyClick event is raised when a day is clicked in "Month" view. The docs will be updated to reflect this. I verified that it works fine.
                Is there any way to override the behavior on the weekly view or the daily view?

                Comment


                  #9
                  Updating Databse on Server End

                  Originally posted by olinsha
                  Hello,
                  I know for the Datasource, i have already linked a Datasource to my Calendar. But this is not a real client / server interaction, the datasource is still on client side.
                  I don't want to invest in smartclientEE because I just develop a small web app for my own use, i'm not a company.

                  I checked the samples of Calendar widget many times, believe me :) , but in the showcase everything is a little bit fake : all the data are loaded from a client-side array and the event we can create will be lost as soon as we quit the application.
                  I would like to put in place a Calendar that can advise the real server of any update,save,delete done on the events.

                  So my only requirement is to be able to intercept the actions done on events to be able to make my proper call to my server-side services to update my MySQL DB.
                  May you indicate me how i can proceed for that ? Or it's not possible with the existing widget ?
                  (in fact it would be great to have a handler on the calendar to intercept the modifications on events. I have tried the onEventChanged method on the according handler but it's not working.

                  Regards
                  I am also having a hard time finding out how to accomplish this (spent the whole day yesterday and today trying...) It would be good if someone was able to post a small example of DataSource intergration with a database on the server side (eg MySQL). All the examples I have come across keep talking about DataBinding to client side data via XML and JSON etc... How are fetch / update / remove / filter operations passed to the server? From the ResfullDataSource example I get the impression that they are passed over in xml format... how then do we translate this on the server end to MySQL connection? Do we have to write our own parsers? Someone mentioned that we might have to get the SmartClient Enterprise Edition (EE) for this? :-( not free... is this true....

                  It seems like this is an ongoing question for a lot of people ... any help will be appreciated!!

                  Comment


                    #10
                    From the ResfullDataSource example I get the impression that they are passed over in xml format... how then do we translate this on the server end to MySQL connection? Do we have to write our own parsers?
                    That's exactly what you need to do. Once you get the XML string on the server side parse it out and then call the appropriate sql

                    Comment


                      #11
                      I'm happy to see that I'm not the only one confused with this kind of thing :)

                      Ok, I have done the following thing :

                      I have overide the transformRequest in my datasource (not a RestDataSource, a classical one because I would prefer to avoid xml and to use my own POJOs to exchange information with the server)
                      In this method I can easily capture the different actions taken on the calendar : fetch, remove, add, update.

                      That's a first great step :)

                      Now, I would like to get the data of the added/updated/removed event to initialise a new UserEvent POJO object (UserEvent is my own pojo class I want to use). I have checked the different fields of the DSRequest object that is in parameter of the transforme method but I don't manage to get the event field values.

                      Do I have to give up and to use the xml protocol as explained here and there or is there a way I can get the fields value ? so I would be able to init my UserEvent and call my servlet to handle the action on my database ?

                      Regards

                      Comment


                        #12
                        Originally posted by rmanromga
                        I am also having a hard time finding out how to accomplish this (spent the whole day yesterday and today trying...) It would be good if someone was able to post a small example of DataSource intergration with a database on the server side (eg MySQL). All the examples I have come across keep talking about DataBinding to client side data via XML and JSON etc... How are fetch / update / remove / filter operations passed to the server? From the ResfullDataSource example I get the impression that they are passed over in xml format... how then do we translate this on the server end to MySQL connection? Do we have to write our own parsers? Someone mentioned that we might have to get the SmartClient Enterprise Edition (EE) for this? :-( not free... is this true....

                        It seems like this is an ongoing question for a lot of people ... any help will be appreciated!!
                        You have a few options, but it sounds like you want something that just magically works. That's probably not going to happen ;-)

                        In a restful archiecture, you want to ahve you transport mechanism be something very simple, like XML or like JSON simply because the entire idea is that application data should be universal, with a restricted set of verbs (get/post/update/delete) so that it is universal.

                        The way I did this was to use Netbeans's RestFul Web Services + JPA entities (also provided) to handle this for me.

                        See:
                        http://www.netbeans.org/kb/60/websvc/rest.html
                        for more details.

                        There is also the possibility of using the RPC approach (rather then the document approach) by using a custom RPC approach. The downsides to this are many. You end up writing your own bindings, you still have to write a RPC service to go over the network, and it's not exportable to the outside world.

                        Does this help with your question?

                        Comment


                          #13
                          Originally posted by olinsha
                          I'm happy to see that I'm not the only one confused with this kind of thing :)

                          Ok, I have done the following thing :

                          I have overide the transformRequest in my datasource (not a RestDataSource, a classical one because I would prefer to avoid xml and to use my own POJOs to exchange information with the server)
                          In this method I can easily capture the different actions taken on the calendar : fetch, remove, add, update.

                          That's a first great step :)

                          Now, I would like to get the data of the added/updated/removed event to initialise a new UserEvent POJO object (UserEvent is my own pojo class I want to use). I have checked the different fields of the DSRequest object that is in parameter of the transforme method but I don't manage to get the event field values.

                          Do I have to give up and to use the xml protocol as explained here and there or is there a way I can get the fields value ? so I would be able to init my UserEvent and call my servlet to handle the action on my database ?

                          Regards
                          You can override the DataSource to get at these fields if you need to, to call the servlet manually. I think the whole appeal of SmartGWT is letting it do the work for you personally.

                          Comment


                            #14
                            Hello,
                            thank you for your answer. However. I can access to the records in the datasource, but if a user updates an event how may I know what event has been updated to only get this event record to call my update rpc service's method with ?

                            The easier solution (but not really the good one) would be to update the whole user events by getting all the records of the DS when I intercept a update / add / delete event with the trasformRequest method.

                            Regards

                            Comment


                              #15
                              Thanks to this forum I start to understand how to deal with my requirement :

                              I just use the transformResponse to intercept the add/remove/update action and then I call my RPC services to update my DB

                              I have only one last issue : when I add a new event in the calendar, I intercept the action and I initialize one of my own Domain Object (UserEvent) with the data got through the response.getData() call. BUT the id for this new event is not set. I don't know how to obtain the id of the new event as it has to have one (the event will be put in the datasource automatically so it will have an id but I would like to get this id to save the event in my own DB as well.

                              Do you know how I can do that ?

                              I have no issue dealing with update and remove actions as the id is ok in the getData method.

                              Regards

                              Comment

                              Working...
                              X