@ Override protected void validateComponent ( final List < Diagnostic > diags ) { String text1 = field1 . getText ( ) ; String text2 = field2 . getText ( ) ; String text3 = field3 . getText ( ) ; if ( text1 != null && text1 . length ( ) > 0 && text1 . equals ( text2 ) ) { // Note that this error will hyperlink to Field 2. diags . add ( createErrorDiagnostic ( field2 , "Fields 1 and 2 cannot be the same." ) ) ; } int len = 0 ; if ( text1 != null ) { len += text1 . length ( ) ; } if ( text2 != null ) { len += text2 . length ( ) ; } if ( len > 20 ) { // Note that this error does not link to a specific field. diags . add ( createErrorDiagnostic ( "The total length of Field 1 plus Field 2 can exceed 20 characters." ) ) ; } // Sample Warning Message if ( Util . empty ( text3 ) ) { diags . add ( new DiagnosticImpl ( Diagnostic . WARNING , UIContextHolder . getCurrent ( ) , field3 , "Warning that this should not be blank" ) ) ; } }
An example of cross field validation .