}
}
public Canvas getViewPanel() {
DataSource dataSource = new DataSource() {
@Override
protected void transformResponse(DSResponse response, DSRequest request, Object jsonData) {
JSONArray value = XMLTools.selectObjects(jsonData, "/response/status");
String status = ((JSONString)value.get(0)).stringValue();
if(!status.equals("success")) {
response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR);
JSONArray errors = XMLTools.selectObjects(jsonData, "/response/errors");
response.setErrors(errors.getJavaScriptObject());
}
}
};
dataSource.setDataFormat(DSDataFormat.JSON);
dataSource.setDataURL("data/dataIntegration/json/serverValidationErrors/serverResponse.js");
DataSourceTextField userNameField = new DataSourceTextField("userName", "Username", 50, true);
DataSourceTextField firstNameField = new DataSourceTextField("firstName", "First Name", 50, true);
DataSourceTextField lastNameField = new DataSourceTextField("lastName", "Last Name", 50, true);
DataSourceTextField emailField = new DataSourceTextField("email", "Email", 100, true);
DataSourcePasswordField passwordField = new DataSourcePasswordField("password", "Password", 20, true);
dataSource.setFields(userNameField, firstNameField, lastNameField, emailField, passwordField);
final DynamicForm form = new DynamicForm();
form.setDataSource(dataSource);
form.setUseAllDataSourceFields(true);