Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • WebSphere Portal Family wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 6.0
  • 6.1
  • 6.1.0.1
  • 6.1.5
  • 7.0
  • 7.0.0.2
  • 8.0
  • actions
  • administrator
  • authoring
  • Banking template
  • best practices
  • blogs
  • builder
  • building a site
  • caching
  • catalog
  • Clickstream Engine
  • clusters
  • ConfigEngine tasks
  • content
  • customizing
  • databases
  • demo
  • deployment
  • deployment scenario
  • developer
  • developing
  • device class
  • elements
  • examples
  • Express
  • feature set
  • fix pack 2
  • Government to Business template
  • info center
  • information center
  • installation
  • installing
  • LDAP
  • Learning
  • libraries
  • LikeMinds Recommendation Engines
  • logging
  • mentors
  • message catalog
  • messages
  • migration
  • mobile
  • mobile devices
  • mobile experience
  • mobile experience 8.0
  • mobile theme
  • mobile webkit
  • MPA
  • multiplatform
  • pages
  • performance
  • personalization
  • planning
  • portal
  • Portal 6.1
  • Portal 8 theme
  • portlets
  • product doc
  • product documentation
  • projects
  • properties
  • Redbooks
  • Redbooks Wiki
  • remember me cookie
  • resources
  • REST
  • Retail Vendor template
  • rules
  • samples
  • search
  • security
  • sifters
  • sites
  • solutions catalog
  • syndication
  • test infrastructure
  • theme
  • theme optimization
  • topologies
  • troubleshooting
  • tutorials on personalization
  • video
  • wcm
  • web content
  • webkit
  • WebSphere Portal
  • WebSphere Portlet Factory
  • wikis
  • workflows
  • worksheet
  • XML configuration interface
  • z/os
  • zos
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > IBM Mobile Portal Accelerator > Creating forms in WEMPe
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Creating forms in WEMPe 

expanded Abstract
collapsed Abstract
No abstract provided.
Authors:
  • Preeti Sharma (sharma.preeti@in.ibm.com)
  • Kiran Rao (kiran.rao@in.ibm.com)
 
Introduction

IBM WebSphere Everyplace Mobile Portal enable (WEMPe) is a product which extends WebSphere Portal to deliver optimized web content to a wide range of mobile handsets. WEMPe follows a “write once, render many” approach. A portlet is coded only once and it renders on a variety of mobile handsets.

WEMPe greatly reduces the development effort required to get a mobile portal up and running to support thousands of devices; and at the same time, support traditional PC browsers too, since a suitably designed portlet can serve both the mobile channel and web channel.

Mobile web sites can be divided into two categories based on the mode of interaction with the user:

  • Navigation-oriented: In such sites, the input from the user is primarily in form of “clicks” to navigate through the site. There is not much in form of user-entered input. Examples of such sites include content-centric sites and news sites.
  • User-input oriented: These are sites where the service provided depends on some form input from the user. Examples include mobile banking and stock quote sites.

The key entities in the user-input oriented sites are forms. This article provides various tips & tricks, best practices to follow, frequently faced problems/limitations and ways to work around them when using forms in WEMPe. It includes XDIME code samples to demonstrate these best practices.

Specifically, this article explores the following topics:

1. Handling events on multiple buttons on a form in WEMPe without using javascript.

2. Creating multilingual forms in WEMPe.

 


Creating forms in WEMPe.

There are two main artifacts one needs for creating and displaying a form in WEMPe

    1. A Form format in the page canvas
    2. An element in the JSP which binds to the form in the canvas

The Form format is created in the layout policy using the Mobile Portal Toolkit. Here is a screenshot of the layout canvas with the Form.

Figure 1

 

The skeleton XDIME code for this form is as follows:

 <xfform name=”frm” … … >
 //Code for the Form UI Elements here
</xfform>

Notice that the value of the name attribute (i.e., “frm”) on the xfform element is exactly the same as the name of the Form in the layout policy. It is this name attribute that binds the xfform to the specific form format on the canvas.

