Technical Overview of MSCA/MWA Framework Continues...
Event Listener Model
MWAEvent
- Event object passed to the listener methods in the handlers at the field, page, or app level.
public class MWAEvent extends java.util.EventObject
- Frequently used properties and their getters and setters inherited from
EventObject public Object getSource()public String toString()- Stores
actionproperty (private java.lang.String m_action) public java.lang.String getAction()
- Stores
sessionproperty (private oracle.apps.mwa.container.Session m_session) public Session getSession()
MWAEvent Listeners:
Listeners are utilised for validations, dynamic rendering of the fields, update the values etc. Following are the key Listeners:
oracle.apps.mwa.eventmodel.MWAListener- Parent class for all MWA Listeners.
public interface MWAListener extends java.util.EventListener
- Direct subinterfaces -
MWAAppListener, MWAPageListener,MWAFieldListener We don't implement this interface directly.
oracle.apps.mwa.eventmodel.MWAAppListener- Application Level Event Listener
public interface MWAAppListener extends MWAListener- Methods -
void appEntered(MWAEvent e) throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerExceptionvoid appExited(MWAEvent e) throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerException- This interface is& typically implemented by our custom application's menu item bean.
oracle.apps.mwa.eventmodel.MWAPageListener- Page Level Event Listener
public interface MWAPageListener extends MWAListener- Methods -
void pageEntered (MWAEvent e) throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerExceptionvoid pageExited(MWAEvent e) throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerExceptionvoid specialKeyPressed(MWAEvent e) throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerException- Ex. Generating Barcodes, Navigating to Main menu etc.
- This interface is typically implemented by our custom application's page bean.
oracle.apps.mwa.eventmodel.MWAFieldListener- Field Level Event Listener
public interfaceextends MWAListenerMWAFieldListener
- Methods -
void fieldEntered(MWAEvent e) throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerExceptionvoid fieldExited(MWAEvent e) throws AbortHandlerException, InterruptedHandlerException, DefaultOnlyHandlerException- Probably most important class in terms of the custom code that we need to write in this.
- This interface is typically implemented in a standalone class.
- The standalone field listener class is instantiated and referenced inside page bean, where we associate it with every field on the page.
- Field Listener will typically have a constructor where session is passed from page and stored in a class variable.
- Following are few important code snippet typically used in this field listeners:
- To get the source of the event:
String fieldName = ((FieldBean)mwaEvent.getSource()).getName();- To check if it is a submit event:
if (mwaEvent.getAction().equals("MWA_SUBMIT"))- To get the current page details
session.getCurrentPage();- To show message in status bar:
this.ses.setStatusMessage("Qty Should be > 0");this.ses.setStatusMessage("Trx Successful");- To set next field for user entry:
session.setNextFieldName();- To refresh the screen:
session.setRefreshScreen();- To throw exceptions:
throw new AbortHandlerException("Qty Should be > 0");- To signal end of transaction
setNextPageName("|END_OF_TRANSACTION|")- Most of the above code is from session, we'll see session details in coming section.
Other Important Classes - MWA Session Classes
oracle.apps.mwa.container.Sessionpublic class Session extends oracle.apps.mwa.container.BaseSession- BaseSession is base class for user session and telnet session.
- Key methods inherited from BaseSession
public java.sql.Connection getConnection()public java.sql.Connection getConnectionFromSession()public void returnConnection()public java.lang.String getCurrentPageName()- Key methods in Session class
public PageBean getCurrentPage()
- Returns the current page bean in the page bean list
public void setStatusMessage(java.lang.String msg)
- Displays the argument string on the status bar.
public java.lang.String getStatusMessage()
public void setRefreshScreen(boolean RefreshScreenFlag)
- This method set the refresh screen variable Whenever developer change the UI property of the page, e.g. hidden, value, creation of new field, etc, he/she needs to call this method with parameter true so that server will know and refresh the screen
public boolean isRefreshScreen()public FieldBean getFieldFromCurrentPage(java.lang.String fieldName)public void setNextFieldName(java.lang.String fName)
- To set the cursor to some other field.
public java.lang.String getNextFieldName()
public Logger getLogger()
Application Flow
Coding Hints:
A. Ctrl + X shortcut key for About This Page is a good start for customizing existing functionality.
B. We typically create following 4 files:
- XXABCTransactFunction.java
public class XXABCTransactFunction extends MenuItemBean implements MWAAppListener- With following two lines in constructor:
setFirstPageName("xxabc.oracle.apps.xxabc.applpkg.module.server.XXABCTransactPage");addListener(this);- It'll have
appEntered()andappExited()methods. - XXABCTransactPage.java
public class XXABCTransactPage extends PageBean implements MWAPageListener- Typically it'll have following Member variables:
- For all field beans
- For session
- For FieldListener for all fields
- Constructor will initialize FieldListener bean (Explained Next)
- Constructor will initialize all fields, associate field listener and add them to page hierarchy.
- It'll have
pageEntered(), pageExited()andspecialKeyPressed()methods. - It'll have methods for business transactions typically calling PLSQL procedures.
- XXABCTransactFListener.java
public class XXABCTransactFListener implements MWAFieldListener- Typically it'll have following Member variables:
- session
- Paramterized Constructor with session variable will initialize member session variable.
- Rarely we need to write code in
fieldEntered()method. FieldExited()will have bulk of the coding based on current page and field exited:String fieldName = ((FieldBean)mwaEvent.getSource()).getName();- To identify the field exited.
this.ses.getCurrentPage();- To identify the current page
- For transaction logic, it'll have a call to the pageBean's transaction method.
- XXABCFieldLOV.java
public class XXABCFieldLOV extends LOVFieldBean implements MWAFieldListener- Since LOVs are shared components, for easy of use/reuse we usually create them as separate Java files.
- It'll have member variables, their getters and setters for the return values of the selected LOV record.
- It'll have constructor will following api calls:
setName(), setRequired(), setPrompt(), setValidateFromLOV(), setlovStatement(), setInputParameterTypes(), setSubfieldPrompts(), setSubfieldDisplays(), addListener(this).- It'll have
fieldEntered()method (usually empty). - It'll have
fieldExited()method (usually we set all the return values from selected LOV record to member variables).
Sample Code for all Files:
Standard Oracle MWA code provides good insight in how to write code. If still any help is needed, please reach me.
Steps to test the code:
- Deploy it on the server.
- Restart the server.
- Testing on desktop telnet client.
- View the log for debugging.
Debugging:
- Steps to enable logging are in document 338291.1
- Log files are located in $INST_TOP/logs
- Logging Levels are Fatal, Error, Warning, Debug and Trace.
- All Log files start with telnet port number as prefix.
- In java code following method is used to write log statement:
- oracle.apps.inv.utilities.server.UtilFns.trace()
- In java code to check if trace is enabled:
- if (UtilFns.isTraceOn)
- In PLSQL, following code will be used
- Use Mirroring
- Check Mobile Services are up and Runing:
- ps -ef |grep mwa
- ./ $INST_TOP/admin/scripts/mwactl.sh status
- Check MWA user sessions
- netstat -a |grep <MWA PORT> | wc -l
- netstat -an | grep <MWA PORT>
- Find port Number of Mobile Services :
- grep mwa $CONTEXT_FILE
- Connect to Mobile Services :
- telnet hostname.domainname portnumber(mobile application service port_number)
- MWA Troubleshooting Tips for Release 12 (Doc ID 782162.1)
Reference and Further Reading:
Note 578667.1 - Customization of Oracle Mobile Supply Chain Applications and Oracle Warehouse Management SystemNote 959087.1 - How To Download The MSCA/WMS JAVADOCS Files For Doing Customization?
Note 338291.1 - How to Enable WMS / MSCA Logging
Note 297992.1 - Advanced Barcode Strategies – Custom Scan Framework & profile option "MWA: Custom Scan"
For Multi-lingual Support and DFI (Data Field Identifier) - Integration with AK repository is needed.
Previous Read: MSCA/MWA Framework - Custom Development and Extension - Part 1
Previous Read: Oracle MSCA/MWA Framework - Introduction