0

all i have requirement where i need to show tittle along with command link in apex:pageblocksection....same as in when we create account record it shows in address information section one side tittle and another side command link ..

i am not able to call a function from my controller here is my controller

public PageReference copy_billingto_shipping() { 
    System.debug('In function'); 
    if(this.acct.BillingStreet != null) { 
        System.debug('In if condition'); 
        this.acct.ShippingStreet = this.acct.BillingStreet; 
    } 
    return null; 
}

here is vf page

<apex:page standardcontroller="Account" extensions="Account_OverrideCtrl" tabstyle="Account">
    <apex:form>
        <apex:pageblock mode="edit" id="AccountPB" title="Account Edit">
            <apex:pageblockbuttons>
                <apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
                <apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
            </apex:pageblockbuttons>
<apex:pageblocksection id="AddressInformationPBS" title="Address Information">
        <apex:facet name="header">
            <apex:outputpanel >
                <apex:outputText style="font-weight:bold;font-size:13px;float:left;" value="Address Information"/>
                    <apex:commandLink style="Float:right;" value="Copy Billing Address To Shipping Address" action="{!copy_billingto_shipping}" reRender="AddressInformationPBS"/>
            </apex:outputpanel>
        </apex:facet>
             <apex:inputfield value="{!Account.BillingStreet}"></apex:inputfield>
             <apex:inputfield value="{!Account.ShippingStreet}"></apex:inputfield>
            </apex:pageblocksection>
        </apex:pageblock>
    </apex:form>
</apex:page>
2
  • Are you able to provide some more details about what you're trying to do and what you have so far? Feb 13, 2015 at 9:27
  • Isn't the style keys case sensitive. In your command link code you use Float when it should be float. Maybe an image of what you see vs what you want would help as well
    – Eric
    Dec 29, 2015 at 6:38

2 Answers 2

2

Style elements are case sensitive . You had "Float" instead of "float"

The below copied exactly works:

<apex:page standardcontroller="Account"  tabstyle="Account">
    <apex:form >
        <apex:pageblock mode="edit" id="AccountPB" title="Account Edit">
            <apex:pageblockbuttons >
                <apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
                <apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
            </apex:pageblockbuttons>
    <apex:pageblocksection id="AddressInformationPBS" title="Address Information">
        <apex:facet name="header">
            <apex:outputpanel >
                <apex:outputText style="font-weight:bold;font-size:13px;float:left;" value="Address Information"/>
                    <apex:commandLink style="float:right;" value="Copy Billing Address To Shipping Address"  reRender="AddressInformationPBS"/>
            </apex:outputpanel>
        </apex:facet>
             <apex:inputfield value="{!Account.BillingStreet}"></apex:inputfield>
             <apex:inputfield value="{!Account.ShippingStreet}"></apex:inputfield>
            </apex:pageblocksection>
        </apex:pageblock>
    </apex:form>
</apex:page>

You will need to add back in you extension and the commandLink action when you put it back in your org

Output

2
  • Ugh, caught by the community bump an OP missing in action.....
    – Eric
    Dec 29, 2015 at 6:47
  • 1
    No. It is still useful to me though I am not OP :) Thanks for your time.
    – javanoob
    Dec 29, 2015 at 14:36
0
<apex:pageBlockSection>
    <apex:facet name="header">
        ... your html for links here ...
    </apex:facet>
</apex:pageBlockSection>

Try to format your html like this. The <facet name="header"> will replace the pageBlockSection Title content with whatever you place here. So in theory you can put your normal HTML header title left aligned and a link right aligned inside it.

A full working tested sample.

<apex:pageblock title="Page Block Title" mode="edit">
    <apex:pageblockSection>
        <apex:facet name="header">
            <table width="100%">
              <tr>
                  <td align="left"><h3>My Section Title</h3></td>
                  <td align="right">
                      <a href="javascript:alert('clicked here!!!');">Clickable Link</a>
                  </td>
              </tr>
            </table>
        </apex:facet>
    </apex:pageblockSection>
</apex:pageblock>
3
  • no sir its not working
    – Tinku
    Feb 13, 2015 at 8:40
  • hate to say it, but it does work, you just need to model your html around in the facet tag. I've edited my answer to include a full working sample.
    – VarunC
    Feb 13, 2015 at 8:52
  • Its at your convinient. You can replace standard html anchor links with visualforce <apex:commandLink> tags and add your function call to that commandLink action.
    – VarunC
    Feb 13, 2015 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.