+ Start a Discussion
arosysarosys 

rerender not working with command button

Hi 

I am having problem in re render when using with command button .

command button is calling web service , but output panel is not geting refreshed.

Please help me in this 

Here's my code . 

this is my visual force page :

 

<apex:page standardController="Account" extensions="WebserviceAccountExtension" >
    <style type="text/css">
     .dataCol { float: left;
    width: 18% !important; }
    </style>

<apex:form >

<apex:pageBlock title="New Account">

<apex:pageBlockButtons >
   <apex:commandButton value="Create New" action="{!URLFOR( $Action.Account.New, null, null,true)}"  />
   <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/>
</apex:pageBlockButtons>


<apex:pageBlockSection title="Account Information" collapsible="false">
   <apex:inputField value="{!Account.Name}" />
   <apex:actionStatus id="mySaveStatus1">
         <apex:facet name="stop">
             <apex:commandButton value="Check Accounts" action="{!CallWebservice}" status="mySaveStatus1" reRender="message"/>
         </apex:facet>
         <apex:facet name="start">
             <apex:outputPanel >
                   <apex:image value="/img/loading32.gif" style="height: 15px;"/>
                   <apex:commandButton value="Processing..." status="mySaveStatus1" disabled="true"/>
               </apex:outputPanel>
           </apex:facet>
        </apex:actionStatus>
</apex:pageBlockSection>
 
<br/>



<apex:outputPanel id="message">
<b><apex:outputText value="{!OutPutString}"  /></b><br/>
<apex:repeat value="{!accountMap}" var="key" >
 
  <apex:outputLink value="/{!key}">
  <apex:outputText style="font-style:italic" value="{!accountMap[key]}"/><br/> 
  </apex:outputLink> 

</apex:repeat>
</apex:outputPanel>


</apex:pageBlock>
</apex:form>


</apex:page>

 This is controller  code :

 

 public PageReference CallWebservice() { 
      System.debug(LoggingLevel.DEBUG,'Webservice called');
      accountMap = new Map<String, String>();
      OrganisationId = UserInfo.getOrganizationId();
      UserId = UserInfo.getUserId();
      type= 'accounts';
      accountMap.clear();
      sfdcBaseURL = URL.getSalesforceBaseUrl().toExternalForm();
      
      searchDatamapiaCom.AccountsWSPort stub = new searchDatamapiaCom.AccountsWSPort();
      stub.timeout_x = 120000;
      result = stub.GetSuggestions(acct.name,type,OrganisationId,UserId);
      if(result != null ){
           for (Integer i=0; i < result.size(); i++)
           {
           String[] part = result[i].split('\\|');
           accountMap.put(part[0].substring(0,15), part[1]);
           }
           msize=accountMap.size();
          OutPutString = 'Please reivew the account names below. If you still wish to continue , click Create New!'  ;
          System.debug(LoggingLevel.DEBUG,'Mtaches found Account Map size.....'+ msize);
      }
      else{
          OutPutString ='No matches found !';
          accountMap.clear();
          msize=accountMap.size();
          System.debug(LoggingLevel.DEBUG,'No match found Account Map size.....'+ msize);
          
      }
      
      return ApexPages.currentPage();
    }

 

Best Answer chosen by Admin (Salesforce Developers) 
AshlekhAshlekh

Hi ,

 

Just replace this code  'return ApexPages.currentPage();' to 'return null;'

 

Let me know If you get solved or not.

 

If this post helps you than please mark it as a solution and don't forget to give me kudo's.

 

Thanks

Ashlekh

All Answers

AshlekhAshlekh

Hi ,

 

Just replace this code  'return ApexPages.currentPage();' to 'return null;'

 

Let me know If you get solved or not.

 

If this post helps you than please mark it as a solution and don't forget to give me kudo's.

 

Thanks

Ashlekh

This was selected as the best answer
arosysarosys

 it worked :)

Thanks alot :)