Coding Physical Render(Part -3)




I have given three color for code. Red indicated that it is mandatory. Black indicates comment and green indicates custom code.

if( typeof( SiebelAppFacade.ValidatePR ) === "undefined" ){
    SiebelJS.Namespace( "SiebelAppFacade.ValidatePR" );
   
    SiebelApp.S_App.RegisterConstructorAgainstKey( "ValidatePRenderer", "SiebelAppFacade.ValidatePR" );
   
    SiebelAppFacade.ValidatePR = ( function(){
       
                               
        function ValidatePR( pm ){
            SiebelAppFacade.ValidatePR.superclass.constructor.call( this, pm );
            this.GetPM().AttachPMBinding( "isEmailSet",  validateEmail, { scope: this });
                /* This is very important. We bing �isEmailSet� variable. So that this will track changes in this variable in physical model. and if changes happed, then validateEmailwill execute. */
        }
       
        SiebelJS.Extend( ValidatePR, SiebelAppFacade.PhysicalRenderer );
       
                                 function validateEmail() {
                var controls = this.GetPM().Get( "GetControls" );
            var cntrl = controls[ "EmailAddress" ];        
/*The  controls[ "EmailAddress" ]; will return an object  that contain all information about EmailAddress*/
                                                var emailcntrl  = cntrl.GetInputName();
/*cntrl.GetInputName(); Using the above object getting input name  */
                                                var email = $('input[name="'+emailcntrl+'"]').val();
/*Here is jQuery!!... using our input name we are reading the value in it. */
                                                alert(email);
                                                var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
                                                if( !emailReg.test( email ) ) {
                                                                alert("Please enter a valid Email");
                                                                return false;
                                                } else {
                                                                alert("This is a valid Email");
                                                                return true;
                                                }
/*Using a regular expression, we are testing whether it is a valid email or not.. old browser script.. */
                                }
       
        return ValidatePR;
    }());
}

Now if you change value in email field, will trigger Physical Model.. then Physical render and email filed will get validated.  Hope you understand� :)

תגובות

פוסטים פופולריים מהבלוג הזה

Profile Attributes and Open UI

SBL-BPR-00191: The rowId of the active row of the primary buscomp '%1', '%2', does not match the Primary Id

SBL-SVC-00150