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

Urgent Rerender Issue
Please help me with the rendered issue.I have created a page and would like to display the outputtext based on the flag in the controller, I am making a java remote call and passing a parameter to the controller based on which the flag will be set. Somehow the value is always false and the text is not displayed. This is the simplified version of code and I removed a lot of unnecessary stuff.
<apex:page sidebar="false" showHeader="false" controller="TestController">
<script type="text/javascript">
function colid(name){
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.TestController.actFlag}',name,
function(result, event){
if(event.status){
if(result == true){
}
}
},
{escape: true});
}
</script>
<apex:form >
<apex:pageBlock >
<apex:outputText >
<script type="text/javascript">
colid('Test');
</script>
</apex:outputText>
<apex:outputText value="Test" id="theValue" rendered="{!activityFlag}" />{!activityflag}
</apex:pageBlock>
</apex:form>
</apex:page>
global class TestController {
public static boolean activityflag{get;set;}
@RemoteAction
global static void actFlag(String phaseName)
{
activityflag = true;
}
}
Hi Lithiums i have seen the proplem when we reRender a componet which is haveing rendered attribue with it.
Solution
<apex:page sidebar="false" showHeader="false" controller="TestController">
<script type="text/javascript">
function colid(name){
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.TestController.actFlag}',name,
function(result, event){
if(event.status){
if(result == true){
}
}
},
{escape: true});
}
</script>
<apex:form >
<apex:pageBlock >
<apex:outputText >
<script type="text/javascript">
colid('Test');
</script>
</apex:outputText>
<apex:outputPanel id="XYZ">
<apex:outputText value="Test" id="theValue" rendered="{!activityFlag}" />{!activityflag}
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
global class TestController {
public static boolean activityflag{get;set;}
@RemoteAction
global static void actFlag(String phaseName)
{
activityflag = true;
}
}
Just reRender this panel if flag is true output text will apper otherwise it will not appear....
Thanks for you reply.
Using the javascript remote I cannot rerender, do I have to take complete different approach by calling a apex:actionfunction and rerendering the panel.
Or is there a better approach ?
Hi Litmis,
Just I saw standard document for remote action of salesforce. I come to know than we can not reRender panel using remote action.
Points are :
In general, <apex:actionFunction> is easier to use and requires less code, while JavaScript remoting offers more flexibility.
- Since we are reRendering <apex:Inputfield> so we can nor use remote action otherwise to show simple message or input field we could've you remote action like this...
But from my side i am sure we can not reRender <apex:inputField> because we are having rendered attribute with it.
hi shiva,
I have chaged the code a little bit and calling the action function and trying to rerender the outputtext, but I dont see the method being called or the flag being set to true.The script has to be inside the outputext as I am going to put that in a repeat tag and pass some values. This is the simpler version and i was having issues in setting the flag to true.
Can you please look into this as this is very urgent
<apex:page sidebar="false" showHeader="false" controller="TestController">
<script type="text/javascript">
function click(){
alert("Done");
}
</script>
<apex:form >
<apex:actionRegion >
<apex:actionFunction action="{!actFlag}" name="activityflagset" oncomplete="click()" reRender="theValue"/>
</apex:actionRegion>
<apex:pageBlock >
<apex:outputText >
<script type="text/javascript">
activityflagset();
</script>
</apex:outputText>
<apex:outputText value="Test" id="theValue" rendered="{!activityFlag}" />
</apex:pageBlock>
</apex:form>
</apex:page>
---------------------
public class TestController {
public static boolean activityflag{get;set;}
public static void actFlag()
{
activityflag = true;
}
}