Thursday 22 January 2015

Rendering ADF based on the device type

According to some statistics, nowadays more than half of internet usage occurs on mobile platforms. So it is time to ask yourself if your Portal is working properly in tablets and phones.

Latest WebCenter Portal release (11.1.1.8) includes some useful features that control how the pages are displayed in different devices. Also, if you are interested in modifying some Portal behavior in your code, deviceManagement EL expressions are available.

The following piece of code will return the device type accessing Portal:

<af:outputText value="#{DeviceAgent.currentScopeDeviceGroup.name}" id="a1"/>

This group of expressions has several applications, for instance conditional rendering:

                    <af:commandLink rendered="#{DeviceAgent.currentScopeDeviceGroup.name eq 'desktopBrowsers' or DeviceAgent.currentScopeDeviceGroup.name eq 'iOSTablets'}"
                                    text="Register"
                                    id="gl1" styleClass="linkBlue">
                      <af:clientListener method="open" type="click"/>
                    </af:commandLink>


That piece of code will show a Registration link only if the user is accessing Portal via desktop computer or iPads.

Possible values: desktopBrowsers, iOSTablets, iOSPhones, androidTablets, ...

References

 

Tablet Growth: Usage Statistics and Expectations

 

No comments:

Post a Comment