UIX 2.2.16

oracle.cabo.servlet.event.mobile
Class PickerEventHandler

java.lang.Object
  |
  +--oracle.cabo.servlet.event.mobile.PickerEventHandler
All Implemented Interfaces:
EventHandler
Direct Known Subclasses:
DateEventHandler

public class PickerEventHandler
extends java.lang.Object
implements EventHandler

A lov in mobile does not pop up a javascript window, instead it fires an event back to the server.

A lovField on a pda sends
event='lov'
type='pre'
source=id(or name if no id) of lovField
uri=value of destination attribute

This sets up the user to be able to navigate to a new page, pick a value, and navigate back to the original page. PickerEventHandler can be used to help the user with that and save state during the process. The class name starts with the word "picker" because it can be used with events fired by components like a dateField or lovField where a user navigates off the page to pick a value, and then the value picked is shown on the original page. This should be done without losing other state as they navigate to/from the "pick" page.

Below is a brief description of the following methods in oracle.cabo.servlet.event.mobile.PickerEventHandler:

handleEvent()
handleCancel()
handlePreType()
handlePostType()
saveState()
restoreState()

- handleEvent() looks at the event name and calls handleCancel() if the event name is 'cancel', otherwise it looks for an event parameter named 'type' and calls handlePreType() if the 'type' is 'pre', or handlePostType() if the 'type' is 'post'.

- handlePreType() should be called on the request from the original page to the "pick" page. The default version returns the original page. It is expected that the user will override this method to call saveState(). The user can then redirect to the value in the 'uri' parameter.

- handlePostType() should be called on the way from the "pick" page back to the original page. The default version returns the original page. It is expected that the user will override this method and call restoreState().

- saveState() saves the state and returns a token which will be passed to restoreState(). The token can be passed to and returned from the "pick" page to use when restoreState() is called. In the default implementation the PageEvent object is saved on the session.

- restoreState() restores the state based on the token passed in. In the default implementation the parameter names and values from the pageEvent object stored on the session are set on the eventResult, except a new value is set for the element that originally fired the event.


Field Summary
static java.lang.String TOK_NAME
          The name of the token used.
static java.lang.String TOK_PARAM
           
 
Constructor Summary
PickerEventHandler()
           
 
Method Summary
static EventHandler getEventHandler()
           
static java.util.Dictionary getParameterMap(PageEvent event)
          Returns a Dictionary that maps parameter keys to values.
protected  EventResult handleCancel(BajaContext context, Page page, PageEvent event)
          Restore the original state.
 EventResult handleEvent(BajaContext context, Page page, PageEvent event)
          Decide which handle method to call.
protected  EventResult handlePostType(BajaContext context, Page page, PageEvent event)
          Returns original page.
protected  EventResult handlePreType(BajaContext context, Page page, PageEvent event)
          Returns original page by default.
protected  void restoreState(BajaContext context, Page page, PageEvent event, EventResult result, java.lang.String token)
          Restore the state.
protected  void restoreState(BajaContext context, Page page, PageEvent event, EventResult result, java.lang.String token, java.lang.Object value)
          Given the token, restore the state.
protected  java.lang.String saveState(BajaContext context, Page page, PageEvent event)
          Save the state and return a token representing the state which will be returned to the user in the restoreState method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOK_NAME

public static final java.lang.String TOK_NAME
The name of the token used.

TOK_PARAM

public static final java.lang.String TOK_PARAM
Constructor Detail

PickerEventHandler

public PickerEventHandler()
Method Detail

handleEvent

public EventResult handleEvent(BajaContext context,
                               Page page,
                               PageEvent event)
                        throws java.io.IOException
Decide which handle method to call. If the event name is 'cancel', call handleCancel(), else if the 'type' param is 'pre', call handlePreType(), else if the 'type' param is 'post', call handlePostType(), else return the original page.
Specified by:
handleEvent in interface EventHandler
Following copied from interface: oracle.cabo.servlet.event.EventHandler
Parameters:
context - the BajaContext
page - the page the client is requesting
event - the event on that page, or null if the client is just requesting a page display
Returns:
an object encapsulating results of this event
Throws:
java.lang.Throwable - if any processing of the event fails

handlePreType

protected EventResult handlePreType(BajaContext context,
                                    Page page,
                                    PageEvent event)
                             throws java.io.IOException
Returns original page by default. This method should be overridden for an event where the 'type' param is 'pre'.

handlePostType

protected EventResult handlePostType(BajaContext context,
                                     Page page,
                                     PageEvent event)
                              throws java.io.IOException
Returns original page. This method should be overridden for an event where the 'type' param is 'post'.

saveState

protected java.lang.String saveState(BajaContext context,
                                     Page page,
                                     PageEvent event)
Save the state and return a token representing the state which will be returned to the user in the restoreState method.

In this implementation the PageEvent object is saved on the session. The token returned is TOKEN_NAME


restoreState

protected void restoreState(BajaContext context,
                            Page page,
                            PageEvent event,
                            EventResult result,
                            java.lang.String token,
                            java.lang.Object value)
Given the token, restore the state.

In this implementation the parameter names and values from the pageEvent object stored on the session are set on the eventResult, except a new value is set for the element that originally fired the event.


handleCancel

protected EventResult handleCancel(BajaContext context,
                                   Page page,
                                   PageEvent event)
                            throws java.io.IOException
Restore the original state.

restoreState

protected void restoreState(BajaContext context,
                            Page page,
                            PageEvent event,
                            EventResult result,
                            java.lang.String token)
Restore the state.

Calls restoreState(context, page, event, result, token, null);


getParameterMap

public static java.util.Dictionary getParameterMap(PageEvent event)
Returns a Dictionary that maps parameter keys to values.
Parameters:
event - the PageEvent object to pull parameters off of
Returns:
Dictionary which maps parameter keys to values.

getEventHandler

public static EventHandler getEventHandler()

UIX 2.2.16