+ Start a Discussion
cduncombe44cduncombe44 

ReRender issue with tab events....

I am having the hardest time getting this to work.  I have created a tabbed view page for contacts.  One of these tabs shows a list of interventions (custom object).  I have made these into output links that cause a partial page refresh to show the details of the intervention that was clicked.  This works great and I am happy.  Except that when the user navigates to a different tab, and then returns to the interventions tab, the last intervention that was choosen is still being rendered. 

 

I have been toiling over how to 'Clear' this output panel that holds the deatils using tab events but havent had any luck.  This is what I have....

 

VF Page....

 

<apex:tab label="Interventions" name="Interventions" id="tabInterventions" onTabEnter="resetIntTab" ontableave="resetIntTab" onclick="resetIntTab">
        <apex:form >
        
        <apex:actionFunction immediate="true" name="resetIntTab" action="{!resetIntTab}" reRender="intPanelContainer,interventionBlock" />
        
        <apex:pageBlock >
        <apex:facet name="header">
                <apex:dataTable columns="2" rows="1" value="{!Contact}" var="i" style="margin-top:3px;">
                    <apex:column style="width:360px;">
                    <apex:outputText value="Interventions" style="font-weight:bold; font-size:small"></apex:outputText>
                    </apex:column>
                    <apex:column >
                        <apex:outputLink value="{!interventionPageRef}" styleClass="btn" style="text-decoration:none">
                        	New Intervention<apex:param name="00Nd000000308OV" value="{!contact.id}"/>                          
                        </apex:outputLink>
                    </apex:column>
                </apex:dataTable>
            </apex:facet>
            <apex:dataTable value="{!MyInterventions}" var="int" columns="4" style="width:800px; border:1px solid #D4DADC;" rules="rows" cellpadding="3px;3px;" id="myInts">
                <apex:column headerClass="myHead" >
                <apex:facet name="header"><b>Intervention</b></apex:facet>
                    <apex:commandLink action="{!invokeService}"
                                      value="{!int.name}"
                                      rerender="intPanelContainer">
                        <apex:param name="cid" value="{!int.id}"/>
                    </apex:commandLink>

                </apex:column>
                
                <apex:column headerValue="Intervention Type" headerClass="myHead">
                    {!int.recordtype.name}
                </apex:column>
                
                <apex:column headerValue="Status" headerClass="myHead">
                    {!int.Status__c}
                </apex:column>              
                
                <apex:column headerValue="Current Stage" headerClass="myHead">
                    {!int.Current_Stage__c}
                </apex:column>
                
            </apex:dataTable>          
         
        </apex:pageBlock>
        </apex:form>
        
        
        
            <apex:form >
            <apex:outputPanel id="intPanelContainer">
            <apex:pageBlock title="{!fetchedData.Name}" tabStyle="Intervention__c" mode="inlineEdit" id="interventionBlock" rendered="{!NOT(ISNULL(fetchedData))}">
            
                
                <apex:pageBlockButtons location="top" rendered="{!NOT(ISNULL(fetchedData))}">  
                    <apex:commandButton action="{!saveInterventionChanges}" id="saveButton" value="Save" rerender="intPanelContainer,myInts"/>  
                    <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>  
                </apex:pageBlockButtons>  
                
                <apex:outputpanel id="intPanel" rendered="{!NOT(ISNULL(fetchedData))}">  
                       <apex:pageBlockSection columns="2" title="Intervention Details">
                           <apex:outputField value="{!fetchedData.Name}"/>                           
                           <apex:inputField value="{!fetchedData.Status__c}"/>                               
                           <apex:outputField value="{!fetchedData.RecordType.Name}" label="Type"/>
                           <apex:outputField value="{!fetchedData.Current_Stage__c}"/>
                           <apex:outputField value="{!fetchedData.Contact__c}"/>
                       </apex:pageBlockSection>
                       
                       <apex:pageBlockSection columns="2" title="Intervention Age">
                           <apex:outputField value="{!fetchedData.Enrollment_Start__c}"/>
                           <apex:outputField value="{!fetchedData.Enrollment_End__c}"/>
                           <apex:outputField value="{!fetchedData.Time_on_Current_Stage__c}"/>
                           <apex:outputField value="{!fetchedData.Total_Time_on_Enrollment__c}"/>
                       </apex:pageBlockSection>
                       
                        <apex:pageBlockSection columns="2" title="Intervention Stages" rendered="{!isInsEnroll}">
                           <apex:outputField value="{!fetchedData.Ins_Stage_1_Completion__c}"/>
                           <apex:outputField value="{!fetchedData.Ins_Stage_1_Completed_by__c}"/>
                            <apex:outputField value="{!fetchedData.Ins_Stage_2_Completion__c}"/>
                           <apex:outputField value="{!fetchedData.Ins_Stage_2_Completed_by__c}"/>
                            <apex:outputField value="{!fetchedData.Ins_Stage_3_Completion__c}"/>
                           <apex:outputField value="{!fetchedData.Ins_Stage_3_Completed_by__c}"/>
                            <apex:outputField value="{!fetchedData.Ins_Stage_4_Completion__c}"/>
                           <apex:outputField value="{!fetchedData.Ins_Stage_4_Completed_by__c}"/>
                            <apex:outputField value="{!fetchedData.Ins_Stage_5_Completion__c}"/>
                           <apex:outputField value="{!fetchedData.Ins_Stage_5_Completed_by__c}"/>
                            <apex:outputField value="{!fetchedData.Ins_Stage_6_Completion__c}"/>
                           <apex:outputField value="{!fetchedData.Ins_Stage_6_Completed_by__c}"/>
                       </apex:pageBlockSection>
                       
                       <apex:pageBlockSection columns="2" title="Intervention Stages" rendered="{!isFinEnroll}">
                           <apex:outputField value="{!fetchedData.Ins_Stage_2_Completion__c}"/>
                           <apex:outputField value="{!fetchedData.Ins_Stage_2_Completed_by__c}"/>
                       </apex:pageBlockSection>
                </apex:outputpanel>
                        
            </apex:pageBlock>
            </apex:outputPanel>
            </apex:form>
        
        
    </apex:tab> 

 

