Announcement

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

    Link Item shows box when combined with ValuesManager

    smartGWT Power 4/6 nightly build, Firefox 10.0.2,

    The link item in the following form appears as expected when the form is not linked to a ValuesManager. But when the form has a ValuesManager, the link item appears as a box.

    No problem for me to work around since I can put the LinkItem on a separate form, but I thought I would report it.

    Code:
    	final DynamicForm form = new DynamicForm();
    		form.setNumCols(4);
    		form.setColWidths(110, 175, 110, "*");
    		form.setPadding(5);
    		form.setSize("650", "180");
    		form.setSaveOnEnter(true);  
    		
    		Log.info("Value manager is "+dataImportElementValueManager);
    		
    		//!!!!!!!!!!!!!   Link Item appears fine if line below is commented out  */
    		form.setValuesManager(dataImportElementValueManager);
    
    		final SelectItem driverSelectItem = new SelectItem("driver", CONSTANTS.Driver());
    		driverSelectItem.setValueMap(DataImportSettingsGUI.getRDBDriversValueMap());
    		driverSelectItem.setWidth("*");
    
    		final TextItem urlClassTextItem = new TextItem("url", CONSTANTS.DataBase_URL());
    		urlClassTextItem.setWidth("*");
    		urlClassTextItem.setAttribute("browserSpellCheck", false);
    
    		final TextItem userNameTextItem = new TextItem("userName", CONSTANTS.UserName());
    		userNameTextItem.setWidth("*");
    		userNameTextItem.setAttribute("browserSpellCheck", false);
    
    		final PasswordItem passwordItem = new PasswordItem("password", CONSTANTS.Password());
    		passwordItem.setWidth("*");
    
    		final SelectItem tableNameSelectItem = new SelectItem("tableName", CONSTANTS.Table_Name());
    		tableNameSelectItem.setOptionDataSource(tableDS);
    		tableNameSelectItem.setAutoFetchData(false);
    		
    		
    		tableNameSelectItem.addChangedHandler(new ChangedHandler() {
    
    			public void onChanged(ChangedEvent event) {
    				Log.info("Executing change handler for table name selection.  Posting change to memory.");
    				dataImportElementValueManager.saveData();
    				Log.info("Ran tableNameSelectItem save data.");
    
    			}
    
    		});
    
    		// if the driver, url, user and password can establish a connection, load the available tables from the database
    
    		String driver = (String) driverSelectItem.getValue();
    		String url = (String) urlClassTextItem.getValue();
    		String userName = (String) userNameTextItem.getValue();
    		String pass = (String) passwordItem.getValue();
    		if (driver != null && url != null && userName != null && pass != null) {
    			Criteria crit = new Criteria("driver", driver);
    			crit.addCriteria("url", url);
    			crit.addCriteria("userName", userName);
    			crit.addCriteria("password", pass);
    			Log.info("Looked up tables in database to set the table selection picklist.  Database url is " + url);
    			tableNameSelectItem.setPickListCriteria(crit);
    			tableNameSelectItem.fetchData();
    		} else {
    			Log.info("Database driver, url, username or password is null.  Can't setup table name pick list options at form build.");
    		}
    		
    		
    		
    		// Add a hyperlink to test the database connection and retrieve the table names from the database for the table selection pick list
    		// User can select this hyperlink once he fills in the driver, url, username and password info in the form
    		LinkItem linkItem = new LinkItem();
    		linkItem.setHeight(20);
    		linkItem.setTitle("    ");
    		//linkItem.setLinkTitle(CONSTANTS.Test_Connection());
    		linkItem.setLinkTitle("Testing");
    		linkItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
    			public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
    				String driver = (String) driverSelectItem.getValue();
    				String url = (String) urlClassTextItem.getValue();
    				String userName = (String) userNameTextItem.getValue();
    				String pass = (String) passwordItem.getValue();
    
    				if (driver != null && url != null && userName != null && pass != null) {
    					Criteria crit = new Criteria("driver", driver);
    					crit.addCriteria("url", url);
    					crit.addCriteria("userName", userName);
    					crit.addCriteria("password", pass);
    					Log.info("Looking up tables in database " + url);
    					tableNameSelectItem.setPickListCriteria(crit);
    					tableNameSelectItem.fetchData(new DSCallback() {
    
    						// tell the user if the connection was established
    						public void execute(DSResponse response, Object rawData, DSRequest request) {
    							Log.info("In test connection hyperlink DSResponse callback.");
    							int status = response.getStatus();
    							if (status < 0) {
    								SC.warn("Database connection failed.");
    							} else {
    								SC.say("Connected to database.");
    							}
    						}
    					});
    				} else {
    					SC.warn("Database connection failed. Url, user name and Password must be non null.");
    				}
    
    			}
    		});
    
    		form.setFields(driverSelectItem, urlClassTextItem, userNameTextItem, passwordItem, linkItem, tableNameSelectItem);

    #2
    This code isn't ready to run and doesn't suggest a bug due to all the missing information. Let us know if you can modify a sample to create the problem you're reporting.

    Comment


      #3
      I also see this bug (and saw it appearing and disappearing in a few test builds this year) in SNAPSHOT_v8.3d_2012-06-12/Pro Deployment (built 2012-06-12).

      I can't seem to make a standalone repro for it (always renders as text), but maybe the OP has got a good gut feeling it's something with the combination of using ValuesManager.


      Anyway, if you manage to set setCanEdit(false) on the LinkItem, it doesn't render as a box, but as a link.

      Comment


        #4
        Thanks your trick worked.. You saved me a lot of time

        Originally posted by levi View Post
        I also see this bug (and saw it appearing and disappearing in a few test builds this year) in SNAPSHOT_v8.3d_2012-06-12/Pro Deployment (built 2012-06-12).

        I can't seem to make a standalone repro for it (always renders as text), but maybe the OP has got a good gut feeling it's something with the combination of using ValuesManager.


        Anyway, if you manage to set setCanEdit(false) on the LinkItem, it doesn't render as a box, but as a link.

        Comment

        Working...
        X