Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Custom Coding Reference Module

In order to call java APIs in your customclass.java or IFormListener.java/processname.java you have to use
objReference object provided in executeServerEvent(customclass.java) and in
getClassInstance(IFormListener.java/processname.java) function.
Ex :
objReference.getDataFromDB(“select username from PDBUser where userindex=10”);

The following java APIs are available:


1. getDataFromDB(query) – to get data from database.
This will return data as a two-dimensional array.
2. saveDataInDB(query) – to save data in database.
This will return status if the query is succesfully executed or not.
3. GetActivityId() - return current workitem activity id.
4. GetActivityName() - return current workitem activity name.
5. GetCabinetName() - return cabinet name.
6. getProcessName() - return process name.
7. GetServerIp() - return server ip.
8. GetServerPort() - return server port.
9. GetUserName() - return logged in username.
10. setValue(String controlName,String Value)
This API is used to setValue in primitive fields.
Controlname – ID of the control.
Value – String value of control.
Ex -
ifr.setValue("controlId", "14");
11. setValue(String controlName,JSONArray jsonArray)
This API is used to setValue in listbox.
Controlname – ID of the control.
Value – JSON array of values(String).
Ex -
JSONArray obj=new JSONArray();
obj.add("aa");
obj.add(“bb”);
ifr.setValue(“listbox”,obj);
12. setTableCellValue(String controlName, int rowIndex,int colIndex,String value)
This API is used to value in grid cell.
Controlname – ID of the control.
RowIndex – rowindex of the cell grid
ColIndex – colIndex of the cell grid.
Value – String value of cell.
13. setTableCellValue(String tableId,int rowIndex,String controlId,String value)
This API is used to set value in controls which are not visible in grid in case of Advanced Listview
tableId – ID of the table/grid.
RowIndex – rowindex of the cell grid
controlId – ControlId of control in overlay for which value need to be changed.
Value – String value of cell.
Ex -
ifr.setTableCellValue("table1", 0, 1, "34");
14. setTableCellValue(String tableId,int rowIndex,int colIndex,JSONArray jsonArray)
This API is used to set value in listbox controls which are visible in grid in case of Advanced Listview.
tableId – ID of the table/grid.
RowIndex – rowindex of the cell grid
ColIndex – colIndex of the cell grid.
jsonArray – json Array of string values.
JSONArray obj=new JSONArray();
obj.add("aa");
obj.add(“bb”);
ifr.setTableCellValue("table1", 0, 1, obj);
15. setTableCellValue(String tableId,int rowIndex,String controlId,JSONArray jsonArray)
This API is used to set value in listbox and table/grid controls which are not visible in grid in case of
Advanced Listview.
tableId – ID of the table/grid.
RowIndex – rowindex of the cell grid
controlId – ControlId of control in overlay for which value need to be changed.
jsonArray – json Array of values. In case of listbox it should be a array of strings. In case of table/Grid, it
will be a array of JSONObjects where each JSONObject corresponds to a new row. In JSONObject you
have to put entries with key as column name and value as value of grid cell.
Ex -
For ListBox
JSONArray obj=new JSONArray();
obj.add("aa");
obj.add(“bb”);
ifr.setTableCellValue(“table1”,1,"listbox", obj);
where ifr is of type IformReference.
For Table/Grid
JSONArray jsonArray=new JSONArray();
JSONObject obj=new JSONObject();
obj.put("columnName", "1");
jsonArray.add(obj);
obj=new JSONObject();
obj.put("columnName", "2");
jsonArray.add(obj);
ifr.setTableCellValue(“table1”,1,"table4_table2", obj);
16. addDataToGrid(String tableId,JSONArray jsonArray)
This API is used to add rows in grid.
tableId – ID of the table/grid.
jsonArray – json Array of values. In case of listbox it should be a array of strings. In case of table/Grid, it
will be a array of JSONObjects where each JSONObject corresponds to a new row. In JSONObject you
have to put entries with key as column name and value as value of grid cell. Here the json Array will be
formed as given in previous API.
In case of Advanced Grid, while making rowObject instead of column name ,you have to provide the
controlId of controls in the overlay.
Ex –
Advanced Listview
JSONArray jsonArray=new JSONArray();
JSONObject obj=new JSONObject();
obj.put("controlId1", "1");
obj.put("controlId2", "2");
JSONArray chilGridArray=new JSONArray();
JSONObject childGridRowObject=new JSONObject();
childGridRowObject.put(“columnName”,”value”);
chilGridArray.add( childGridRowObject);
obj.put(“controlIdGrid”,chilGridArray);
jsonArray.add(obj);
ifr.addDataToGrid(“table1”,jsonArray);
17. clearTable(String tableId)
This API is used to clear Rows in grid.
tableId – ID of the table/grid.
Ex -
ifr.clearTable("table1");
18. WDGeneralData getObjGeneralData()
This API is used to get the WDGeneralData object
return value : WDGeneralData object
Ex -
WDGeneralData wdgeneralObj= ifr.getObjGeneralData();
You can get sessionId, taskid, userName, DBType, etc from wdgeneralObj in the following way:

