Announcement

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

    DynamicForm.setID() throws IllegalStateException in HostedMode on latest Nightly

    When running the smartgwt pro nightly build from 5/14/2011 in hosted mode, I'm getting java.lang.IllegalStateException errors when trying to set the ID of a DynamicForm. I don't get the exception when the code is deployed to a container (JBoss).

    Here is the exception:
    Code:
    java.lang.IllegalStateException: Cannot change configuration property 'ID' to QCodeValueDialog_NotamEditorFormDyn1 after the component has been created.
    	at com.smartgwt.client.widgets.BaseWidget.error(BaseWidget.java:596)
    	at com.smartgwt.client.widgets.BaseWidget.error(BaseWidget.java:584)
    	at com.smartgwt.client.widgets.BaseWidget.setAttribute(BaseWidget.java:606)
    	at com.smartgwt.client.widgets.BaseWidget.setID(BaseWidget.java:323)
    	at com.jeppesen.nmt.client.dialog.QCodeValueDialog.<init>(QCodeValueDialog.java:57)
    And here is the code that throws the exception:
    Code:
    		DynamicForm editor = new DynamicForm();
    		editor.setID( SCUtil.buildChildId( getID(), "Form" ) );
    Looking at the available constructors for DynamicForm shows that there isn't a constructor that takes an ID, unlike Canvas and many of the other widgets.

    Is this a bug, or am I missing something?

    I'm running Firefox 3.6.17 on Ubuntu.

    Thanks,
    Chris

    #2
    If it's Chrome only, it's a known core GWT bug mentioned in the FAQ. If it occurs on other browsers, let us know.

    Comment


      #3
      It is occurring on Firefox 3.6.17.

      I stepped through the code and to my surprise it wasn't the setID() on the form that was throwing the exception, but the setID() call on the parent Window.

      Comment


        #4
        OK.. it may well be a legitimate application bug. The difference in the new nightlies is that this problem is warned about earlier.

        Comment


          #5
          We set the IDs to facilitate Selenium testing. The warning dialogs in hosted mode are very annoying. Will this be fixed in one of the upcoming nightly builds?

          Thanks!

          Comment


            #6
            There's no problem with setting IDs. There is a problem with setting an ID on a component that's already been drawn as the error message says. If you think this warning is spurious, then please try putting together test code that causes it to happen inappropriately, otherwise, this looks like a pre-existing application bug that SmartGWT is now reporting for you.

            Comment


              #7
              Ok, I think I see what is going on here.

              I have a class that extends Window:
              Code:
              public abstract class MultiValueDialog extends Window
              {
              	public MultiValueDialog(String title)
              	{
              		setTitle( title );		
              		setShowModalMask( true );
              		setShowMinimizeButton( false );
              		setShowCloseButton( true );
              		setAutoCenter( true );
              		centerInPage();		
              		setShowResizer( false );
              		setIsModal( true );
              		setBackgroundColor( "white" );
              ...
              And its children set the ID like this:
              Code:
              public class QCodeValueDialog extends MultiValueDialog
              {
              	public QCodeValueDialog(String id)
              	{
              		super( "Q-Codes");
              		setID( id );
              So at this point is the component already drawn and it is too late to set the ID?

              I made these changes to the class and it fixes the problem:
              Code:
              public abstract class MultiValueDialog extends Window
              {
              	public MultiValueDialog(String title, String id)
              	{
              		setID(id);
              		setTitle( title );		
              		setShowModalMask( true );
              		setShowMinimizeButton( false );
              		setShowCloseButton( true );
              		setAutoCenter( true );
              		centerInPage();		
              		setShowResizer( false );
              		setIsModal( true );
              		setBackgroundColor( "white" );
              ...
              and to the child class:
              Code:
              public class QCodeValueDialog extends MultiValueDialog
              {
              	public QCodeValueDialog(String id)
              	{
              		super( "Q-Codes", id );

              Comment


                #8
                Not technically drawn in this case, but yes, some of those APIs force creation of underlying elements. Your fix is correct and in general, call setID() first to avoid any issues.

                Comment


                  #9
                  Thanks Isomorphic for your help and clarifications!

                  Comment

                  Working...
                  X