Friday, January 23, 2009

Salesforce Development Lesson Of The Day

I'm doing some Salesforce.com dev at a large NZ insurance company. Development as a Service can be monumentally frustrating, especially when sitting behind flaky (it's a euphemism) proxy servers, but I'm learning heaps about Client-Server development, about html, javascript and also the less transferable skills of VisualForce and Apex...


Today's lesson was a good 'un. We use wizards a lot to gently guide the users through their data-entry, and we have a 'PopupWizard' component that we use to load up the pages. Actually what happens is that the pages get rendered within a parent page as a div, and the PopupWizard component controls the page-navigation (nice...)


Now, Apex provides a couple of 'table' controls to present sets of data, including the PageBlockTable control which looks a bit like this:



One would then need to write a method on the server-side controller, called getMyAccounts() which should return a collection of objects. In this example it would probably return Account[]. The table then contains some number of columns, and we tell the page which data (from the Account object) lives in which column via the 'item' which is defined in the attribute 'var'.


Awesomely simple, eh?



What I learned today (eventually) was this: When you have two DataTables in the same wizard, even if they are in completely separate pages, you cannot call the 'var' attribute by the same name!!!


So now you know...