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
RiyaRiya 

issue in rendered attribute

i have created a VF page with three components.

On the action support event even though specifically i have given which component to rerender all the components with rendered attribute is recalculated.

Whether this is the expected behaviour?

 

 

<apex:page controller="exampleCon">
<apex:form >
<apex:actionRegion >
<apex:outputPanel id="counter">
    <apex:outputText value="Click Me!: {!count1}" />
        <apex:actionsupport event="onclick" action="{!incrementCounter}" rerender="countertest1" status="counterStatus" />
    </apex:outputPanel>
</apex:actionRegion>
 
<apex:outputpanel id="countertest" rendered="{!isFlagRendered}">                                 
{!count2}
</apex:outputpanel>

<apex:outputpanel id="countertest1" >                                 
{!count1}
</apex:outputpanel>

</apex:form>
</apex:page>


-------------------------------------------------------------------------------------------------------------------

public class exampleCon {
public boolean isFlagRendered{get;set;}
Integer count1 = 0;
Integer count2 = 0;
public Integer getCount1() {
    return count1;
}
public Integer getCount2() {
    return count2;
}


public PageReference incrementCounter() {
count1++;
return null;
}

}

bob_buzzardbob_buzzard

This is correct behaviour - you can't rerender something that wasn't there in the first place.

 

I've described this in detail in the following blog post:

 

http://bobbuzzard.blogspot.co.uk/2011/02/visualforce-re-rendering-woes.html

RiyaRiya

Sorry,  i didn't get u.

 

In the action support i have specified to  rerender="countertest1" component Id,but the attribute  value of  id="countertest" is also recalculated..

so in a VF page if i have 100 components  with rendered attribute all this values will be calculated for each action event.that means 100 getter functions..

 

Plz clarify...

 

Thanks in advance

bob_buzzardbob_buzzard

I don't understand your requirement I'm afraid.  Can you explain what you are trying to do and what the issue is? 

jd123jd123

Hi try this code

 

   

<apex:page controller="exampleCon">
<apex:form >
<apex:actionRegion >
<apex:outputPanel id="counter">
    <apex:outputText value="Click Me!: {!count1}" />
        <apex:actionsupport event="onclick" action="{!incrementCounter}" rerender="countertest1" status="counterStatus" />
    </apex:outputPanel>
</apex:actionRegion>
<apex:outputPanel id="countertest">
<apex:outputpanel id="countertest123" rendered="{!isFlagRendered}">                                 
{!count2}
</apex:outputpanel>

</apex:outputpanel>

<apex:outputpanel id="countertest1" >                                 
{!count1}
</apex:outputpanel>

</apex:form>
</apex:page>

 

neeedhelpneeedhelp

I guess here is the mistake

 

<apex:outputpanel id="countertest" rendered="{!isFlagRendered == true}">

jd123jd123

Is your solution is resolved??

 

If i can expalin o.w let me know.

BharathimohanBharathimohan

Hi Riya,

 

Checked your code, and found that only count1 is increasing and count2 remains zero, after every click.

Hope this is what you're expecting, and it works fine.

 

In case, if you want to rerender a component which is not rendered at the first time of page load due to rendered=false, we cannot rerender it anymore. If this is your issue, Check out Bob blog post for further info.

 

 

 

Regards,

Bharathi
Salesforce For All

RiyaRiya

In the actionsupport i am calling id "Countertest1", but the  rendered attribute  of Id countertest is recalculated  for that action event.

why that attribute value is recalculated?

 

<apex:actionRegion >
<apex:outputPanel id="counter">
    <apex:outputText value="Click Me!: {!count1}" />
        <apex:actionsupport event="onclick" action="{!incrementCounter}" rerender="countertest1" status="counterStatus" />
    </apex:outputPanel>
</apex:actionRegion>
 
<apex:outputpanel id="countertest" rendered="{!isFlagRendered}">                     

            
{!count2}
</apex:outputpanel>

<apex:outputpanel id="countertest1" >                                 
{!count1}
</apex:outputpanel>