Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Develop Mobile Portlets with WebSphere Everyplace Mobile Portal -- Part 2

Apply custom themes to mobile portlets

Mohan K Jadhav (mohan.jadhav@in.ibm.com), Software Engineer, EMC
Author photo
Mohan K Jadhav is a Software Engineer in IBM India Software Labs, Bangalore. He is currently working on Java™ middleware and server-side technologies.
(An IBM developerWorks Contributing Author)

Summary:  Learn how to apply custom themes to portlets that are intended to be rendered on the mobile devices. The article is for portal developers who want to develop portlets for mobile and wireless devices using IBM® WebSphere® Everyplace® Mobile Portal (hereafter called Mobile Portal) and WebSphere Studio Application Developer (hereafter called Application Developer). You should have a working knowledge of developing and testing portlets on WebSphere Portal (hereafter called Portal), and hands-on experience with Application Developer features to complete the steps in this article.

Date:  07 Sep 2005
Level:  Introductory

Activity:  2618 views
Comments:  

Introduction

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
Sample portlet

Before you begin, complete the steps in Part 1 to set up the environment and create XDIME resources.


Create a custom theme

To create a custom theme to apply styles to the portlet you created in Part 1, complete the following steps:

  1. Right-click mcs-policies and select New => Other, and then MCS => Theme, then click Next.:

    Figure 2. Create theme dialog
    Figure 2.  Create theme dialog
  2. Enter the theme name myTheme and click Next.
  3. In the New Device Theme window, select Mobile as shown in Figure 3.

    Figure 3. New device theme dialog
    Figure 3. New device theme dialog
  4. Click Finish. The myTheme.mthm file is opened in the design mode.
  5. Select Mobile as shown in Figure 8 and switch to the design mode by clicking on the Design tab.

    Figure 4. Click Design tab
    Figure 4. Click Design tab
  6. In the Selectors section, click New.
  7. Select xfform in the Element field. Click Add, then Finish.
  8. Repeat steps 6 and 7 for the element xftextinput. You should see a screen that looks like this:

    Figure 5. Design for Mobile
    Figure 5. Design for Mobile
  9. Now click xfform, then select Background in the Style Properties section.
  10. Select the color for the background as shown in Figure 6.

    Figure 6. Selectors and Style Properties
    Figure 6. Selectors and Style Properties
  11. Now click xftextinput in the Selectors section, then select Font in the Style Properties section.
  12. Select italic for the style.

Edit the XDIME JSP

Now that we've created a layout and a custom theme, we need to apply the layout and theme to the display.

  1. With the source editor, open the MobileLoginPortletView.jsp in the WebContent/mobilelogin/jsp/xdime folder of the project.
  2. 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.
  3. 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 ElementEquivalent HTML ElementDescription
    <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.


Test the application

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:

  1. Create a test server for WebSphere Portal and configure it for the portlet project.
  2. Start the test server.
  3. Open the Firefox browser.
  4. Select a user agent by selecting Tools => User Agent Switcher.
  5. 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.
  6. Figure 7 shows the Log-in window of the portal with the user agent Sanyo enabled.

    Figure 7. Portal Log-in
    Figure 7. Portal Log-in
  7. Log in with a valid Portal user ID.
  8. You should see something like Figure 8.

    Figure 8. Select portlet
    Figure 8. Select portlet
  9. Click MobileTheme portlet. You should see a screen like that shown in Figure 9.

    Figure 9. Portlet log-in
    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!


Summary

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.


Resources

Learn

Get products and technologies

About the author

Author photo developerWorks Contributing author level

Mohan K Jadhav is a Software Engineer in IBM India Software Labs, Bangalore. He is currently working on Java™ middleware and server-side technologies.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=93485
ArticleTitle=Develop Mobile Portlets with WebSphere Everyplace Mobile Portal -- Part 2
publish-date=09072005

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers