Thursday 17 January 2013

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 validateEmail will 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… :)

7 comments :

  1. Hi Prasanth,
    I am new to siebel open UI. I have been trying to customize the list applet as specified in the bookshelf Customizing List Applets to Display a Box List. I have followed all the given steps, but in my list applet i don't find any records. Please let me know your inputs.

    Thanks,

    ReplyDelete
    Replies
    1. You don't find any record - means there is an error in your script. So further steps of that script will not executed. Even in the bookshelf, I could find some semantic errors. So you just debugg it with inspector tool of any browser.

      Delete
    2. Hi Thanks for your prompt response.
      I have validated and changed my js file and now there is no error in my js file. But still I couldn't see the records.

      One more thing. when i try to debug in firefox. my debuy opened but it doesnt went inside the script eventhough i click on play and step in. Kindly let me know what i am missing.

      I have seen the below comments in this forum.
      For above issue i.e only header getting displayed for list applet and no data
      In PR:
      Replace
      SiebelJS.Extend(SISPR, SiebelAppFacade.PhysicalRenderer);
      with
      SiebelJS.Extend(SISPR, SiebelAppFacade.JQGridRenderer);

      IN PM:

      Replace
      SiebelJS.Extend(SISPM, SiebelAppFacade.PresentationModel);
      with
      SiebelJS.Extend(SISPM, SiebelAppFacade.ListPresentationModel);

      and do add all the necessary List applet files in custom_manifest file.

      Could you pls tell me where do i have to look for this PM. I mean which is the default PM and PR for list applet.

      Thanks in Advance.
      Gayathri.

      Delete
    3. to get more idea, need to see that code, and manifest.

      Delete
  2. Hi Prasanth,

    I am new to Open UI and trying to do same customization as Gayathri.

    I have created one PM and PR file and registered it with Form Applet.
    validation is working fine and applet is getting initilized succesfully but
    whenever i trying to use same PM and PR for(After doing below Modification)
    List applet i am not able to see any records.
    In PR:
    Replace
    SiebelJS.Extend(SISPR, SiebelAppFacade.PhysicalRenderer);
    with
    SiebelJS.Extend(SISPR, SiebelAppFacade.JQGridRenderer);

    IN PM:

    Replace
    SiebelJS.Extend(SISPM, SiebelAppFacade.PresentationModel);
    with
    SiebelJS.Extend(SISPM, SiebelAppFacade.ListPresentationModel);

    i will be highly thankful if you can provide some input on this issue.

    Thanks

    ReplyDelete
    Replies
    1. @Chitra
      Means there is something went wrong on the code. Mostly syntax errors, that will prohibit the further code execution and data will not populate in Applet.
      Please check in console and find error. or share the code.

      Delete