You need to sign in to do that
Don't have an account?
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;
}
}
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
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
I don't understand your requirement I'm afraid. Can you explain what you are trying to do and what the issue is?
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>
I guess here is the mistake
<apex:outputpanel id="countertest" rendered="{!isFlagRendered == true}">
Is your solution is resolved??
If i can expalin o.w let me know.
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
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>