cancel
Showing results for 
Search instead for 
Did you mean: 

checkAndReportRequiredFields validation not working for Table

bernd_speckmann
Contributor
0 Kudos

Hi,

I want to validate some inputfields with the checkAndReportRequiredFields method. Everything works fine with "normal" inputfields.


IWDNode node = null;

   v.checkAndReportRequiredFields(node, IMessageConfigureAngebot.EMPTY_NUMERIC_FIELD, new Object[]{"test"});

But the inputfields within a table ( Cardinality 0..n ) are not validated. How can I achieve this?

Thanks ahead.

Bernd

Accepted Solutions (0)

Answers (5)

Answers (5)

govardan_raj
Contributor
0 Kudos

hi Bernard ,

In the link you provided please see this .

If the parameter 'node' is given, the check is restricted to UI Elements bound to attributes of this node's sub tree. If null is set for parameter node the complete WD Context starting from root node is considered. The method considers Personalization. The method doesn't consider UI elements in Table like UI elements. (IWDTable, IWDRowRepeater).

it doesnot support Table UI elements

Regards

Govardan Raj

0 Kudos

Hi Bernd,

As for validating each rows in the table values, i suggest you do the following steps:

Step 1;Write a checkMandatoryValues function returning TRUE or FALSE in your component controller

which will check for null values and return false in case it is null along with the Error in ReportException in Message Manager.

Step 2:In the view where in you want to validate the table values

          -create a method named for eg:m_ValTable1()

Step 3:In this method:
Use the following logic:

declare two boolean flags named l_flag1=true and l_flag2=false

As correctly specified by Tobias-

Iterate through the context node bound to the table

for(........)

{

Check For column 1

l_flag2=m_checkMandatoryValues(Column1);

l_flag1=l_flag2 && l_flag1;

Check for Column 2

l_flag2=m_checkMandatoryValues(Column2);

l_flag1=l_flag2 && l_flag1;

....

-Do the above for all the columns

}

Note the purpose of the usage of two boolean flags is it would return all the error messages of the columns with wrongly provided input hence making the validation very easy.

Call this method on the button of save or validate or which ever action before which it needs to be performed.

Check this link to get a broader perspective:

Kindly try and let me know.

Regards,

Nimisha

Former Member
0 Kudos

I would go the way mentioned by Tobias:

Loop through your context node, do the necessary validation manually with the currentNodeXYElement.... and afterwareds report non-valid fields using the Message Managers reportContextAttributeMessage-Method

former_member191044
Active Contributor
0 Kudos

Hi Bernd,

you could loop over the node and check those fields manualy in wdDoBeforeAction. Then report validation errors:

validation.reportValidationError(yourAttributePointer, yourMessage, new Object[] {"Your params"});

By the way. Where do you get the "checkAndReportRequiredFields" method from? Is that a WD4J standard method? Never used it before.

Regards,

Tobais

Former Member
0 Kudos

The method is from the

com.sap.tc.webdynpro.progmodel.api.WDViewController Interface

https://help.sap.com/javadocs/nwce/current/wdr/com.sap.wdr/com/sap/tc/webdynpro/progmodel/api/IWDVie...

It works perfectly well except for tables.

Former Member
0 Kudos

I'm struggling to find a solution to the same issue. Did you manage to resolve this?