Announcement

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

    How can i use java Reflection in smartgwt

    i would like to use java reflection in smartgwt. is it possible?
    i wrote code Class.forName("MyDataSource"). when i ran the programm, it said it was wrong.

    Can i use java reflection in smartgwt?

    Thanks

    xiaochen

    #2
    Hi
    It is simply not possible to use reflection in smartgwt.

    Though gwt client side code looks like Java it is not pure java so any import from javax package can not be used.

    Let me know of your requirement is so critical.I will tell you way of how to do it.
    But i will not recommend to use that way instead try to find workaround it not using reflection.

    Comment


      #3
      thanks vic.

      the reason that i would like to use reflection is that i would like to write the code that read the datasource name from a configure file, then use reflection to create the datasource.

      for me, at the moment i use a config file to generate different search condition. some condition (selection box ) binds datasource.
      { "field" : "exception",
      "type" : "select",
      "source" : "SourceExceptionListDataSource",
      },
      i would like to bind the selection item to the datasource according to the config file. then i would not need to change the code for each item, just generate it according to config file.
      i see that gwt has a framework to support reflection, http://gwtreflection.sourceforge.net/. i do not know whether smartgwt could support reflection as well. it will help to make the code flexible.

      many thanks

      xiaochen

      Comment


        #4
        Ya i knew about that.But that will make your code much more complex and the flexibility of reflection is gone.


        What you can do is you can acheive this using no of datsources and interfaces.
        Pass interface refrence to combo box and at runtime based on string equals condition make it contain object of your datasource.

        Comment


          #5
          If you're using SGWT EE then maybe Datasource.get("MyDataSource") would do what you want.

          ???
          ,chris

          Comment


            #6
            thanks for your replies.

            Comment

            Working...
            X