Announcement

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

    Java Reflection

    Is it possible to use Java Reflection to dynamically load a Class (Panel) by selecting the Class name from a database and then invoke the Class method(Create Panel) through smartgwt? My goal is to dynamically determine which panels used based a value from a database table.

    I get the sense this is not possible based on the following error:

    21:32:27.483 [ERROR] [showcase] Line 3: The import java.lang.reflect cannot be resolved

    I have the imports for Reflection.

    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.lang.reflect.Type;

    Even if Java Reflection can't be used maybe there is an alternative solution I could employ.

    Thanks,

    John Haigh

    #2
    It's a core limitation of GWT that Reflection isn't available. However this doesn't affect the underlying SmartClient system, where this would be trivial (ClassFactory.getClass(className)), so if this use case comes up a lot, consider using SmartClient directly. Otherwise, you will need to implement poor-man's reflection - switch statements, registry pattern, etc.

    Comment


      #3
      Isomorphic (Administrator) : Please tell me how to do reflection in smartgwt, because that what I need for my application. What I really need is something like this :
      1. User clicked on a menu (a tree node)
      2. Based on menu that user clicked, I need to load the right panel/view class using just the class name in string value and add the loaded panel to content area in the center.
      Please help me how to achieve this, if reflection not available, then how can I do this task?
      Thanks.

      Best Regards,
      the.wizard

      Comment

      Working...
      X