Announcement

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

    Issue with two tab DynamicForm complaining

    Hi all.. I'm following the example code in the form_splitting demo (http://www.smartclient.com/smartgwt/showcase/#layout_form_splitting) but when the code runs it complains with a number of errors like the following -- one for each form field -- there are two other complains about id collisions and those fields are not editable.. Any ideas?

    Code:
    [INFO] [myapp] - init Organization_Edit()...
    [ERROR] [myapp] - 12:23:32.965:MUP2:WARN:DynamicForm:form0:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    [ERROR] [myapp] - 12:23:32.967:MUP2:WARN:DynamicForm:form0:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    [ERROR] [myapp] - 12:23:32.969:MUP2:WARN:DynamicForm:form0:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    [ERROR] [myapp] - 12:23:32.971:MUP2:WARN:DynamicForm:form0:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    [ERROR] [myapp] - 12:23:32.974:MUP2:WARN:DynamicForm:form0:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    [ERROR] [myapp] - 12:23:32.976:MUP2:WARN:DynamicForm:form0:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    [ERROR] [myapp] - 12:23:32.997:MUP2:WARN:Log:ClassFactory.addGlobalID: ID:'isc_TextItem_6' for object '[TextItem ID:isc_TextItem_6 name:adminName]' collides with ID of existing object '[TextItem ID:isc_TextItem_6 name:address]'. The global reference to this object will be replaced
    [ERROR] [myapp] - 12:23:32.998:MUP2:WARN:Log:ClassFactory.addGlobalID: ID:'isc_TextItem_5' for object '[TextItem ID:isc_TextItem_5 name:adminPhone]' collides with ID of existing object '[TextItem ID:isc_TextItem_5 name:organizationName]'. The global reference to this object will be replaced
    [ERROR] [myapp] - 12:23:33.000:MUP2:WARN:DynamicForm:form1:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    [ERROR] [myapp] - 12:23:33.002:MUP2:WARN:DynamicForm:form1:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    [ERROR] [myapp] - 12:23:33.004:MUP2:WARN:DynamicForm:form1:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    [INFO] [myapp] - Organization_Edit.Factory.create()->view.getID() - isc_Organization_Edit_0
    I've checked the code and no-reuse is being done.. Below is the code in question :

    Code:
      public Organization_Edit() {
        super();
        
        GWT.log("init Organization_Edit()...", null);
            
        // Initialize the Accounts View layout container
        this.setStyleName("ContextArea");
        this.setWidth("*"); 
    
        DataSource OrganizationDS = DataSource.get("Organization");
        final ValuesManager vm = new ValuesManager(); 
        vm.setDataSource(OrganizationDS);
    
        final TabSet theTabs = new TabSet();  
        theTabs.setWidth(500);  
        theTabs.setHeight(250);  
    
        ////////////////////////////////////////////////////////////////////////////
        // Define the first tab content
        ////////////////////////////////////////////////////////////////////////////
        Tab organizationTab = new Tab();  
        organizationTab.setTitle("Organization Info");  
          
        final DynamicForm Orgform = new DynamicForm(); 
        Orgform.setID("form0");
        Orgform.setValuesManager(vm);
        
        TextItem OrganizationItem = new TextItem(); 
        OrganizationItem.setName("organizationName"); 
        
        TextItem addressItem = new TextItem();
        addressItem.setName("address");
        
        TextItem cityItem = new TextItem();
        cityItem.setName("city");
    
        ComboBoxItem stateItem = new ComboBoxItem();  
        stateItem.setName("state");
        stateItem.setType("comboBox");  
    
        TextItem zipItem = new TextItem();
        zipItem.setName("zipcode");
        
        TextItem organizationPhoneItem = new TextItem();
        organizationPhoneItem.setName("organizationPhone");
    
        Orgform.setFields(
                OrganizationItem,
                addressItem, 
                cityItem, 
                stateItem, 
                zipItem, 
                organizationPhoneItem
                );
    
        organizationTab.setPane(Orgform);  
      
        ////////////////////////////////////////////////////////////////////////////
        // Define the second tab content
        ////////////////////////////////////////////////////////////////////////////    
        Tab adminTab = new Tab();  
        adminTab.setTitle("Admin's Information");  
      
        final DynamicForm Adminform = new DynamicForm(); 
        Adminform.setID("form1");
        Adminform.setValuesManager(vm);
    
        TextItem adminName = new TextItem();
        adminName.setName("adminName");
        
        TextItem adminPhone = new TextItem();
        adminPhone.setName("adminPhone");
        
        TextItem adminEmail = new TextItem();
        adminEmail.setName("adminEmail");
        
        Adminform.setFields(
                adminName,
                adminPhone, 
                adminEmail
      );
    
        adminTab.setPane(Adminform);
        theTabs.setTabs(organizationTab, adminTab);
        
        IButton saveButton = new IButton("Save");
        saveButton.addClickHandler(new ClickHandler() {  
            public void onClick(ClickEvent event) {  
                if (vm.validate()) {
                    // Save the new form data if validation passed
                    vm.saveData();
                }
                else // If errors, select the proper tab
                {
                    if (Adminform.hasErrors()) {  
                        theTabs.selectTab(1);  
                    } else {  
                        theTabs.selectTab(0);  
                    }  
                }
            }
        });
        
        HStack buttons = new HStack(10);  
        buttons.setHeight(24);  
        buttons.setMembers(saveButton);  
    
        VLayout layout = new VLayout(10);  
        layout.setMembers(theTabs, buttons);  
        this.addMember(layout);
      }
    Below is the ds.xml file for the Organization items:

    Code:
    <DataSource 
    	ID="Organization" 
    	serverType="sql" 
    	tableName="Organization"
    	testFileName="/ds/test_data/Organization.data.xml"
    	>
        <fields>
    		<field name="organizationId"		title="Organization ID"								type="sequence"	primaryKey="true" hidden="true" />
    		<field name="organizationName"		title="Organization Name"		required="true"		type="text"		length="64"/>
    		<field name="address"		title="Address"					required="true"		type="text"		length="64"/>
    		<field name="city"				title="City"					required="true"		type="text"		length="32"/>
    		<field name="state"				title="State"					required="true"		type="text"		length="2">
    			<valueMap>
    				<value>AL</value>
    				<value>AK</value>
    				<value>AZ</value>
    				<value>AR</value>
    				<value>CA</value>
    				<value>CO</value>
    				<value>CT</value>
    				<value>DE</value>
    				<value>FL</value>
    				<value>GA</value>
    				<value>GU</value>
    				<value>HI</value>
    				<value>ID</value>
    				<value>IL</value>
    				<value>IN</value>
    				<value>IA</value>
    				<value>KS</value>
    				<value>KY</value>
    				<value>LA</value>
    				<value>ME</value>
    				<value>MD</value>
    				<value>MA</value>
    				<value>MI</value>
    				<value>MN</value>
    				<value>MS</value>
    				<value>MO</value>
    				<value>MT</value>
    				<value>NE</value>
    				<value>NV</value>
    				<value>NH</value>
    				<value>NJ</value>
    				<value>NM</value>
    				<value>NY</value>
    				<value>NC</value>
    				<value>ND</value>
    				<value>OH</value>
    				<value>OK</value>
    				<value>OR</value>
    				<value>PA</value>
    				<value>PR</value>
    				<value>RI</value>
    				<value>SC</value>
    				<value>SD</value>
    				<value>TN</value>
    				<value>TX</value>
    				<value>UT</value>
    				<value>VT</value>
    				<value>VI</value>
    				<value>VA</value>
    				<value>WA</value>
    				<value>WV</value>
    				<value>WI</value>
    				<value>WY</value>
    			</valueMap>
    		</field>
    		
    		<field name="zipcode"				title="Zip code"				required="true"		type="text"		length="10"/>
    		<field name="organizationPhone"		title="Phone #"					required="true"		type="text"		length="12"/>
    		<field name="adminName"			title="Administrators Name"		required="true"		type="text"		length="64"/>
    		<field name="adminPhone"			title="Admin's Phone #"			required="true"		type="text"		length="12"/>
    		<field name="adminEmail"			title="Admin's Email Address"	required="true"		type="text"		length="48"/>
        </fields>
    </DataSource>

    #2
    Bump... :-)

    Comment


      #3
      So.. I found the piece of code that has this warning in it but not being a JS junkie I'm not sure what it means -- specifically why item.destroyed is being set in my case. :

      Code:
       ... taken from DynamicForm.js ... (probably not the current version)
      createItem : function (item, type) {
          // We may want to support having the user specify which form an item belongs to before it
          // is initialized as a FormItem instance.  (The specified form will then handle values 
          // management, etc.)
          // However this is not currently supported - we'll always have form items point back to the
          // form that created them.
          // (Note: We may want a customizable 'formProperty' property, rather than hardcoding the
          // "form" property)
          if (item.form != null && !(item.form == this.getID() || item.form != this)) {
              this.logWarn("Unsupported 'form' property [" + item.form + "] set on item:" +
                            item + ".  Ignoring.");
          }
      
          if (item.destroyed && isc.isA.FormItem(item)) {
              this.logWarn("destroyed FormItem passed to setItems()/addItem(): FormItems cannot be " +
                           "re-used with different DynamicForms");
          }

      Comment


        #4
        Ok.. If I remove the datasource lines identified below from the above code blurb, then I no longer receive the complaints.. Am I missing something here?

        Code:
        public Organization_Edit() {
            super();
            
            GWT.log("init Organization_Edit()...", null);
                
            // Initialize the Accounts View layout container
            this.setStyleName("ContextArea");
            this.setWidth("*"); 
        
        -->    DataSource OrganizationDS = DataSource.get("Organization");
            final ValuesManager vm = new ValuesManager(); 
        -->    vm.setDataSource(OrganizationDS);
        .
        .
        .
        Should I not be using setDataSource() in this case or not apply it to the ValuesManager??

        Comment


          #5
          Ok.. Solved this problem.. Apparently you need to not only set the data source for the ValuesManager but also use/specify the same DS for all of the tabs connected to the ValuesManager.. Once I did that all was happy.. I must be the only one doing that.. Oh well..

          Comment


            #6
            You are not alone anymore. Therefore many thanks for the detailed description and the solution you have provided here. That helped me much.

            Comment


              #7
              Hi jkugelberg,

              see also this related post.

              Best regards
              Blama

              Comment

              Working...
              X