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.
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);
Comment