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
Vinod AdminVinod Admin 

Unable to Rerender PageBlockTable

Hi Every One,

I have created a Vf page, In this when ever we mouseover the output lable it needs to rerender the pageblock table but it is not diplaying. Please help me on this,
VF:
<apex:page controller="exampleCon">
    <apex:form >
        <apex:outputpanel id="counter">
            <apex:outputText value="Click Me!: {!count}"/>
            <apex:actionSupport event="onmouseover"
                                action="{!incrementCounter}"
                                rerender="op" status="counterStatus"/>
        </apex:outputpanel>
        <apex:actionStatus id="counterStatus"
                           startText=" (incrementing...)"
                           stopText=" (done)"/>
                       
         <apex:outputpanel id="op" rendered="{!opc}">                  
            <apex:pageBlock id="pb" >
                <apex:pageBlockTable value="{!acc}" var="a">
                    <apex:column value="{!a.Name}"/>
                </apex:pageBlockTable>
           </apex:pageBlock>
       </apex:outputpanel>
    </apex:form>
</apex:page>

Controller:
/***  Controller: ***/
public class exampleCon {
    Integer count = 0;
    public boolean opc {get; set;}
    public Account acc{get; set;}
   
   public exampleCon(){
       opc=false;
   }             
    public PageReference incrementCounter() {
            opc=true;
            count++;
            display();
            return null;
    }
    public PageReference display() {
            opc=true;
             acc=[select id,Name from Account limit 1];
             system.debug('>>>>>>>xxx>>>>>>>>>>');
            return null;
    }
                    
    public Integer getCount() {
        return count;
    }
}

Please correct me where i did mistake.
Shingo YamazakiShingo Yamazaki
Hi, Venod.

I'm Shingo.

Though I haven't completely understood what you'd like to realize, this seems to work correctly.
(Just move "rendered="{!opc}"" option to "pageBlock id="pb"" )
 
<apex:page controller="exampleCon">
    <apex:form >
        <apex:outputpanel id="counter">
            <apex:outputText value="Click Me!: {!count}"/>
            <apex:actionSupport event="onmouseover"
                                action="{!incrementCounter}"
                                rerender="op" status="counterStatus"/>
        </apex:outputpanel>
        <apex:actionStatus id="counterStatus"
                           startText=" (incrementing...)"
                           stopText=" (done)"/>
                       
         <apex:outputpanel id="op">                  
            <apex:pageBlock id="pb" rendered="{!opc}"> <!-- HERE -->
                <apex:pageBlockTable value="{!acc}" var="a">
                    <apex:column value="{!a.Name}"/>
                </apex:pageBlockTable>
           </apex:pageBlock>
       </apex:outputpanel>
    </apex:form>
</apex:page>

 
Himanshu ParasharHimanshu Parashar
Hi Vinod,

There are two issues with your code so first check the correct code and then understand the issue.
 
<apex:page controller="exampleCon">
    <apex:form >
        <apex:outputpanel id="counter">
            <apex:outputText value="Click Me!: {!count}"/>
            <apex:actionSupport event="onmouseover"
                                action="{!incrementCounter}"
                                rerender="op,counter" status="counterStatus"/> <!--  counter rerender -->
        </apex:outputpanel>
        <apex:actionStatus id="counterStatus"
                           startText=" (incrementing...)"
                           stopText=" (done)"/>
                       
         <apex:outputpanel id="op" >                  
            <apex:pageBlock id="pb" rendered="{!opc}"> <!-- moved to this place -->
                <apex:pageBlockTable value="{!acc}" var="a">
                    <apex:column value="{!a.Name}"/>
                </apex:pageBlockTable>
           </apex:pageBlock>
       </apex:outputpanel>
    </apex:form>
</apex:page>

1.  Counter outputpanel id has been added so that you can see incremented counter value.
2. rendered attribute always rerender all child attribute and it doesn't rerender itself so when you put {!opc} in outputpanel op and add outputpanel id in rerender it always evaluate child element not self that is why you were not able to see the pageblock table.

Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.