Quantcast
Viewing all articles
Browse latest Browse all 8501

validation stopped the action to trigger gateway service.

Hi Friends,

 

Here is what I'm getting..

I have few input fields and a button save.

when I enter the values in the fields and then save.. it is working as expected.

But For validation purpose I have added  a condition like

 

 

var oButton1 = new sap.ui.commons.Button({

    id : 'B-SAVE',

    text : 'Save',

    width : '10em',

    style: sap.ui.commons.ButtonStyle.Emph,

    press : function(){

    if ((sap.ui.getCore().byId("input1").getValue().trim().length == 0) ||(sap.ui.getCore().byId("input2").getValue().trim().length == 0))

         {

    oInputMsg.setValue("Please enter Either Input 1 or Input 2");

 

         }

    else

       {

*then save functioanlity of calling the service and getting the result. 

       oModel = new sap.ui.model.odata.ODataModel(util.Global.getUrl("/sap/opu/odata/sap/ZSAVE"));     

       sap.ui.getCore().setModel(oModel);

 

          var sRead ="/ZsaveSet(Input1='" + Input1.getValue() + "')";

   

      oModel.read( sRead, null, null, true, function(oData, oResponse){

      oInputMsg.setValue(oData.result);    

             oPanel.placeAt("content");

   

         },function(){

             alert("Read failed");

             });   

    }

    }

  });

 

So Validation is working perfectly. when I click on save button it is throwing the error saying enter any of the one... but after entering those field and click on Save button , it is not going to the service.. it is not doing any action.

 

Can anyone of you tell me what I'm doing wrong?

 

All this code I have written in a view. do I need to copy anything to controller?

 

but before validation... it was getting the desired output.

 

 

Thanks.


Viewing all articles
Browse latest Browse all 8501

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>