Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
Load user as options based on the group id passed by the controlling field.
Code Block | ||
---|---|---|
| ||
import java.util.Collection;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;
import org.joget.apps.form.service.FormUtil;
import org.joget.directory.model.User;
import org.joget.directory.model.service.ExtDirectoryManager;
public FormRowSet load(String[] values) {
FormRowSet rows = new FormRowSet();
ExtDirectoryManager directoryManager = (ExtDirectoryManager) AppUtil.getApplicationContext().getBean("directoryManager");
//set groupId based on dependency value
String groupId = null;
if (values != null && values.length > 0) {
groupId = values[0];
}
//Get users using directory manager
Collection userList = directoryManager.getUsers(null, null, null, null, groupId, null, null, "firstName", false, null, null);
for(Object u : userList){
User user = (User) u;
FormRow option = new FormRow();
option.setProperty(FormUtil.PROPERTY_VALUE, user.getUsername());
option.setProperty(FormUtil.PROPERTY_LABEL, user.getFirstName() + " " + user.getLastName());
rows.add(option);
}
return rows;
}
//call load method with injected variable
return load(values); |
...