Monday, September 9, 2013

VisualForce Workbook


Static  Resource Components

    • Type of salesforce storage
    • designed to be used on visualforce pages.
    • Examples - javascripts, css, images etc
    • referenced using $Resource global variable
    • Are uploaded via Your Name|Setup|Develop|Static Resources
    • can be contained in an archive (zip)
    • limited to 5 MB per file and a 250 mb overall
    • use action attribute to redirect 


Dependent Picklist Considerations

  • There’s a limit of 10 dependent picklist pairs per page. This is totalled across all objects. Thus, you could have five dependent picklists on Account, and five on Contact, but no more. However, you can repeat the same pair of dependent picklists, such as in an iterative tag like <apex:repeat>, without counting more than once against your limit.
  • If the user viewing the page has read-only access to the controlling field, a dependent picklist might not behave as expected. In this case, the dependent picklist shows all possible values for the picklist, instead of being filtered on the read-only value. This is a known limitation in Visualforce.
  • Don’t mix inline edit-enabled fields with regular input fields from the same dependency group. For example, don’t mix a standard input field for a controlling field with an inline edit-enabled dependent field:
    <apex:page standardController="Account">
        <apex:form>
            <!-- Don't mix a standard input field... -->
            <apex:inputField value="{!account.Controlling__c}"/>
            <apex:outputField value="{!account.Dependent__c}">
                <!-- ...with an inline-edit enabled dependent field -->
                <apex:inlineEditSupport event="ondblClick" />
            </apex:outputField>
        </apex:form>
    </apex:page>


Visualforce Dashboard Components

  • Each dashboard can have up to 20 components.
  •  Visualforce pages that use the Standard Controller can’t be used in dashboards.
  • To be included in a dashboard, a Visualforce page must have either no controller; use a custom controller; or reference a page bound to the StandardSetController Class.   If a Visualforce page does not meet these requirements, it does not appear as an option in the dashboard componentVisualforce Page drop-down list.


Enabling Inline Editing


  • Components that support inline editing must always be descendants of the <apex:form> tag. However, the <apex:detail> component doesn’t have to be a descendant of an <apex:form> to support inline editing.
  •  The <apex:inlineEditSupport> component must be a descendant of the following components:
  • <apex:dataList>
  • <apex:dataTable>
  • <apex:form>
  • <apex:outputField>
  • <apex:pageBlock>
  • <apex:pageBlockSection>
  • <apex:pageBlockTable>
  • <apex:repeat>


  • The following are cases when inline editing isn’t supported.
    • Inline editing isn’t available in:
      • Accessibility mode
      • Setup pages
      • Dashboards
      • Customer Portal
      • Descriptions for HTML solutions

    • The following standard checkboxes on case and lead edit pages are not inline editable:
      • Case Assignment (Assign using active assignment rules)
      • Case Email Notification (Send notification email to contact)
      • Lead Assignment (Assign using active assignment rule)

    • The fields in the following standard objects are not inline editable.
      • All fields in Documents and Pricebooks
      • All fields in Tasks except for Subject and Comment
      • All fields in Events except for Subject, Description, and Location
      • Full name fields of Person Accounts, Contacts, and Leads. However, their component fields are, for example, First Name and Last Name.

    • You can use inline editing to change the values of fields on records for which you have read-only access, either via field-level security or your organization's sharing model; however,Salesforce doesn't let you save your changes, and displays an insufficient privileges error message when you try to save the record.

    • You can use inline editing to change the values of fields on records for which you have read-only access, either via field-level security or your organization's sharing model; however,Salesforce doesn't let you save your changes, and displays an insufficient privileges error message when you try to save the record.

    • Inline editing isn’t supported for standard rich text area (RTA) fields, such as Idea.Body, that are bound to <apex:outputField> when Visualforce pages are served from a separate domain, other than the salesforce.com domain. By default, Visualforce pages are served from a separate domain unless your administrator has disabled this setting. Custom RTA fields aren’t affected by this limitation and support inline editing.

    • Inline editing is supported for dependent picklists that use <apex:outputField>.
  • Pages must include the controlling field for a dependent picklist. Failing to include the controlling field on the page causes a runtime error when the page displays.


Rendering a Page as a PDF

