Friday, December 7, 2012

Applying CSS to a Visualforce apex:selectOption

I had a customer requirement to put some CSS formatted labels on some radio buttons in a Visualforce page. The markup was already using an <apex:selectOption> within a <apex:selectRadio>. I didn't want to revert to raw HTML controls as there was a <apex:actionSupport> already in use.

Using the style or styleClass to apply the CSS to the selectOption didn't work as they were deprecated in Salesforce API version 17.0.

Instead I created a property in the controller that returned the required HTML markup and set itemEscaped="false" on the selectOption.

E.g.:

Page:

    <apex:selectRadio layout="pageDirection" value="{!controllerflag}" rendered="{!(!addingNew)}">
        <apex:actionSupport action="{!getData}" status="addItem" event="onclick" rerender="somePageBlock">
            <apex:param name="selectedId" value="{!elementId}"/>
        </apex:actionSupport>
        <apex:selectOption itemLabel="{!radioSelectLabel}" itemEscaped="false" itemValue="true" >
        </apex:selectOption>
    </apex:selectRadio>

Controller:

    public string radioSelectLabel {
        get {
            if (hasBeenCancelled) {
                return '<span style="color:red;">(Cancelled)</span>';
            }
            return 'Available';
        }
    }

Friday, November 30, 2012

Windows Phone 8 Emulator issues in Visual Studio 2012

I haven't had much luck to date getting up and running with the WP8 SDK for Visual Studio 2012. When I attempt to start the emulator I get the message:

The connection to the virtual machine has been lost. The virtual machine may have been turned off by another application. The Windows Phone Emulator must close.

After this has occurred, attempts to restart the emulator produce the following error:

The Windows Phone Emulator wasn't able to set some properties on the virtual machine:

Couldn't change Memory of the virtual machine: Error code 32775

I have a 64-bit Intel i7 processor with virtualization enabled in the bios. Hyper-V is installed. I have more than enough memory (32 GB).


Solution

I found my specific issue. The VPN software that I had installed was preventing the local VM connection, even when it wasn't actively running. Uninstalling it resolved the issue.

The response from the VPN provider indicated the issue was with the Layered Service Providers:

It seems the problem is with incompatibility of LSPs (Layered Service Providers) - [VPN Name] uses a LSP to redirect traffic as well as Hyper-V software.

See Also:

Salesforce convert Apex integer to long

A quick snippet after I came across the following when modifying some apex:

integer someId = 12345;
aMethodThatTakesALong(Long.valueOf(someId.format()));

Note the transition via an intermediate string to get to the long required by the method.

Usually Apex will implicitly convert an integer to a long if required. E.g.

Integer testInt = 12345;
Long testLong = testInt;
System.assertEquals(12345L, testLong);

In the case of the method parameter above you can either rely on the implicit casting or, where there may be other overrides available, explicitly cast the integer to a long. E.g.

integer someId = 12345;
aMethodThatTakesALong((long)someId);

Tuesday, October 30, 2012

Salesforce - Unable to uninstall package due to page layouts

Uninstalling a package from a Salesforce org failed recently due to references from profiles to page layouts.

Unable to uninstall package
This installed component is referenced by a locally created component. System Administrator
Unable to uninstall package

It is possible to remove this mapping by following the link to the profile and changing the page layout assignments for the affected objects.

Alternatively, I found it quicker to manually remove the page layout and use the replacement screen provided by Salesforce.

App Setup > Customize > Accounts > Page Layouts > Page Layout Name : Del

Then use the page layout replacement screen to reassign any references to a remaining page layout.

Wednesday, October 24, 2012

Changing the Windows Store Market

I recently published an app to the Windows Store and was puzzled why I couldn't find it in the Store to install from other machines.

When I published the app I restricted it to the New Zealand market. Turns out my current Windows 8 language settings were sending me to the wrong store.

  • Go to the Control Panel under the Settings charm.
  • In the Control Panel, click on Clock, Language, and Region.
  • Click on 'Add a language'
  • [Optionally] in the opened Window again click on 'Add a language' to add your language to Windows. (Ignore this step if you already have the required language)
  • Move the language the corresponds to the required store to the top of the list. Making it your primary language.
  • Back at Clock, Language, and Region, click on 'Change location' and select the location from the drop-menu and then click on OK.

Sunday, October 21, 2012

Debugging a WinRT background task

With Windows Phone 7 apps I often used ScheduledActionService.LaunchForTest to make background agents run quickly when debugging so I didn't need to wait 15 minutes before they would fire.

With WinRT you can now trigger the Background Task directly from Visual Studio. To do so:

  • Bring up the Debug Location toolbar. Right click somewhere in an empty toolbar if you can't find it.
  • Trigger the code that registers the background task.
  • Click the dropdown next to suspend and select the class that the background task runs.

See also:

Wednesday, October 17, 2012

DEP0700 : Registration of the app failed. Windows cannot install package

The following error appeared in Visual Studio when trying to run the Bing Maps SDK examples:

Error : DEP0700 : Registration of the app failed. Windows cannot install package 133E2AEE-177A-43F4-BB19-4A6CCA8BD2CA because the package requires architecture ARM, but this computer has architecture x64. (0x80073cf3) PushpinSample

The fix was simple enough. Change the Platform from ARM to x64 in the Configuration Manager.