String sessionId = wdgeneralObj.getM_strDMSSessionId();


String taskId = wdgeneralObj.getTaskId();
String userName = wdgeneralObj.getM_strUserName();
String dbType = wdgeneralObj.getM_strDBType();

18. getDataFromStoredProcedure(String pProcName, List pParamList);

formReference.getDataFromStoredProcedure("your store procedure name",listOfParameter);

In above API call we will pass first parameter store procedure name as string and in second
parameter we will pass a arrayList object containing the parameters for the stored procedure.
For example :
For example , if procedure expects two parameters of type Integer, Text .
Parameter list will contain datatype and value both .DataType and value will be
colon (:) separated .
In this case paramlist would be like as follows:
List<String> paramlist =new Arraylist<String>( );
paramlist . add ("Integer : 10");
paramlist . add ("Text : John");
Note:
1) In above example we have seen the second parameter to API is an
arrayList object. This arrayList object will have a list of parameters
each of those parameter will be colon(:) separated from its Data Type as
show above while preparing arrayList object.
2) In case, procedure expects no parameter , pParamList will be empty.
3) supported parameter dataTypes are (Integer,Text,Float) .

19. getValue(String controlId)

This API is used to get value of primitive controls like textbox,combobox,listbox etc.
Parameters:
1. controlId: ControlID of the control.
Return Value:
This function by default will return a object.
For listbox you have to cast the return value of this API to JSONArray.
Ex: (JSONArray)ifr.getValue("listbox")
The return value is a JSONArray of strings.

For all other controls you have to cast the return value to String.
Ex: (String)ifr.getValue("textbox")
The return value is a string.

20. getDataFromGrid(String tableId)

This API is used to get value of listview and table.


Ex: JSONArray output=ifr.getDataFromGrid ("table2");
Parameters:
1. tableId: ControlId of the table.
Return Value:
This function will return a JSONArray(array of JSONObject).
The format of JSONArray is same as the input in addDataToGrid API.
The each JSONObject inside array corresponds to a new row.
For table/Listview:
The format of JSONObject will be as given below:
{
“column1”:”value1”,
”column2”:”value2”,
.
.
}
For Advanced Listview:
The format of JSONObject will be as given below:
{
“controlId1”:”value1”,
”ControlId2”:”value2”,
”table1_table2”:[
{
“col1”:”value”,
“col2”:”value2”
}
],
”listbox1”:[“val1”,”val2”]
}
If control inside advanced listview is Listview/table, then the value will be a JSONArray with
JSONArray format as for normal table/listview.

If control inside advanced listview is a listbox, then the value will be a JSONArray with
JSONArray containing strings.

21. getTableCellValue(String tableId, int rowIndex, int columnIndex)


This API is used to get cell value of normal listview/table.
Ex: String output= getTableCellValue(“table1”,0,1);
Parameters:
1. tableId: ControlId of the table.
2. rowIndex: Row Index for the Cell.
3. colIndex: Column Index for the Cell.
Return Value:
This API will return the string value of the cell.

22. getTableCellValue(String tableId, int rowIndex, String controlId)


This API is used to get Value of controls in advanced Listview for a given rowIndex.
Parameters:
1. tableId: ControlId of the table.
2. rowIndex: Row Index for the Cell.
3. controlId: controlId of the control inside advanced Listview Modal
Return Value:
This API will return the string value of the cell.
This function by default will return a object.
1. For listbox you have to cast the return value of this API to JSONArray.
Ex: (JSONArray)ifr.getTableCellValue(“table1”,0,"listboxId")
The return value is a JSONArray of strings.
2. For primitive controls like textbox, combo, date etc, you have to cast the return value to String.
Ex: (String)ifr.getTableCellValue(“table1”,0,"textBoxId")
3. For listview/table you have to cast the return value to JSONArray.
Ex: (JSONArray)ifr.getTableCellValue(“table1”,0,"textBoxId")
The format of JSONArray is same as the input in addDataToGrid API.
The each JSONObject inside array corresponds to a new row.
The format of JSONObject will be as given below:
{
“column1”:”value1”,
”column2”:”value2”,
.
.
}

