+ Start a Discussion
anitha12anitha12 

how to refresh VF page using action attribute for a page tag

Hi,

I am using Acttion attribute in a page tag. How can I refresh My page with action attribute.Anyone pls help me.
this is my code:

public class RF_Request_DependentPicklistcontroller {

   public Id cobj {get;set;}
   public boolean popup {get;set;}
   public Id ruleId;
   public string ruleName{get;set;}
   public Cerner_Application_Change_Request__c request{get;set;}
   
//Constructor
public RF_Request_DependentPicklistcontroller(ApexPages.StandardController controller) {
    cobj = controller.getRecord().id;
    if(cobj  != null){
        request= [Select ACI_Staff_Assignee__c,Status__c,name,id,FKLOOKUP_Cerner_App_Rules__c from Cerner_Application_Change_Request__c where id =:cobj];
        ruleId = request.FKLOOKUP_Cerner_App_Rules__c ;
        if(ruleId  != null){
            ruleName = [select id,name from Cerner_Application_Change_Request_Rules__c where id=:ruleId limit 1].name;
            system.debug('ruleName ----'+ruleName );
        }
    }
}  
      
// for updating status based on Staff   
public void statusCheck(){
    Id loggeduserId = UserInfo.getUserid();
    system.debug('loggeduserId '+loggeduserId +'--request.Status__c--'+request.Status__c+'--request.ACI_Staff_Assignee__c--'+request.ACI_Staff_Assignee__c);
    system.debug('Request before update:'+request);
    if(request.Status__c == 'Pending ACI Review'){
        if(request.ACI_Staff_Assignee__c != null){
          if(loggeduserId == request.ACI_Staff_Assignee__c )
             request.status__c = 'ACI Review In Progress';  
        
    try{
         system.debug('Request after update:'+request);
         update request;
    }
   catch(DMLException e){
       system.debug('Exception while Updating Request with new rule'+e);
   }  
   
    }
    }   

}
 
}

Page:
<apex:page action="{!statusCheck}" standardController="Cerner_Application_Change_Request__c" extensions="RF_Request_DependentPicklistcontroller" sidebar="false" id="pageid" showHeader="false" rendered="true">
<script>
var newWin = null ;
function PopUpWin(url, width, height) {
    var leftPosition, topPosition;
    //Allow for borders.
    leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
    //Allow for title and status bars.
    topPosition = (window.screen.height / 2) - ((height / 2) + 50);
    //Open the window.
    newWin = window.open(url, "Window2",
    "status=no,height=" + height + ",width=" + width + ",resizable=yes,left="
    + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY="
    + topPosition + ",toolbar=no,menubar=no,scrollbars=yes,location=no,directories=no");
    newWin.focus();
}
function openUserPopup(objid){
    var url="/apex/RF_Request_Dependentpopuppage?&objectId="+objid;
    PopUpWin(url, 420, 230);
}


function refresh(objid){
    alert('TEST Parent:'+objid);
    window.top.location ='/'+objid;
   
}


</script>
<apex:form id="formid">
    <apex:panelGrid columns="2">
        <apex:outputPanel >
            <span><font color="#4A4A56"><b>Cerner Application Change Request</b></font></span><br/>
            <span style="float:right"><font color="#4A4A56"><b>Rule</b></font></span>
        </apex:outputPanel>
        <apex:outputPanel style="padding-left:25%">
        <apex:commandlink onclick="openUserPopup('{!cobj }');">
            <apex:outputText value="{!ruleName}"/>
        </apex:commandlink>
        </apex:outputPanel>
    </apex:panelGrid>         
</apex:form>
</apex:page>
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
You can do somthing like
<apex:page controller="myClass" action="{!redirect}" >

</apex:page>

/****** Controller ****/
public with sharing class myClass{
		
	public pageReference redirect(){
		PageReference pageRef = new PageReference('/objectId');
		pageRef.setRedirect(true);
		return pageRef;		
	}
}
Thanks,
N.J
anitha12anitha12
Hi NJ,

Actually It is an embedded VFpage in detail page. Already I am having logic for statusCheck method in my code. Am not able to refreshing my page after updating status field.