Building Mobile Enterprise Applications : Using webMethods Mobile Designer : Defining Resources for a Mobile Application Project : Coding the Resource Handler
Coding the Resource Handler
 
Using Resource Blocks and Resource Packs
If you started your project by cloning a sample project provided with Mobile Designer, you can update the resource handler provided in the sample to work for your application. Alternatively, you create the resource handler from the beginning on your own.
Resource Handler Requirements
*Your resource handler must extend com.softwareag.mobile.reshandler.ResourceHandler. This class includes the projectResourceScript method.
*In the resource handler, include all resource handling logic that your project requires in the projectResourceScript method.
When building your project, Mobile Designer calls the resource handler’s projectResourceScript method.
Methods that Mobile Designer Provides for the Resource Handler
Mobile Designer provides the com.softwareag.mobile.reshandler.AntTaskResourceHandler that contains methods you can use in your resource handler.
The com.softwareag.mobile.reshandler.ResourceHandler class, which your project’s resource handler must extend, includes the rh field that defines a link to AntTaskResourceHandler. As a result, you can easily execute the methods in the AntTaskResourceHandler using the following format, where method is the AntTaskResourceHandler method you want to invoke:
rh.method
For example, to use the AntTaskResourceHandler addFile method to create a resource from a file, use the following:
rh.addFile
The types of actions you can accomplish using methods provided by the AntTaskResourceHandler include:
*Add resources to the project.
*Set and get IDs for resources, text lines, menus, and resource blocks.
Note:  
When the resource handler sets identifiers, Mobile Designer adds corresponding parameters to the Parameters.java class. For more information, see Setting Parameters in the Resource Handler Code.
*Bundle resources into packs. For more information, see Using Resource Blocks and Resource Packs.
*Set application-specific parameters. For more information, see Setting Parameters in the Resource Handler Code.
To learn about all the methods that Mobile Designer provides for a resource handler, see information about com.softwareag.mobile.reshandler.AntTaskResourceHandler in webMethods Mobile Designer Java API Reference.
Setup to Allow the Resource Handler and Application Code to Share Common Code
You can set up your project’s resource handler and the application code so that they share common code. For example, the resource handler and application code might use the same set of constant values, or you might have common code that you want to use in both the resource handler and the application code.
To use shared common code, place the shared code in a folder within your project. Then when defining the project.runtime.project.src.path and project.reshandler.src.path Ant paths for your project, include <pathelement> tags to the location that contains the shared code. For example, if you placed shared code in the project’s src/shared_code folder, you might define Ant paths like the following in your project’s _defaults_.xml file:
<path id="project.runtime.project.src.path">
<pathelement path="${basedir}/src/core"/>
<pathelement path="${basedir}/src/shared_code"/>
</path>
 
<path id="project.reshandler.src.path">
<pathelement path="${basedir}/reshandler"/>
<pathelement path="${basedir}/src/shared_code"/>
</path>
The _FunctionDemo_ sample application provides an example of this shared code setup.
Sample Resource Handler Code
You can find examples of basic and complex resource handler logic in all the samples applications provided with Mobile Designer.
Accessing Resources in Your Application Code
Your resource handler defines the resources available to your application. For information about how to use the resources in your application code, see Accessing Resources in Your Application Code.
Copyright © 2007-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback