Agenda:

This document deals with conducting validations on Table UI having multiple rows and many columns in order to fetch a consolidated error messages in the message area providing information about the columns with data provided in wrong format.

Step 1:

The scenario would be a case as shown below.There would be multiple tables in the view which needs to be validated.

Fig1.1.png

Fig 1.1

In this case all the validations would be triggered on the action of Save Button and Save as Draft button.

Step 2:

We all do know that there is always a standard function written in the component controller as a part of best practice to check whether the mandatory values have been entered or not.

Therefore  create a method in your component controller namely m_checkMandatoryValues(String p_fieldLabel,String p_fieldValue,IWDAttributePointer p_AttValue) which returns TRUE or FALSE.

wherein p_fieldLabel-for eg:Name of Directors from the table 1 in fig 1.1

               p_fieldValue-the input value stored in the context attribute for the same.

               p_AttPointer-Location value of the context attribute.


Here if the p_fieldValue is null or empty ,the method returns  false along with the Error Message specified in the Message Manager(Using MessagePool).

Step 3:

Now in the view mentioned in the above figure Fig 1.1, we shall create 3 methods called m_valTable1(),m_ValTable2() and so on.

Step 4:

For Method m_ValTable1()-

We need to iterate through the node that is bound to Table1 namely Director’s details.Consider the node to be CTX_VN_Directors.

-Declare two boolean variable namely l_flag 1 and l_flag 2

where in l_flag1=true;

                 l_flag2=false;


for(i=0;i<CTX_VN_Directors.size();i++)

{

String l_table=”Director Details :Row :”+i;

Check Mandatory For Column 1

l_flag2=m_checkMandatoryValues(l_table+”Name of Director”,CTX_VA_DirectorName,ICTX_VN_DirectorElement.CTX_VA_DirectorName);

l_flag1=l_flag1 && l_flag2;

Check Mandatory For Column 2

l_flag2=m_checkMandatoryValues(l_table+”Address”,CTX_VA_Address,ICTX_VN_DirectorElement.CTX_VA_Address);

l_flag1=l_flag1 && l_flag2;

…..

Do the same for all the columns

}

Note: The two boolean variables are used in order to give the consolidated report error messages of all the column of a particular table.

            The string variable l_table helps to identify which row of which table .

Step 5:Repeat Step 4 for all the tables .Do remember to change the l_table variable to the corresponding table names.

Step 6:

Lastly on the action of Save button:

onActionSave()

{

-Declare two boolean variable namely l_flag 1 and l_flag 2

where in l_flag1=true;

                 l_flag2=false;

l_flag2=m_valTable1;

l_flag1=l_flag1 && l_flag2;

l_flag2=m_valTable2;

l_flag1=l_flag1 && l_flag2;

l_flag2=m_valTable3;

l_flag1=l_flag1 && l_flag2;

if(l_flag1)//That is if all the validations are successful

{

wdComponentAPi().getmessagemanager().reportsuccess(“Validations successfull!”);

}

}

This way we are able to validate tables with less number of methods and also code optimization.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply