WebSphere Everyplace Mobile Portal extends WebSphere Portal software with technology to meet the requirements of mobile and wireless service providers. With Mobile Portal, you can develop content independent specific devices using a special markup called XDIME (XML Device Independent Markup Extension). This enables you to create content or services once, and present them on many different devices without any additional rework.
Most of the time, the default themes and styles provided by the XDIME aggregator are sufficient. But you can also create custom themes to apply to mobile portlets.
This article assumes you have completed Develop Mobile Portlets with WebSphere Everyplace Mobile Portal -- Part 1: Create an interactive XDIME portlet.
The sample portal we'll create consists of two text fields and a Submit button as shown in Figure 1. We'll apply a custom color to the body of the screen. This is the final output after completing the steps in this article.
Figure 1. Sample portlet
Before you begin, complete the steps in Part 1 to set up the environment and create XDIME resources.
To create a custom theme to apply styles to the portlet you created in Part 1, complete the following steps:
- Right-click mcs-policies and select New => Other, and then MCS => Theme, then click Next.:
Figure 2. Create theme dialog
- Enter the theme name
myThemeand click Next. - In the New Device Theme window, select Mobile as shown in Figure 3.
Figure 3. New device theme dialog
- Click Finish. The myTheme.mthm file is opened in the design mode.
- Select Mobile as shown in Figure 8 and switch to the design mode by clicking on the Design tab.
Figure 4. Click Design tab
- In the Selectors section, click New.
- Select xfform in the Element field. Click Add, then Finish.
- Repeat steps 6 and 7 for the element xftextinput. You should see a screen that looks like this:
Figure 5. Design for Mobile
- Now click xfform, then select Background in the Style Properties section.
- Select the color for the background as shown in Figure 6.
Figure 6. Selectors and Style Properties
- Now click xftextinput in the Selectors section, then select Font in the Style Properties section.
- Select italic for the style.
Now that we've created a layout and a custom theme, we need to apply the layout and theme to the display.
- With the source editor, open the MobileLoginPortletView.jsp in the WebContent/mobilelogin/jsp/xdime folder of the project.
- Using the source editor, open the JSP file in the WebContent/<project_name>/jsp/xdime folder of the project, where <project_name> is the name of the portlet project.
- Edit the code as shown below:
<%-- keep JSP page compiler from generating code that accesses the session --%> <%@ page session="false" contentType="text/xml; charset=ISO-8859-1" %> <!-- load WPS portlet tag library and initialize objects --> <%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI" %> <portletAPI:init /> <%-- Create a layout policy for your portlet. Specify the layout name as the value for the layoutName attribute of the canvas element below. --%> <canvas layoutName="/login.mlyt" type="portlet" theme="/myTheme.mthm"> <xfform name="loginForm" action="<portletAPI:createReturnURI> <portletAPI:URIAction name='Submit'/> </portletAPI:createReturnURI>" method="post"> <xftextinput name="userId" type="text" caption="User ID : " captionPane="useridPane" entryPane="useridPane" initial=""/><br/> <xftextinput name="password" type="password" caption="Password : " captionPane="passwordPane" entryPane="passwordPane" initial=""/><br/> <xfaction name="Submit" type="submit" caption="Submit" captionPane="submitPane" entryPane="submitPane"/> </xfform> </canvas>
Note that we've used the following XDIME elements in the code:Table 1. XDIME elements XDIME Element Equivalent HTML Element Description <xfform> <form> The form in the page <xftextinput type="text"t> <input type="ttext"t> Text field <br/> <br> Line break <xfaction> <input type="submit"> Action button For more information on XDIME elements, see Resources .
You can also see that the different elements are assigned to the different panes in the login layout, which is referred to in the <canvas> tag in the code.
Now that we've completed the required configuration and development, let's test the application. We'll test the application using the Firefox browser with an appropriate User Agent enabled.
To test the XDIME portlet, complete the following steps:
- Create a test server for WebSphere Portal and configure it for the portlet project.
- Start the test server.
- Open the Firefox browser.
- Select a user agent by selecting Tools => User Agent Switcher.
- Access the portal from http://<host>:<port>/wps/myportal, where <host> is the IP or name of the machine and the <port> is the port at which the test server is configured.
- Figure 7 shows the Log-in window of the portal with the user agent Sanyo enabled.
Figure 7. Portal Log-in
- Log in with a valid Portal user ID.
- You should see something like Figure 8.
Figure 8. Select portlet
- Click MobileTheme portlet. You should see a screen like that shown in Figure 9.
Figure 9. Portlet log-in
You can see that the background color of the form and the font style of the text fields are applied as we defined them in the custom theme.
We've now successfully applied custom syles to our mobile portlet!
In this article, you have created and tested a custom theme for the portlet you created in Part 1, including editing the JSP to define the custom layout and custom theme.
Learn
-
Develop Mobile Portlets with WebSphere Everyplace Mobile Portal -- Part 1: Create an interactive XDIME portlet
-
Overview of wireless technologies
-
Product documentation on Multi-Channel Server and Layouts
-
XDIME Element Reference
-
WebSphere Everyplace Service Delivery product documentation
-
WebSphere Everyplace Mobile Portal -- Part 2: Developing a Mobile Portal Enabled XDIME Portlet
Get products and technologies





