BlackBerry Considerations

The mobile application launches Visualforce Mobile pages in an embedded browser. Research in Motion (RIM) upgraded the embedded browser with the release of BlackBerry operating system version 4.3, but the embedded browser still has limited JavaScript support. Although the BlackBerry Bold (version 4.6) and BlackBerry Storm (version 4.7) have more powerful standard browsers, the embedded browser has not sufficiently improved for full Visualforce Mobile support.

When developing pages for BlackBerry smartphones, these considerations apply:

JavaScript Support
The embedded BlackBerry browser has very limited JavaScript support. Inline DOM events do not work at all. When possible, avoid using JavaScript in Visualforce Mobile pages for BlackBerry.
Forms and View State
Visualforce pages rely on a view state to maintain the state of the database between requests. If you use the <apex:form> tag in your Visualforce page, the view state variable is often too large for the BlackBerry embedded browser to deal with effectively, even for the simplest forms.
If you need to create a form, try to use standard HTML forms. Parameters sent from the form can be retrieved with ApexPages.currentPage().getParameters() map in the controller. When using HTML forms, remember that:
  • Maintaining state between pages must be done manually.
  • Redirecting to another page must be done manually.
  • The <apex:commandLink> and <apex:commandButton> components are not available.
For Visualforce Mobile pages that let users upload files, using the <apex:form> and <apex:inputFile> components is the best choice. The two components function properly in this limited use case. For example, to create an upload form, use the two tags in conjunction with Apex controller methods:
<apex:form>
	<apex:inputFile value="{!attachment.body}"/>
	<apex:commandButton action="{!save}"/>
</apex:form>
The implementation can benefit further from the use of transient variables. The transient keyword is used for data that doesn’t need to be saved on a postback. In the previous example, the attachment itself should be non-transient, but the attachment body can potentially be very large, and there's no reason to store the body in the view state.
The solution is to change the value of <apex:inputFile> to retrieve a Blob file type:
<apex:form>
	<apex:inputFile value="{!theBlob}"/>
	<apex:commandButton action="{!save}"/>
</apex:form>
Then, in your Apex controller for this page, define theBlob as transient:
Transient Blob theBlob;
Finally, in the save method, define the attachment using the value of theBlob:
attachment.body = theBlob; 
upsert attachment; 
attachment.body = null.
The attachment body will get updated with the correct data, but the data will not be preserved. Set attachment.body to null after save because the attachment itself is not transient.
Misplaced Visualforce Tags
Some Visualforce tags, upon compilation and resolution to HTML, are sometimes misinterpreted or not interpreted:
  • The <apex:facet> component is placed where it appears in the code. Be sure to place the <apex:facet> tag where it should display on the page; for example, place the <apex:facet name="footer"> component at the bottom of a section.
  • The standard Salesforce styles provided with the <apex:sectionHeader> and <apex:pageBlock> components are mangled or ignored. Use simpler tags, or write pure HTML.
Page Styles
Be sure to follow the best practices for styling your Visualforce Mobile pages. Additionally, be aware that the BlackBerry embedded browser ignores some common CSS properties, such as margin-left.
Line Breaks
The <br/> tag is ignored unless there is something on the line, such as a non-breaking space.
Navigation
The embedded browser in the BlackBerry client application does not have built-in navigation. If your Visualforce page is a wizard, you should provide navigation links that allow users to return to the previous page and advance to the next page. Additionally, the Visualforce page is embedded in a tab, so you should avoid using tabs for navigation in mobile Visualforce pages.
Previous
Next