7 Narrow Screen Support and User-Agent Details Support

This chapter describes how the Trinidad infrastructure determines narrow screen support and how it uses EL expressions to expose user-agent details.

This chapter includes the following sections:

7.1 Determining Narrow Screen Support

Mobile devices have a wide range of screen widths. As a result, the UI components of a web application may render properly on a device with a screen width measuring 240 pixels, but not align correctly when the application runs on a device that has a screen width of only 100 pixels. In such a situation, Trinidad optimizes its rendering for narrow-screen devices. Trinidad considers any device with a screen width of less than 240 pixels as a narrow screen and optimizes the rendering for the following components accordingly:

  • tr:breadcrumbs

  • tr:inputText

  • tr:navigationPane

  • tr:panelFormLayout

  • tr:panelLabelAndMessage

  • tr:panelRadio

  • tr:processChoiceBar

  • tr:selectRangeChoiceBar

7.1.1 How Trinidad Determines Narrow-Screen Optimization

Because Trinidad only considers a device with a screen width that measures less than 240 pixels as a narrow screen, it does not consider iPods (Safari browsers) or BlackBerry smartphones (BlackBerry browsers), which usually have screens that are greater than 240 pixels, as such. For a Windows Mobile browser, Trinidad determines the screen width from the UA-pixels request header and only applies narrow screen optimization if the screen-width is less than 240 pixels. For all other user agents, however, Trinidad optimizes its rendering for a narrow screen device.

7.2 Determining User-Agent Capabilities Using EL Expressions

Trinidad exposes a requesting user-agent's details to developers using the EL expression, #{requestContext.agent}, which returns an agent object that describes the requesting user agent. By adding the detail name or capability name properties to this expression, you enable Trinidad to return details that include the user-agent's name, version, platform, the version of the platform, the model (which is applicable only to BlackBerry), and the browser's support for JavaScript and PPR (Partial Page Rendering). For information on exposing user-agent details, see Section 7.2.1, "How To Determine User-Agent Details." For information on determining browser capabilities, see Section 7.2.2, "How to Determine Browser Capabilities."

7.2.1 How To Determine User-Agent Details

When Trinidad receives a request, it parses user-agent strings for a variety of user-agent details (listed in Table 7-1) that include type, the name and version of the agent, and the agent's platform name and platform version. Trinidad uses the EL expression #{requestContext.agent.<detail-name>} to expose these details to developers. For example, to enable developers to retrieve the category appropriate to the user-agent type (that is, desktop for a desktop browser or PDA for mobile browsers), Trinidad uses the type detail in the EL expression as follows:

#{requestContext.agent.type}

Note:

Trinidad may return a null value for such details as PlatformName, PlatformVersion if it cannot parse them from the user-agent string.

Table 7-1 Browser Details Exposed through EL Expressions

Detail Name Description

type

Identifies a user-agent type. For desktop and mobile browsers, the values are desktop and PDA, respectively. Because Safari provides all desktop browser features when it runs in a mobile device, the agent object exposes this detail as a desktop type.

agentName

The name of the agent

agentVersion

The version of the agent

platformName

The platform on which the agent runs

platformVersion

The version of the platform on which the agent runs

hardwareMakeModel

The model of the mobile device


7.2.2 How to Determine Browser Capabilities

Trinidad sends its response to a user-agent's request based on capabilities it assigns to a user agent. These capabilities include a user-agent's support for JavaScript and PPR. Some of these capabilities (listed in Table 7-2) are exposed to developers through the EL expression #{requestContext.agent.capabilities}.

Use the EL expression #{requestContext.agent.capabilities.<capability-name>} to determine the specific capability assigned to a user-agent by Trinidad. For example, to determine whether Trinidad assigns JavaScript capability to a user agent, use the following EL expression:

# {requestContext.agent.capabilities.scriptingSpeed!='none'}

Table 7-2 Browser Capabilities Exposed through EL Expressions

Capability Name Detail

narrowScreen

Indicates whether Trinidad optimizes is rendering for a narrow-screen device. It returns true (a boolean type) if Trinidad optimizes its rendering for a narrow-screen device.

scriptingSpeed

Indicates JavaScript support for a user-agent. Returns none (a String type) if the user-agent does not support JavaScript.

partialRendering

Indicates PPR support for a user-agent. Returns true (a boolean type) if the browser supports PPR.