How to use ISetValueAdaptor to populate the full name text field from first and last name text field
Hi all,
I am trying to build a form that allows users to input the first and last name text fields in Forms Builder 6.7 SP3 P15.
When either of the value changes in the above, use a custom adaptor to concatenate the values and populate to a third full name text field.
I am trying to implement the above functionality using custom ISetValueAdaptor, with a simple Java class and deploying to Webtop.
I have also included screenshots of my adaptor configuration, as well as the Special tab of the third full name text field (named as "staff_name").
The class seems to be called whenever values are changed in either the first or last name fields, but it looks like I am unable to get the parameters argument.
Kindly guide me on this implementation.
My code below:
public class FullNamePopulatorAdapter implements ISetValueAdaptor {
@Override
public Object execute(IAdaptorParameter[] parameters) throws AdaptorException {
String firstName = "";
String lastName = "";
String fullName = "";
if (parameters != null && parameters.length == 2) {
IAdaptorParameter parameter = parameters[0];
if (parameter.getObject() instanceof String) {
firstName = parameter.getObject() == null ? (String) parameter.getObject() : "";
firstName = firstName.trim();
}
parameter = parameters[1];
if (parameter.getObject() instanceof String) {
lastName = parameter.getObject() == null ? (String) parameter.getObject() : "";
lastName = lastName.trim();
}
}
if (!firstName.isEmpty() && !lastName.isEmpty()) {
fullName = lastName + " " + firstName;
} else if (!firstName.isEmpty()) {
fullName = firstName;
} else if (!lastName.isEmpty()) {
fullName = lastName;
}
DfLogger.info(CLASSNAME, "firstName = " + firstName + ", lastName = " + lastName + ", fullName = " + fullName, null, null);
return fullName;
}
}
Comments
-
Hi DCTM_Guru,
Thanks for the quick response.
After some tinkering I found the problem lies with the line parameter.getObject() and it is strangely not an instanceof String.
Changed to use parameter.getValue() instead and now it works.
Updated code below.
However I now have a new problem. While the adaptor works for single valued attributes, it does not work with repeating values.
I have another form for users to start workflows for a batch of users and get approval in one go.
The sample screenshot is a part of the form in Forms Builder. Even when adding multiple rows, it looks like the adaptor only captures the first row.
But even if it captures it does not populate the first row's Full Name.
Wonder if there is a way to set the index of the row for the adaptor?
public class FullNamePopulatorAdapter implements ISetValueAdaptor {
private static final String CLASSNAME = FullNamePopulatorAdapter.class.getName();
@Override
public Object execute(IAdaptorParameter[] parameters) throws AdaptorException {
String firstName = "";
String lastName = "";
String fullName = "";
if (parameters != null && parameters.length == 2) {
IAdaptorParameter parameter = parameters[0];
firstName = parameter != null ? parameter.getValue() : "";
firstName = firstName.trim();
parameter = parameters[1];
lastName = parameter != null ? parameter.getValue() : "";
lastName = lastName.trim();
}
if (!firstName.isEmpty() && !lastName.isEmpty()) {
fullName = lastName + " " + firstName;
} else if (!firstName.isEmpty()) {
fullName = firstName;
} else if (!lastName.isEmpty()) {
fullName = lastName;
}
DfLogger.info(CLASSNAME, "firstName = " + firstName + ", lastName = " + lastName + ", fullName = " + fullName, null, null);
return fullName;
}
}
0 -
Its been a long time, but if I recall correctly, we didnt use repeating control. Instead we used a combination of both read-only table (to display any existing rows and cols) and editable row (like you shown above). There would "Insert" button visible and if there are existing repeating rows, then "Update" button will also be visible. Clicking row in read-only table would load values in the editable row.
0
Categories
- All Categories
- 111 Developer Announcements
- 49 Articles
- 103 General Questions
- 123 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 123 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 1 XM Fax