Tables within Forms
Tables within forms can be used to select one from a set of records and then process it further. A typical application is e.g. the selection of a user from a part of the organization. So, one would like to select from the users of an area or a group sometimes exactly one and in the context of a business process dispatch an email automatically. A table might look like this:
The script to load the data into the table is executed in the callback of the button "Load User":
var userArrayMap=com.proxemo.todo.client.base.ToDoClientOMCache.getInstance().getUserOfOrganizationById(2);
if (userArrayMap != null && userArrayMap.size()>0)
{
var userArray = userArrayMap.values().toArray();
// store user in values
var users=new java.util.HashMap();
for (var i=0; i<userArray.length;++i)
{
var values = new StringArray(2);
var user = userArray[i];
var key = user.getLastname();
values[0]=key;
values[1]=user.getEmail();
users.put(key, values);
}
//set all user into table
helper.setFormValue(form.getMetaName(), "userTable",users);
var widget = helper.getWidget(form, "userTable");
widget.setSortingColumn(1,true);
}
In this case all users from the area with id 2 are determined via the method getUserOfOrganizationById and then imported into the table. If you only want to read the users of a group, you can access them with the getUserOfWorkgroupById method. If you want to automatically fill the text field below the table whenever a line is selected, you have to instruct the callback of the table accordingly:
if (emailValue != null)
{
helper.setFormValue(form.getMetaName(),"email",emailValue[1]);
}