Friday, February 25, 2011

Conversion Error setting value 'value1 value2 value3' for '#{myMultiselectPicklistValue}'.

Salesforce is great. Apex is great. Visualforce is great.

Until you run into bizarre errors with no obvious explanation, such as the following error:
Conversion Error setting value 'value1 value2 value3' for '#{myMultiselectPicklistValue}'.

This error comes from trying to save the selections from an apex:selectCheckboxes component into a multi-select picklist field. You would think that it's as easy as simply specifying {!property} for the value attribute of the apex:selectCheckboxes component. But, no, it's not.

Multi-select picklist values are stored as String values, with each option delimited with a semicolon.  This is great to know, but what happens with apex:selectCheckboxes? apex:selectCheckboxes expects a List<String>! This discussion board post hints at the annoyance awaiting developers: "Checkboxes not saving".

Basically, to spell it out for myself and for others, here's what we have to do as developers working around this problem.

What we want to write is:

<apex:selectcheckboxes value="{!mPicklistValue}">
... and in the controller ...

public String mPicklistValue { get; set; }

Instead, what we have to write is:

<apex:selectcheckboxes value="{!mPicklistValues}">
... and in the overblown controller ...
private String mPicklistValue;
public List<String> getMPicklistValues() {
    List<String> values = null;
    // Convert mPicklistValue into List of 
    // String values

    if (mPicklistValue != null)
        values = mPicklistValue.split(';');

    return values;
}   // List<String> getMPicklistValues()
public void setMPicklistValues(
        List<String> values) {

    // Convert values into a semilcolon-delimited
    // String value

    if (values == null) {
        mPicklistValue = null;
    }
    else {
        mPicklistValue = '';
        
        for (String value : values) {
            mPicklistValue += value + ';';
        }
    }
}   // void setMPicklistValues(List<String>)

Note the plural name of the custom getter and setter methods. Cheers, indeed.

Tuesday, February 15, 2011

Samsung Galaxy Tab Test-drive

I had the opportunity to check out the Samsung Galaxy Tab for a few days, and I was very excited at the chance to use Android on a tablet to personally see how it stacks up against the iPad and iOS 4.

The short review:  Galaxy Tab + Android fall way, way short.  Samsung, did you pull an ostrich and just ignore the fact that the iPad has already captured the imagination and desire of the world over the past year?

Anyway, where was I...

First, the good, since the good is little:

  • Widgets.  It's nice to see things other than little grids of icons on the home screen.
  • Swype input.  Okay, it's pretty cool and revolutionary.  But what the hell is up with the way the rest of the symbol and numeric inputs are displayed?

Grab the popcorn and beer, because the next part may take a while to read.  The bad:
  • Unreliable Wi-Fi connection that works about 1 % of the time.  Really, Samsung?  Really?
  • Landscape form entry was designed by a masochist.  Who had the bright idea that when we use landscape orientation to enter data on forms that we no longer need to see the form?  Or even the label of the field into which we're typing?
  • Thick form factor.  Not appealing.
  • Typo on the setup screen relating to Wi-Fi.  See if you can find it.
  • 802.1x-secured wireless network did not appear on initial setup but did appear later in Settings.
  • Browser bug where the client gets squished into about the top 1/5 of the screen, making it impossible to change the address, see anything or open new tabs.  Basically, I had to kill the app and relaunch it to get back up and running.  If it's going to crash, just crash.  Don't make it a pain for me to relaunch the app.
  • Do I really need a Gmail account to access the Marketplace?  Is my Google Account attached to my company email address not good enough for Android?
  • And so much more that I couldn't remember it all...

Basically, if I had a choice between having a Samsung Galaxy Tab or having nothing at all, guess what I would choose...  Hint:  It's not having the Galaxy Tab.