Archives for February 2011

I’m totally addicted to the new Visualforce inline editing feature. It all started with this post by Josh Birk at Developerforce. I liked it, but as a “standardstylesheets” specialist, I wanted a bit more. Then I looked at the Visualforce apex:inlineEditSupport documentation, and I was hooked. Okay, so you’re probably wondering why this is so neat. I’ll show you how to enable fields for inline editing, and then I’ll show you why the apex:inlineEditSupport tag is completely unnecessary! Here’s a simple example. You’ll notice that inline edit support has only been given to the contact.phone field. resetInlineEdit() is referenced in the code, but the actual Javascript isn’t shown anywhere. PLEASE don’t be fooled by the bad code in the documentation: It works perfectly for that “undo” arrow by the inline edit field, but it doesn’t work on the cancel button. changedStyleClass is optional. Omitting it uses the standard style we’re […]

Sometimes we have to write code that executes differently if the Apex is being tested. For a great example, check out Scott Hemmeter's blog post on testing webservice callouts at http://sfdc.arrowpointe.com/2009/05/01/testing-http-callouts/. Scott's example works well, and he uses a Boolean isApexTest, running certain code if this is true or false. I used to do something similar. The disadvantage is that one has to declare one more variable, assign a new value to it from the test code (or call a special method from the test code which, in my opinion, negatively impacts code readability), and (if you put your test code in a separate class) declare it as public. My Java professor would not like this, as he preferred to declare all variables private unless absolutely necessary. Sure, I could make a private Boolean and a getter, but now we're splitting hairs. Salesforce has come to the rescue, though, with […]