Controller Extension....

 

public class tabbedContactExtension {

    private List<Contact> members;
    private List<Intervention__c> myInts;
    private Member_Profile__c myProf;
    private Contact cntact; 
    public Intervention__c result;
    public string recType;    
    
    public tabbedContactExtension(ApexPages.StandardController controller) {
        this.cntact= (Contact)controller.getRecord();
        
    }
       
    public List<Contact> getMembers()
    {
        Contact con = [Select id, npo02__Household__r.id FROM Contact where id = :cntact.id];
        members = [Select id, Household_Role__c, Name, Birthdate, HomePhone from Contact where npo02__Household__r.id = :con.npo02__Household__r.id];
        return members;
    }    
    
    public Member_Profile__c getProfile()
    {
        myProf = [Select id, name, Total_Savings__c, Total_Cost__c, Contact__c FROM Member_Profile__c where Contact__c = :cntact.id];
        return myProf;
    }
    
    public List<Intervention__c> getMyInterventions()
    {
        myInts = [select Name, id, recordtype.name, Status__c, Current_Stage__c from Intervention__c where Contact__c =:cntact.id];
        return myInts;
    }
    
    public Intervention__c getFetchedData(){
    
        return result;
        
    }
    
    public void resetIntTab() {    	
    	result = null;
    }
    
    public void invokeService() {

        Id id = System.currentPageReference().getParameters().get('cid');
        result = [SELECT Name, Current_Stage__c, Contact__c, RecordType.Name, Status__c, Enrollment_Start__c, 
                  Enrollment_End__c, Time_on_Current_Stage__c, Total_Time_on_Enrollment__c,
                  Ins_Stage_1_Completion__c, Ins_Stage_2_Completion__c, Ins_Stage_3_Completion__c,
                  Ins_Stage_4_Completion__c, Ins_Stage_5_Completion__c, Ins_Stage_6_Completion__c,
                  Ins_Stage_1_Completed_by__c, Ins_Stage_2_Completed_by__c, Ins_Stage_3_Completed_by__c,
                  Ins_Stage_4_Completed_by__c, Ins_Stage_5_Completed_by__c, Ins_Stage_6_Completed_by__c FROM Intervention__c WHERE id=:id];

        recType = result.RecordType.Name;
               
    }
    
    
    
    public pageReference saveInterventionChanges()
    {        
        UPDATE result;        
        return null;
    }
    
    public PageReference getInterventionPageRef()
    {
        return System.Page.Intervention;        
    }

 

As you can see I have tried to add my actionfunction to every tab event that I thought was relevant, but still it does nothing.  Am I wrong to think that all I have to do is set my controller variable 'result' to NULL.  After all it gets set to null, and then getFetchedData() is returning result, so it should be returning NULL and thus my output panel is looking at that in its rendered property.  

 

Please help as I just can;t seem to see where I am going wrong.  Thanks in advance.

 

Chris