The various form UI elements used in this example are:

  • xfaction – this is used to create a button.
  • xftextinput – this is a text box, the XDIME equivalent of HTML’s
  • xfsiselect – this is used for exclusive selection. It can be formatted to render either as a radio-box or a combo-box.

Please refer to the WEMPe InfoCenter for more details about the various for UI elements.

http://publib.boulder.ibm.com/infocenter/pvccom/v6r0m1/topic/com.volantis.mcs.eclipse.doc/wag/xdime_pr_er.html

Handling Multiple Buttons on Forms.

When there is a requirement to have multiple buttons associated with a form, HTML developers would use Javascript to keep track of the button that has been clicked and the action that has to be performed. A value would be passed from the JSP to the processAction method to identify the event. However, it is not recommended to use JavaScript for mobile applications since there are varied numbers of mobile devices, of which some support JavaScript and some do not. Also, various devices differ in the version of Javascript that they support.

The following technique can be used to handle multiple buttons on a form without using JS in WEMPe. This technique is based in the premise that when there are multiple buttons on a form, and one of them is clicked, only the button which is clicked has a non-null parameter value. This is explained in more detail with the help of snippets as follows:

    1. In the JSP, define a button using the xfaction tag and give caption and name values.

      <xfaction type="submit"
         caption="UPDATE DETAILS" 
          name="UPDATE_DETAILS"
          captionPane="pane_cap.7" 
           entryPane="pane_cap.7" />
    2. In the portlet’s action processing method, do a request.getParameter(), passing the button name as parameter. This returns the caption of the button clicked. When there are multiple buttons only the caption for the clicked button will be a valid value. The captions for all other buttons will be null.

    String btnclicked = actionRequest.getParameter(“UPDATE_DETAILS”)
    if (btnclicked.equalsIgnoreCase(“UPDATE DETAILS”))
    {
        //perform action
    }

Example

Please refer to the attached Project Interchange with source code for the complete working sample. Here, we look at the relevant sections of the sample, i.e., the JSP and the Portlet java code.

The scenario used for this example is that of an employee database. A user who is logged in to the system is presented a text box to enter an employee code. The user can then click on the “Get Emp Details” button to get the employee details. This refreshes the page and fetches the employee record. It details displayed include the employee’s band, Account number, Department etc.

The first screenshot displays the JSP used for rendering such a form. Notice how multiple buttons are defined within a single form by including multiple tags within a single element.

Figure 2

In the processAction() method, action handling is performed based on the caption of the clicked button.

 

Figure 3

 


Handling Multilingual Forms.

As we saw in the preceding sections, fetching the captions of the buttons is a good way to ascertain the button which was the source of the action. However, this presents a challenge in case of multilingual forms. For example, how does one type in a caption which is in a double-byte language, in the Java source?

The answer is to simply examine the null-ness of the caption. Remember, as has been pointed out earlier, all caption values, except that for the button which has been clicked, are null. Hence, calling the equalsIgnoreCase() is not really necessary. All that is needed is to find that button for which the getParameter() is non-null. This is the button which has been clicked!

     
    String btnclicked = actionRequest.getParameter(“UPDATE_DETAILS”)
    if (btnclicked!=null)
    {
        //perform action
    }

The screenshot below shows the previous code, re-factored to suit cases where the form is multilingual.


Figure 4

Conclusion


 

To summarize what’s been discussed in this article:

  • Creating a form in WEMPe involves
    1. Adding a Form within the canvas layout
    2. Coding the JSP using the XDIME xfform tag; creating actions with the xfaction tag; and associating the xfform with the layout using the name attribute
    • If it is required to have multiple buttons within a form, one can take advantage of the fact that only the button which has been clicked will return a caption when the getParameter() method is invoked. All other buttons return null values
    • The same principle can be applied for having multi-lingual forms with multiple buttons.
 

