Mobile Development 10.11 | webMethods Mobile SuiteWeb Help | Using webMethods Mobile Designer | Creating Mobile Application Projects | Defining Resources for a Mobile Application Project | Coding the Resource Handler
 
Coding the Resource Handler
 
Using Resource Blocks and Resource Packs
Deprecated. It is still possible but not preferable to 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.
*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>
Sample Resource Handler Code
Most applications generated with Mobile Development will not need to edit the resource handler, as Mobile Development will manage resources for you. If you want to implement custom logic, NativeUI Demo New provides a simple example of how the resource handler may be used.
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.