In earlier parts of this series of blogs, we have learned to create a BPM Process, deploy it and import it in our Web Dynpro Java Component. This part focuses on the invocation of BPM process from our Web Dynpro Java application using java code. Sample code to invoke the adaptive web service model is given below:
ModelName objModelName = new ModelName();
Request_Name objRequest = new Request_Name(objModelName);
StartOpName objStartOpName = new StartOpName(objModelName);
// Set the values for the Details Node (Cardinality is 1:1)
DetailsType objDetailsType = new DetailsType(objModelName);
// Set the value for attribute Name, String type (Check for Null)
if (wdContext.currentDetailsElement().getName() != null)
objDetailsType.setName(wdContext.currentDetailsElement().getName());
else
objDetailsType.setName("");
// Set the value for Age (No check as by default it will be 0 if not already set)
objDetailsType.setName(wdContext.currentDetailsElement().getAge());
// Set the values for the Details Element
objStartOpName.setDetails(objDetailsType);
objRequest.setStartOp(objStartOpName);
// Bind the object
wdContext.nodeRequest_Name().bind(objRequest);
// Execute the model
wdContext.nodeRequest_Name().currentRequest_NameElement().modelObject().execute();
Above code is just for demonstration purpose and proper Naming/Coding standards should be followed while coding business applications. Remember we need to send the values for all the nodes which has a cardinality of 1:1 or 1:n failing which the model will throw errors and the process will not be triggered. Also verify that you do not send any null values for any string attributes, otherwise a null pointer exception will be thrown.