You need to sign in to do that
Don't have an account?

Rerender Visualforce Dynamic Component
Hi all,
I'm trying to rerender a visualforce dynamic component in my visualforce page on the onclick button event: I tried with a remote action on a button tag element (I'd like to avoid the form element on Vf page for view state problems) and it didn't work; so I tried with an apex button element, too, but no luck: can anyone help me? thanks
This is the code:
- Controller:
- Vf page:
I'm trying to rerender a visualforce dynamic component in my visualforce page on the onclick button event: I tried with a remote action on a button tag element (I'd like to avoid the form element on Vf page for view state problems) and it didn't work; so I tried with an apex button element, too, but no luck: can anyone help me? thanks
This is the code:
- Controller:
public class provaController{
public boolean var{get; set;}
public integer count;
public provaController(){
var = false;
count = 0;
}
public void add(){
var = true;
}
public Component.Apex.OutputText getThePanel() {
system.debug('****panel');
count++;
String stringaFinale = '<p>first call</p>';
if(count>1) stringaFinale = stringaFinale + '<p>second call</p>';
Component.Apex.OutputText outTextGlobal = new Component.Apex.OutputText();
outTextGlobal.value = stringaFinale;
outTextGlobal.escape = false;
stringaFinale = null;
return outTextGlobal;
}
@RemoteAction
global static void click() {
system.debug('****remote');
}
}
public boolean var{get; set;}
public integer count;
public provaController(){
var = false;
count = 0;
}
public void add(){
var = true;
}
public Component.Apex.OutputText getThePanel() {
system.debug('****panel');
count++;
String stringaFinale = '<p>first call</p>';
if(count>1) stringaFinale = stringaFinale + '<p>second call</p>';
Component.Apex.OutputText outTextGlobal = new Component.Apex.OutputText();
outTextGlobal.value = stringaFinale;
outTextGlobal.escape = false;
stringaFinale = null;
return outTextGlobal;
}
@RemoteAction
global static void click() {
system.debug('****remote');
}
}
- Vf page:
<apex:page controller="provaController" id="idController" >
<div id="provaDiv" >
<apex:dynamicComponent componentValue="{!thePanel}" invokeAfterAction="true"/>
</div>
<apex:form >
<apex:commandButton action="{!add}" value="button" id="theButton" reRender="idController,provaDiv"/>
</apex:form>
</apex:page>
<div id="provaDiv" >
<apex:dynamicComponent componentValue="{!thePanel}" invokeAfterAction="true"/>
</div>
<apex:form >
<apex:commandButton action="{!add}" value="button" id="theButton" reRender="idController,provaDiv"/>
</apex:form>
</apex:page>
I would say Add a new outputPanel and that should fix the issue.
Then just change the method in the controller.
That should do the trick.
An outputPanel its the same as using a HTML div,or span and its the component that should be used when you need AJAX Refreshes, so you can also change the <div id="provaDiv" > that you have for an <apex:outputPanel>
Please let me know how it goes.
Regards,
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
All Answers
FYI : I added $Component
I would say Add a new outputPanel and that should fix the issue.
Then just change the method in the controller.
That should do the trick.
An outputPanel its the same as using a HTML div,or span and its the component that should be used when you need AJAX Refreshes, so you can also change the <div id="provaDiv" > that you have for an <apex:outputPanel>
Please let me know how it goes.
Regards,
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.