function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GuptaGupta 

Rerender is not working properly.


 
    Public PageReference DoSearch()
        {
            
            ListAcc = [Select Id, Name, BillingCity From Account Where Name Like :('%' + SearchWord + '%')];
            For(Account acc : ListAcc)
            {
                ListAcc1.add(new aAccount(acc));   
            }
            System.debug('========== ListAcc ============' + ListAcc);
            System.debug('========== ListAcc1 ============' + ListAcc1);
            
            return null;
        }
         

 

=================================

<apex:page Controller="sclass6Again">
<apex:form >
    <apex:pageBlock >
   
        <apex:pageblockSection >
            <apex:pageblockSectionItem >
            <apex:outputLabel >
            Search Text :
            </apex:outputLabel>
            
            <apex:panelGroup >
            <apex:inputText value="{!SearchWord}"/>
            <apex:commandButton value="Go" Action="{!doSearch}">
            <apex:actionSupport event="onclick" reRender="x" />
            </apex:commandButton>
            </apex:panelGroup>
            </apex:pageblockSectionItem>   
        </apex:pageblockSection>
           

               
        <apex:pageBlockSection title="Results" id="x" >
            <apex:pageBlockTable value="{!ListAcc1}" var="v">
                <apex:column value="{!v.aRecord.name}"/>
                <apex:column >
                <apex:inputCheckbox value="{!v.Check}"/>
                </apex:column>
                <apex:column value="{!v.b}"/>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
        
        </apex:pageBlock>
        
          
</apex:form>
</apex:page>

 

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
GuptaGupta

Public Class sclass6Again
{   
 
    Public String SearchWord{get;set;}
   
    List<Account> ListAcc = new List<Account>();
    List<aAccount> ListAcc1 = new List<aAccount>();
    
    
    Public List<Account> getListAcc()
    {
    
        return ListAcc;
    }
    Public List<aAccount> getListAcc1()
    {    
     
        return ListAcc1;
    }
    

    Public PageReference DoSearch()
        {
            ListAcc1.clear();
            ListAcc = [Select Id, Name, BillingCity From Account Where Name Like :('%' + SearchWord + '%')];
            For(Account acc : ListAcc)
            {
                ListAcc1.add(new aAccount(acc));   
            }
            System.debug('========== ListAcc ============' + ListAcc);
            System.debug('========== ListAcc1 ============' + ListAcc1);
            
            return null;
        }
        
        
    Public Class aAccount
    {
        Public Account aRecord{get; set;}
        Public String b{get; set;}
        Public Boolean Check{get; set;}
        
        Public aAccount(Account acc)
        {
            
            aRecord = acc;
            Check = False;
            if(aRecord.BillingCity == Null)
            {
                b = 'Not Provided';      
            }
            Else
            {
                b = aRecord.BillingCity;
            }     
        }
    }
}

All Answers

souvik9086souvik9086

Add that in Button

 

<apex:page Controller="sclass6Again">
<apex:form >
    <apex:pageBlock >
   
        <apex:pageblockSection >
            <apex:pageblockSectionItem >
            <apex:outputLabel >
            Search Text :
            </apex:outputLabel>
            
            <apex:panelGroup >
            <apex:inputText value="{!SearchWord}"/>
            <apex:commandButton value="Go" Action="{!doSearch}" reRender="x">
            <apex:actionSupport event="onclick"  />
            </apex:commandButton>
            </apex:panelGroup>
            </apex:pageblockSectionItem>   
        </apex:pageblockSection>
           

               
        <apex:pageBlockSection title="Results" id="x" >
            <apex:pageBlockTable value="{!ListAcc1}" var="v">
                <apex:column value="{!v.aRecord.name}"/>
                <apex:column >
                <apex:inputCheckbox value="{!v.Check}"/>
                </apex:column>
                <apex:column value="{!v.b}"/>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
        
        </apex:pageBlock>
        
          
</apex:form>
</apex:page>

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

GuptaGupta

it is not working.

displays the list for 1 sec then disappear.

GuptaGupta

Public Class sclass6Again
{   
 
    Public String SearchWord{get;set;}
   
    List<Account> ListAcc = new List<Account>();
    List<aAccount> ListAcc1 = new List<aAccount>();
    
    
    Public List<Account> getListAcc()
    {
    
        return ListAcc;
    }
    Public List<aAccount> getListAcc1()
    {    
     
        return ListAcc1;
    }
    

    Public PageReference DoSearch()
        {
            ListAcc1.clear();
            ListAcc = [Select Id, Name, BillingCity From Account Where Name Like :('%' + SearchWord + '%')];
            For(Account acc : ListAcc)
            {
                ListAcc1.add(new aAccount(acc));   
            }
            System.debug('========== ListAcc ============' + ListAcc);
            System.debug('========== ListAcc1 ============' + ListAcc1);
            
            return null;
        }
        
        
    Public Class aAccount
    {
        Public Account aRecord{get; set;}
        Public String b{get; set;}
        Public Boolean Check{get; set;}
        
        Public aAccount(Account acc)
        {
            
            aRecord = acc;
            Check = False;
            if(aRecord.BillingCity == Null)
            {
                b = 'Not Provided';      
            }
            Else
            {
                b = aRecord.BillingCity;
            }     
        }
    }
}

This was selected as the best answer
souvik9086souvik9086

Is there any reason for adding this line?

<apex:actionSupport event="onclick"  />

 

If not please remove that.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

GuptaGupta
Yes U r right... Thanks