+ Start a Discussion
rupesh ranjanrupesh ranjan 

How to avoid page load in this code after selecting picklist

<apex:page controller="videolistclasss" readOnly="true">
<apex:form >
 <script>
   function myJavaMethod(){
      myactionfun();
  }
  </script>
  <apex:actionFunction name="myactionfun"  action="{!getperformcalloutpageReference}" reRender="false"/>
 <apex:pageBlock >
 <apex:pageblockSection >
<apex:selectList size="1" value="{!ContentCategoryId}" id="ContentCategoryId" onchange="{!myJavaMethod}">    
      <apex:selectOptions value="{!items}" /> 
       <apex:actionSupport event="onchange">
    </apex:actionSupport>   
     </apex:selectList>
     </apex:pageblockSection>
 </apex:pageBlock>
 <apex:pageblock >   
<c:PageBlockTableEnhancerADV targetPbTableIds="a"  pageSizeOptions="5,10,15,30,40,50,60,70" defaultPageSize="50" enableExport="false"/> 
<apex:pageBlockTable id="a" value="{!performcallout}" var="wrap" width="100%"  rendered="{!normalList}">
<apex:column headerValue="Title" value="{!wrap.Title}"/>
<apex:column >
<apex:inputCheckbox value="{!wrap.selected}" > 
</apex:inputCheckbox>
</apex:column>
</apex:pageBlockTable> 
</apex:pageBlock>  
</apex:form>
</apex:page>
 
Public  class videolistclasss{
public String ContentCategoryId {get;set;}
public String PartnerId{get;set;}
public String parentcompany_id{get;set;}
PUBLIC List<selectOption> Items;
    public String toAddresses {get; set;}
     public   String MySessionID = UserInfo.getSessionID();
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
    // public   String Acode= Userinfo.getuserid();
      public   String Acode= '00528000001ktnpAAA';
     public   String Oid = '00D280000018TjaEAE';
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    public String ssnid{get;set;}
    public boolean normalList{get;set;}
    public boolean selectedList{get;set;}
    public String Title{get;set;} 
    public Boolean selected {get; set;} 
   public List<videolist> ConsoleWrapperList5{get;set;}
    public string productName{get;set;}
    public videolistclasss() {
        getperformcallout5();
       
        normalList = true;
        selectedList = false;
    }
 
    public List<videolist> getperformcallout5(){ 
        ConsoleWrapperList5 = new List<videolist>(); 
        HttpRequest req = new HttpRequest();
         HttpResponse res = new HttpResponse();
          Http http = new Http();
            System.debug('Calling method now' );
          string url = 'https://www.demomail.net/sf/api/ContactCategoryList?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0+'&PartnerId='+0;
            req.setEndpoint(url);
              System.debug('&&: '+ url );
            req.setMethod('GET');
             res = http.send(req);
              if(res.getstatusCode() == 200 && res.getbody() != null)
              {
               ConsoleWrapperList5=(List<videolist>)json.deserialize(res.getbody(),List<videolist>.class);
               }
                return consolewrapperlist5; 
                }
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        for(videolist crRec : ConsoleWrapperList5){
            options.add(new SelectOption(crRec.ContentCategoryId, crRec.CategoryName));
            System.debug('##: '+ crRec.ContentCategoryId);
        }   
        return options;
    }
    public List<consolewrap> ConsoleWrapperList{get;set;}
   public  List<consolewrap> getperformcallout(){
        ConsoleWrapperList = new List<consolewrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
     string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0+'&PartnerId='+0;
       System.debug('**: '+ url);
      req.setEndpoint(url);
        //System.debug('!!!'+ SessionId);
        req.setMethod('GET');
         //system.debug('???'+aucode);
           //system.debug('***'+ocode);
        res = http.send(req);
       // System.assert(false,res.getBody()+'-----');
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); 
            System.debug('value: '+ ConsoleWrapperList );
        }
     return ConsoleWrapperList;
    } 
public pageReference getperformcalloutpageReference ()
{
  getperformcallout(); 
  return null; 
}   
}

 
Nagendra Prasad ChNagendra Prasad Ch
Try one of the below,

1) You can use return false; in OnChange
<apex:selectList size="1" value="{!ContentCategoryId}" id="ContentCategoryId" onchange="myJavaMethod(); return false;">  

2) You can use rerender="" (rerender is blank )(or) rerender="Panel Id that doesn't exist"(Here give a panel name that doesn't exists in the page.) in apex:actionFunction 

<apex:actionFunction name="myactionfun" action="{!getperformcalloutpageReference}" reRender=""/>