Announcement

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

    Problem with FormItem.getAttributeAsObject

    Version: Isomorphic SmartClient/SmartGWT Framework (v8.3p_2013-01-20/PowerEdition Deployment 2013-01-20)
    Browser: Firefox 11.0

    I recently upgraded to the 3.1p 1/20/2013 build from this version:

    Isomorphic SmartClient/SmartGWT Framework (v8.3p_2012-11-26/PowerEdition Deployment 2012-11-26)

    The previous version allowed me to set/get a StringBuilder as an attribute within a ComboBoxItem, but now the getAttributeAsObject call returns a String, thus breaking my app. When I reverted to the prior SmartGWT version, the problem went away. Switching back to the Jan 20 version reintroduced the problem.

    Here's a test case which demonstrates the problem and verifies that a couple other types (a Boolean and an instance of a custom inner class) work fine.

    Code:
    public static class CustomClass
    {
      private String d_stringThing;
      private Integer d_intThing;
    
      public CustomClass(String stringThing, Integer intThing)
      {
         d_stringThing = stringThing;
         d_intThing = intThing;
      }
    
      public String getStringThing()
      {
        return d_stringThing;
      }
    
      public Integer getIntThing()
      {
        return d_intThing;
      }
    }
    
    public void doSimpleTest()
    {
    
      DynamicForm form = new DynamicForm();
    
      ComboBoxItem comboItem = new ComboBoxItem("name","item");
    
      form.setFields(comboItem);
    
      Object obj = new StringBuilder();
      comboItem.setAttribute("objAttrib",obj);
    
      obj = comboItem.getAttributeAsObject("objAttrib");
    
      if (!(obj instanceof StringBuilder)){
        Log.error("Expected StringBuilder, got " + obj.getClass().toString());
      }
    
      comboItem.setAttribute("objAttrib",new Boolean(false));
      obj = comboItem.getAttributeAsObject("objAttrib");
      if (!(obj instanceof Boolean)){
        Log.error("Expected Boolean, got " + obj.getClass().toString());
      }
    
      CustomClass cc = new CustomClass("quirk",888);
      comboItem.setAttribute("objAttrib",cc);
    
      obj = comboItem.getAttributeAsObject("objAttrib");
      if (!(obj instanceof CustomClass)){
        Log.error("Expected CustomClass, got " + obj.getClass().toString());
      }
    
      Canvas main = new Canvas();
      main.setHeight100();
      main.setWidth100();
    
      VLayout layout = new VLayout();
      layout.setWidth100();
      layout.setHeight100();
    
      layout.addMember(form);
    
      main.addChild(layout);
    
      main.show();
    }
    
    public void onModuleLoad()
    {
      GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler()
      {
          public void onUncaughtException(Throwable e)
          {
             Log.warn("Uncaught exception!\n", e);
          }
    });
    
    		doSimpleTest();
    }
    The output of the program is:

    Code:
    (ComboBoxTester.java:129) 2013-01-22 21:49:46,287 [ERROR] Expected StringBuilder, got class java.lang.String
    This is a highly stripped down example of a ComboBoxItem subclass that my application needs, which relies on setting/getting some attributes. Is there some workaround to this issue I can use instead?

    Thanks in advance.

    #2
    We've gone and reverted a change that would cause StringBuilder -> String conversion. This will be present in the next nightly build.

    Comment


      #3
      Thank you very much.

      Comment

      Working...
      X