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
@altius_rup@altius_rup 

apex:page Header and apex:detail relatedListHover are unnecessarily related

Hi,

 

When you display a record on a VisualForce page with a standardController, its nice to get all the options available : the apex:page attribute 'tabStyle' decides which ico and color is displayed; the record's name (or number) is displayed also - as long as the showHeader attribute is true.

 

When you display more complew pages, you realize that the apex:page showHeader also impacts other part of the page - unnecessarily.

 

I'm makeing a "Master-Detail" View (that is the master-detail Design Pattern, not the Salesforce master-detail type of relation/lookup), i.e :

- a pageblock with a pageBlockTable showing a list of records (contracts)

- a pageblock with an apex:detail section showing the selected record, chosen in the table

 

Here's my VF page :

<apex:page standardController="Contract" tabStyle="Contract" extensions="ALS_ContractView_Controller" action="{!init}" id="page">

    <apex:form >
    <apex:pageBlock id="pageblock" title="Tous les contrats de {!accountName}" mode="detail">
        <apex:pageBlockTable value="{!Contracts}" var="item" rowclasses="odd,even">
            <apex:repeat value="{!ContractColumns}" var="col">
                <apex:column >
                    <apex:facet name="header">{!ContractColumnLabels[col]}</apex:facet>
                    <apex:outputPanel onMouseOver="document.body.style.cursor = 'pointer'; return true;" 
                                       onMouseOut="document.body.style.cursor = 'default'; return true;">
                                       
                        <apex:outputField value="{!item[ContractColumnNames[col]]}"/>
                        
                        <apex:actionSupport event="onclick" action="{!SelectContract}" rerender="pageblock,detail" status="status">
                            <apex:param assignTo="{!selectedContractId}" value="{!item.Id}" name="selectedI"/>
                        </apex:actionSupport>
                    </apex:outputPanel>
                </apex:column>
            </apex:repeat>
        
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
    
    <apex:pageBlock id="detail" mode="maindetail">
        <apex:detail id="theDetail"  subject="{!selectedContractId}" relatedList="true" relatedListHover="true" rendered="{!selectedContractId != NULL}"/>
    </apex:pageBlock>

</apex:page>

 

You will notice that I only display the detail if a contract is selected in the table.

 

Let's look at 2 different cases :

 

1) I start with a preselected contract (set in the controller extension's constructor).

In that case, the first time the page is displayed, the contract number and icon are displayed at the top of the page. Moreover, I get the nice hoverlist of the contract, displayed at the top of the detail pageblock, just after the pageblocktable

 

When I select another contract, the first contract number and icon don't change : that's normal, because they are displayed by the 'apex:page' which has not been rerendered.

The detail part of the page is rerendered nicey, but the relatedListHover has disappeared. *** Why ? ***

 

2) I start witout a preselected contract : selectedContractID = NULL

In that case, the first time the page is displayed, the contract number and icon do not appear : normal, I suppose.

The detail pageblock is not rendered.

 

When I select a contract in the table, I get the same behaviour as previously : the top of the page does not change (still no contract number or icon), and still no relatedListHover.

 

 

My question is : 

- how do I get the contract number of the selected contract to be displayed at the top of the page - all the time, and correctly ?

- how do I get the relatedListHover of the selected record to be displayed - all the time and correctly ?

 

 

Thanks for any ideas

Rupert

tanmay.sfdctanmay.sfdc

It's quite intriguing and puzzling, why on re-render relatedLists are disappearing :) 

 

The only workaround I can think of is a full page re-load on selection of contract while passing selectedContractId as a parameter. 

 

public void init(){
selectedContractId=ApexPages.currentPage().getParameters().get('id'); 
}

 

public PageReference SelectContract(){
PageReference pr = new PageReference('/apex/ContractTest?id='+selectedContractId);
pr.setRedirect(true);
return pr;
}