It is possible to pre-populate the values that will be displayed to the user so that the answers only need to be confirmed or modified.
For example, we can pre-populate the name and date of birth of a user on a Personal Details page assuming that the user has already logged in and another database holds the personal details.
The DS can be pre-populated prior to the start of script execution as follows:
... Datastore ds = null; try { // open the data store and create the root entity ds = DatastoreFactory.newInstance().openDatastore(schemaName); } catch (NoSuchSchemaException e) { throw new AppException(IEG.ID_SCHEMA_NOT_FOUND); } final EntityType appType = ds.getEntityType("Application"); final Entity rootElement = ds.newEntity(appType); ds.addRootEntity(rootElement); final EntityType personType = ds.getEntityType("Person"); final Entity person = ds.newEntity(personType); person.setAttribute("firstName", "TestFirstName"); person.setAttribute("lastName", "TestLastName"); person.setAttribute("dateOfBirth", "19700101"); //... rootElement.addChildEntity(person);
The root entity can then be used in creating a new script execution as follows:
... // create the script execution final IEGRootEntityID rootEntityID = new IEGRootEntityID(); rootEntityID = rootElement.getUniqueID(); final IEGRuntime runtimeAPI = new IEGRuntime(); final IEGScriptExecutionIdentifier executionIdentifier = runtimeAPI.createScriptExecutionExistingRootEntity( iegScriptID, schemaName, rootEntityID);
The IEG Player can then be run using this new script execution as follows:
<?xml version="1.0" encoding="UTF-8"?> <PAGE PAGE_ID="IEGScriptLauncher"> <JSP_SCRIPTLET> <![CDATA[ curam.omega3.request.RequestHandler rh = curam.omega3.request.RequestHandlerFactory.getRequestHandler( request); String context = request.getContextPath() + "/"; String url = context + "ieg/Screening.do?" + "executionID=" + executionID + "&" + rh.getSystemParameters(); // Redirect to the correct page. response.sendRedirect(response.encodeRedirectURL(url)); ]]> </JSP_SCRIPTLET> </PAGE>
Note that it is only possible to pre-populate the DS, and not the control questions or other script-related information as they are stored in the script execution and not in the DS. This means that it is not possible to pre-populate the data displayed in the first section of the script and start at the second section. The first section will be displayed and the user will be able to confirm the pre-populated data.