Extras

The article is accompanied by a source code project interchange (Forms.zip) and a deployable portlet (Forms.war)

 https://greenhouse.lotus.com/files/app/person/4c98c940-b16a-102c-87bf-946fab8fcf80/file/f63d6144-93e6-4ff0-9805-d1c86e24155f|Creating_Forms_WEMPe_extras.zip">Creating_Forms_WEMPe_extras.zip">https://greenhouse.lotus.com/files/app/person/4c98c940-b16a-102c-87bf-946fab8fcf80/file/f63d6144-93e6-4ff0-9805-d1c86e24155f|Creating_Forms_WEMPe_extras.zip

 


expanded Article information
collapsed Article information
Category:
IBM Mobile Portal Accelerator
Tags:
WEMPe, form, mobile

This Version: Version 36 April 7, 2010 2:14:17 PM by John Munnell  IBMer

expanded Attachments (4)
collapsed Attachments (4)

 


File TypeSizeFile NameCreated On
image/jpeg 32 KB fig1.JPG 2/11/10 3:20 PM
image/jpeg 29 KB fig2.JPG 2/11/10 3:20 PM
image/jpeg 38 KB fig3.JPG 2/11/10 3:20 PM
image/jpeg 36 KB fig4.JPG 2/11/10 3:20 PM
expanded Versions (36)
collapsed Versions (36)
Version Comparison     
Version Date Changed by               Summary of changes
This version (36) Apr 7, 2010 2:14:17 PM John Munnell  
35 Feb 18, 2010 3:39:09 PM John Munnell  
34 Feb 18, 2010 3:38:26 PM John Munnell  
33 Feb 18, 2010 3:36:08 PM John Munnell  
32 Feb 18, 2010 3:35:35 PM John Munnell  
31 Feb 16, 2010 6:24:28 PM John Munnell  
30 Feb 16, 2010 6:21:50 PM John Munnell  
29 Feb 16, 2010 6:20:39 PM John Munnell  
28 Feb 16, 2010 6:19:12 PM John Munnell  
27 Feb 16, 2010 6:18:00 PM John Munnell  
26 Feb 16, 2010 6:16:34 PM John Munnell  
25 Feb 16, 2010 6:14:32 PM John Munnell  
24 Feb 16, 2010 6:12:57 PM John Munnell  
23 Feb 16, 2010 6:10:38 PM John Munnell  
22 Feb 16, 2010 6:09:16 PM John Munnell  
21 Feb 16, 2010 6:06:55 PM John Munnell  
20 Feb 16, 2010 6:03:49 PM John Munnell  
19 Feb 16, 2010 2:11:15 PM John Munnell  
18 Feb 16, 2010 2:09:25 PM John Munnell  
17 Feb 16, 2010 2:03:32 PM John Munnell  
16 Feb 16, 2010 2:02:02 PM John Munnell  
15 Feb 16, 2010 1:57:47 PM John Munnell  
14 Feb 12, 2010 4:40:51 PM Laura Sohval  
13 Feb 12, 2010 4:23:42 PM Laura Sohval  
12 Feb 12, 2010 4:18:10 PM Laura Sohval  
11 Feb 12, 2010 4:12:18 PM Laura Sohval  
10 Feb 12, 2010 4:05:03 PM Laura Sohval  
9 Feb 12, 2010 3:59:30 PM Laura Sohval  
8 Feb 12, 2010 3:57:06 PM Laura Sohval  
7 Feb 12, 2010 3:42:07 PM Laura Sohval  
6 Feb 11, 2010 3:20:28 PM John Munnell  
5 Feb 11, 2010 3:14:18 PM John Munnell  
4 Feb 11, 2010 3:12:22 PM John Munnell  
3 Feb 11, 2010 3:10:00 PM John Munnell  
2 Feb 11, 2010 3:05:13 PM John Munnell  
1 Feb 11, 2010 3:03:40 PM John Munnell  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use