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
t.deepthi05t.deepthi05 

Visual Force Page Refresh

Hi,

 

Can I know how to refresh the entire Visual force or Part of the page when a component is modified(i.e. when a command link action is performed by the component).

 

Thanks & Regards

DipakDipak

You can do that by specifying "rerender=xxx" on commandbutton or link..
here xxx is the ID of a section in VF say pageblock or so

DipakDipak
If you need for entire page the
do like
<apex:commandLink value="click here to refresh" onclick="window.location.href='/apex/VFPageName" />
t.deepthi05t.deepthi05

How can i rerender the id of vf page in the component on button click

t.deepthi05t.deepthi05

I added the onclick action in the command link but it didnt work

DipakDipak

To rerender a portion of the page do some thing like

<apex:pageBlock title="New" mode="edit" id="newPageBlock">
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!add}" rerender="newPageBlock" status="myStatus"/>
            
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="new data" columns="1">
<!- Write your code here </apex:pageBlockSection>
<apex:actionStatus startText=" Reloading" id="myStatus"/>
</apex:pageBlock>
t.deepthi05t.deepthi05

My requirement is I have command link in apex:component and I am using that component  in my vf page.

 

When I perform an action by clicking the link I want rerender an outputpanel of VF page automatically.

ezdhanhussainezdhanhussain

Code provided by dipak is one way to do.You can  also do this by initializing a boolean data type. supply this boolean variable to the output panel you want to,default value of boolean variable is false so it is in hidden state. on click/action the variable value should change to true, which displays the output panel

Tablevisible=false;
public boolean Tablevisible { get; set; }
<apex:CommandLink value="display" action  ="{!dis}" rendered="{!Tablevisible}"/>

 Above code is not the exact one, it is just for your reference.

t.deepthi05t.deepthi05

I have the command link in the component I am referring the component in my page and on click the rerender the page and refresh the content of the page.

 

On click it deletes the records and have refresh the page content

 

Sonali BhardwajSonali Bhardwaj

I tried to implement your requirement.

Below is code

Component - MyComp:

<apex:component>
    <apex:attribute name="idOfSection" required="true" type="string" description="Id of the section which needs to be rerender."/>
    <apex:commandLink onclick="alert('Clicked, now rerendering page section!!')" reRender="{!idOfSection}" value="Click This !!"/>
</apex:component>

 Page:

<apex:page id="myPage">
    <apex:form>
        <c:MyComp idOfSection="myPage:myPanel"/>
    </apex:form>
    
    <apex:outputPanel id="myPanel">
        <script>
            alert('This is Rendered');
        </script>
    </apex:outputPanel>
</apex:page>

 

If this post is helpful please throw Kudos. If this post solves your problem mark it as solution.

t.deepthi05t.deepthi05

The panel is rerender but the values are not getting updated in the page until i manually refresh the page again or performing an action again on the list. The list contains check box field which has to unchecked on performing the action using command link

ezdhanhussainezdhanhussain

Can you post your code so that we can go through it  ?

t.deepthi05t.deepthi05

I am posting a sample code below

 

<apex:component controller="componentcontroller">

<attribute .....>

<apex:comandLink value="{somevalue}" action="{sample}"/>

</apex:Component>

 

<apex:page controller="PageController">

<c.Component>

<apex:repeat  value="{Hello}" var="h"  id="repeat"/>

</apex:repeat>

</apex>

 

i want to rerender  the above repeat panel on click on command link 

 

i able to rerender but unable get the updated values in the list until i refresh the page manually.

Sonali BhardwajSonali Bhardwaj

You can try below code.

 

Class:

public class myClass {
   public myClass() {
       values = new List<String>();
       values.add('Before On Click');
   }
    
   public static List<String> values {get; set;}
   
   public static void onClick() {
       values = new List<String>();
       values.add('After On Click');
   }
}

 

Component:

<apex:component controller="myClass">
    <apex:attribute name="idOfSection" required="true" type="string" description="Id of the section which needs to be rerender."/>
    <apex:commandLink action="{!onClick}" reRender="{!idOfSection}" value="Click This !!"/>
</apex:component>

 

Page:

<apex:page id="myPage" controller="myClass">
    <apex:form >
        <c:MyComp idOfSection="myPage:myPanel"/>
    </apex:form>
    
    <apex:outputPanel id="myPanel">
        <apex:repeat  value="{!values}" var="val">
            <apex:outputText value="{!val}" />
        </apex:repeat>
    </apex:outputPanel>
</apex:page>

 

If this post is helpful please throw Kudos. If this post solves your problem mark it as solution.

Anh Tran 43Anh Tran 43
To Reload a salesforce page after running the visual force page

<apex:page standardController="Drawing__c">  
    <flow:interview name="Update_Drawing_Name_To_Each_Item">
...
    </flow:interview>
    <script>
        self.close();
        window.parent.location.href='/{!Drawing__c.Id}';
    </script>

</apex:page>