Salesforce Advance Developers -501 Notes

Page 21

or custom JavaScript. The <apex:outputPanel> tag defines the area over in which we want the specialized behavior. • The <apex:actionSupport> tag defines the partial page update behavior that was implemented previously by the command link. ◊ The event attribute specifies the JavaScript event that should trigger the update.Whereas <apex:commandLink> only executes during the "onclick" event, <apex:actionSupport> can execute on any valid event such as "onclick", "ondblclick", or, for this example, "onmouseover". ◊ The reRender attribute specifies which part of the page should refresh. ◊ The <apex:param> tag sets the value of the cid query string parameter when the specified event occurs. Using JavaScript in Visualforce pages gives you access to a wide range of existing JavaScript functionality, including JavaScript libraries, and another way to customize the functionality of your pages.By including JavaScript in a page, you are introducing the possibility of cross-browser and maintenance issues that you do not have when using Visualforce. Before writing any JavaScript, you should be sure that there is not an existing Visualforce component that can solve your problem. Describe and incorporate proper error handling techniques. <apex:pageBlock mode="edit" id="thePageBlock"> <apex:pageMessages /> <apex:pageBlockButtons > As mentioned earlier, you should always include a pageMessages component in all your Visualforce pages, public PageReference save() { if (PositionTypeID == 'other') { try{ newPositionType.Department__c = position.Department__c; insert newPositionType; position.Position_Type__c = newPostionType.ID; } catch (DmlException e) { ApexPages.addMessages(e) } } else { Position.Position_Type__c = positionTypeID; } return theController.save(); } Whenever an exception is thrown in the code_block immediately following the keyword try, the execution drops out of that block. There are different types of Force Platform exceptions so you can have more than one catch block, with no more than one catch block for a particular type of exception. You can also define your own exception types. The code_block for a particular exception type is executed when an exception of that type is thrown. You can also specify the general exception type of Exception, catching any exceptions not intercepted by previous catch statements–because of this, a catch statement that uses the general Exception must be the last catch statement in the block. Once the code for the appropriate catch block runs, the code_block listed for the finally statement is run. The finally statement is not required. Describe the benefits, functions, and features of Visualforce and how it conforms to the model-view-controller pattern. Visualforce technology provides a means for developers to create any type of browser-based user interface, interacting with any combination of data, in your on-demand Force Platform applications. You can create user interfaces with a simple tag-based syntax, similar to HTML,


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.