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
Nithin_007Nithin_007 

commandLink failed to reRender apex:include

Hello,

I am facing an issue to reRender apex:include through a commandLink, below is the part of the code

<apex:page id="mainVisualforcePg" controller="xyzController" id="vfPg1">

<apex:include pageName="menuBarVisualforcePg" id="VfPg2"/>

<apex:pageMessages id="error"/>
<apex:commandLink action="{!addToCart}" reRender="VfPg2">Add to Cart</apex:commandLink>

</apex:page>

when click on the "Add to Cart" link it try to reRender 'menuBarVisualforcePg", but after reRender the 'menuBarVisualforcePg" will disappera

So i tried putting the apex:include in apex:outputPanel - same issues

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

then i tried this
<apex:page id="mainVisualforcePg" controller="xyzController" id="vfPg1">
<script type="text/javascript">
       function reloadPage()
      {
              location.reload();
       }
</script>
<apex:include pageName="menuBarVisualforcePg" id="VfPg2"/>

<apex:pageMessages id="error"/>
<apex:commandLink action="{!addToCart}" reRender="VfPg2" oncomplete="reloadPage()">Add to Cart</apex:commandLink>

</apex:page>

This works but i do some validation in controller if commandLink action "addToCart" faills - i display error messages but  oncomplete="reloadPage()" will not show the disaplyed message

I am not able to come up with a solution to resolve this issue - any help is greatly appricated

Thanks
Nithin
Sushil KaushikSushil Kaushik
Hi Nithin,

Remove reRender attribute and Javascript  you have added. it should work in way you desired. if problem still persist than there is some problem with your controller action mentod. please paste that code.

Thanks,

Sushil
Nithin_007Nithin_007

Hi Sushil,

Java Script work by itself, the problem is when user try to add more qty than allowed to order - i display a message saying you can't add that to cart since it excides the allowed qty to order but oncomplete thing gets excuted and refreshes the page

so user will not see that error message 

the thing i am try to achive is excute oncomplete only when there is no error for that i made the following changes in the script 

<script type="text/javascript">
        function reloadPage()
        {
           
            var theControllerValue = '{!validationErrorFlg}';
            alert(theControllerValue);
            if(theControllerValue!="true")
            {
                location.reload();
            }
           
        }
    </script>

so basiclaly in controller when user click on commandlink - i am doing certain validation if that failes i am setting "validationErrorFlg" variable 

 

still its not working