Things to note about using renderAs:
  • Currently, PDF is the only supported content converter.
  • Rendering a Visualforce page as a PDF is intended for pages that are designed and optimized for print.
  • Standard components which are not easily formatted for print or contain form elements like inputs, buttons, and any component that requires JavaScript to be formatted, shouldn’t be used. This includes but isn’t limited to any component that requires a form element.
  • PDF rendering doesn’t support JavaScript-rendered content.
  • Verify the format of your rendered page before deploying it.
  • If the PDF fails to display all the characters, adjust the fonts in your CSS to use a font that supports your needs. For example:
    <apex:page renderas="pdf">
    <html>
      <head> 
        <style> body { font-family: Arial Unicode MS; } </style> 
      </head>
      This page is rendered as a PDF
    </html>
    </apex:page>
  • The maximum response size when creating a PDF must be below 15 MB, before being rendered as a PDF. This is the standard limit for all Visualforce requests.
  • The maximum file size for a generated PDF is 60 MB.
  • The total size of all images included in a generated PDF is 30 MB.
  • PDF rendering doesn’t support images encoded in the data: URI scheme format.
  • Note that the following components do not support double-byte fonts when rendered as a PDF:
    • <apex:pageBlock>
    • <apex:sectionHeader>
    These components are not recommended for use in pages rendered as a PDF.


  • The <apex:pageBlockTable> component automatically takes on the styling of a standard Salesforce list. To display a list with your own styling, use<apex:dataTable> instead. 

  •  You cannot use the reRender attribute to update content in a table in AJAX behaviour. 

Styling Pages that Use Standard Controllers

For example, the following page uses the Account standard controller, but renders a page that highlights the Opportunities tab and uses the Opportunity tab's yellow coloring:
<apex:page standardController="Account" tabStyle="Opportunity">
</apex:page>
  • To use the styling associated with MyCustomObject:
<apex:page standardController="Account" tabStyle="MyCustomObject__c">
</apex:page>
  • To use the styling associated with a custom Visualforce tab, set the attribute to the name (not label) of the tab followed by a double-underscore and the word tab. For example, to use the styling of a Visualforce tab with the name Source and a label Sources, use:
<apex:page standardController="Account" tabStyle="Source__tab">
</apex:page>
  • Alternatively, you can override standard controller page styles with your own custom stylesheets and inline styles.


--> To check if you have access to the standard Lead object, use the following code:
{!$ObjectType.Lead.accessible}

--> To ensure that a portion of your page will display only if a user has access to an object, use the render attribute on a component. For example, to display a page block if a user has access to the Lead object, you would do the following:

<apex:page standardController="Lead">
 <apex:pageBlock rendered="{!$ObjectType.Lead.accessible}">
  <p>This text will display if you can see the Lead object.</p>
 </apex:pageBlock>
 <apex:pageBlock rendered="NOT({!$ObjectType.Lead.accessible})">
  <p>Sorry, but you cannot see the data because you do not have access to the Lead object.</p>
 </apex:pageBlock>
</apex:page>


--> When using a standard list controller, the returned records sort on the first column of data, as defined by the current view, even if that column is not rendered. When using an extension or custom list controller, you can control the sort method.

--> No more than 10,000 records can be returned by a standard list controller. Custom controllers can work with larger results sets

--> By default, a list controller returns 20 records on the page. To control the number of records displayed on each page, use a controller extension to set thepageSize. 


--> Although custom controllers and controller extension classes execute in system mode and thereby ignore user permissions and field-level security, you can choose whether they respect a user's organization-wide defaults, role hierarchy, and sharing rules by using the with sharing keywords in the class definition 


--> Multiple controller extensions can be defined for a single page through a comma-separated list. This allows for overrides of methods with the same name.  
For example, if the following page exists:
<apex:page standardController="Account" 
    extensions="ExtOne,ExtTwo" showHeader="false">
    <apex:outputText value="{!foo}" />
</apex:page>


 with the following extensions:
public class ExtOne {
    public ExtOne(ApexPages.StandardController acon) { }

    public String getFoo() {
        return 'foo-One';
    }
}
public class ExtTwo {
    public ExtTwo(ApexPages.StandardController acon) { }

    public String getFoo() {
        return 'foo-Two';
    }
}
The value of the <apex:outputText> component renders as foo-One. Overrides are defined by whichever methods are defined in the “leftmost” extension, or, the extension that is first in the comma-separated list. Thus, the getFoo method of ExtOne is overriding the method of ExtTwo. 
Like other Apex classes, controller extensions run in system mode. Consequently, the current user's credentials are not used to execute controller logic, and the user's permissions and field-level security do not apply. However, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it executes in user mode, in which the permissions, field-level security, and sharing rules of the current user apply.


1 comment:

  1. Really appreciated information and please keep sharing, I would like to share some information regarding online training.
    MAXMUNUS SOLUTIONS offer an extensive curriculum of instructor-led education options, from in-person classes with hands-on instruction to private workshops, custom training, and more, and technical designers, our training covers every key role for every Salesforce product.
    Maxmunus Solutions is providing the best online salesforces cloud computing training.

    For Joining online training batches please feel free to call or email us.
    Name : Minati
    Email: minati@maxmunus.com
    Skype id- training_maxmunus
    Contact No.-+9066638196/91-9738075708
    Company Website:- http://www.maxmunus.com/page/Salesforce-Certification-Training

    ReplyDelete