23. setStyle(String controlId,String attributeName,String attributeValue)


This API is used to set control's setstyle ()

Parameters:
1. controlId: HTML ID of the iform control.
2. attributeName: This can take the values : “disable”,”visible”,“mandatory” and
“custompattern”.
3. attributeValue: Set this to “true” or “false”
In case of “custompattern” set this to 'pattern' where pattern can be- For eg-
“[0-9]”
Return Value:
None

24. applyGroup(String groupName)


This API is used to set style for a group of controls defined from the group window in iform designer.
Parameters:
1. groupName: group name for which style is to be set

Return Value : None

25. resetGroup(String groupName)


This API is used to reset the group to the previous state.
Parameters:
1. groupName: group name for which style is to be reset

Return Value : None

26. Add an item in combo control


Call the API in following manner :

Add an option with label


addItemInCombo(comboId,label)

Add an option with label and value


addItemInCombo(comboId,label,value)

Add an option with label,tooltip and value


addItemInCombo(comboId,label,value,tooltip)

Add an option with label,tooltip ,value and optionId


addItemInCombo(comboId,label,value,tooltip,optionId)

comboId : controlId of combobox


label : label of the option to be added
value : value of the option to be added
tooltip : title of the option to be added
optionalId : Id of the option to be added
27. Add an item in table combo control
Call the API in following manner :

Add an option with label


addItemInTableCellCombo(tableId, rowIndex, columnIndex, label)

Add an option with label and value


addItemInTableCellCombo(tableId, rowIndex, columnIndex, label,value)

Add an option with label,tooltip and value


addItemInTableCellCombo(tableId, rowIndex, columnIndex, label,value,tooltip)

Add an option with label,tooltip ,value and optionId


addItemInTableCellCombo(tableId, rowIndex, columnIndex, label,value,tooltip,optionId)

comboId : controlId of combobox


label : label of the option to be added
value : value of the option to be added
tooltip : title of the option to be added
optionalId : Id of the option to be added

28. removeItemFromCombo(comboId,optionIndex)
This API is used to remove Item from combo control.
Parameters:
1. comboId: ControlID of the combo control.
2. optionIndex : index of the item to be removed.
Example:
removeItemFromCombo(“combo1”,2);

29. clearCombo(comboId)
This API is used to clear items from combo control.
Parameters:
1. comboId: ControlID of the combo control.
Example:
clearCombo(“combo1”);

30. removeItemFromTableCellCombo(tableId, rowIndex, columnIndex, optionIndex)


This API is used to remove Item from table cell combo control.
Parameters:
1. tableId : contrOlId of table Control
2. rowIndex : row index of the cell control
3. columnIndex: column index of the cell control
4. optionIndex : index of the item to be removed.
Example:
removeItemFromTableCellCombo(“table1”,1,2,2);

31. clearTableCellCombo(tableId, rowIndex, columnIndex)


This API is used to clear items from table cell combo control.
Parameters:
1. tableId : contrOlId of table Control
2. rowIndex : row index of the cell control
3. columnIndex: column index of the cell control
Example:
clearTableCellCombo(“table1”,1,2);
32. setTabStyle(String tabID,String sheetindex,String attributeName, String attributeValue)
This API is used to set style in a particular sheet of a tab control
Parameters:
1. tabID : contrOlId of tab control
2. sheetIndex : index of the tab sheet for which style is to be set.
3. attributeName: this can take value : visible/disable
4. attributeValue : false/true
Example:
setTabStyle(“tab1”,”1”,”visible”,”false”)
setTabStyle(“tab2”,”2”,”disable”,”true”)

33. addZone(String zoneName,int top,int left,int width,int height,String controlId)


This API is used to set zone for a given field.
Parameters:
1. zoneName : Name of zone
2. top : top position of zone.
3. left : left position of zone.
4. width :width of zone.
5. height : height of zone.
6. controlId : Id of control on which zone needs to be set.
Example:
addZone(“zone1”,25,25,20,20,”textbox1”)

34. deleteRowsFromGrid(String tableId,int[] rowIndices)


This API is used to delete rows from grid.
Parameters:
1. tableId : html id of table
2. rowIndices : integer array of indexs of rows that needs to be deleted.(Index needs to be in increasing
order)
Example:
int arr=new int[2];
arr[0]=0;arr[1]=2
deleteRowsFromGrid(“table2”,arr);

You might also like