Sometimes you need to get detailed information about a page accessing its adapter. Or, in other words: you want to get a detailed list of all the properties and objects which are referenced by your page definition to the corresponding adapter object.
For this reason, there is the class
CheckAccessPath
in the
com.softwareag.cis.server
package providing this
information. The class has a getInstance()
method to
obtain an instance; the class has two additional methods:
public String[] findAccessedObjects(String application, String reference); public String[] findAccessedProperties(String application, String reference);
In both methods, the parameters are "application" and "reference". "application" is the application project in which a page is defined. "reference" is the name of the page itself, without ".xml".
The findAccessedObjects
method returns a String
array of all objects referenced in this page. An object is referenced if the
properties are not directly plugged to the adapter itself but to subobjects.
Example: if you bind a FIELD to the VALUEPROP
"address.street" then
"address" is the returned name.
The findAccessedProperties
method returns a
String array of all properties referenced in the page which are not complex
properties, but simple value properties.
In the cisdemos project (which is part of the installation), there is a
page "ShowAccessPaths" and the corresponding class
ShowAccessPathsAdapter
that shows an example of how to
use the CheckAccessPath
methods. The page allows you
to enter the application name and the page name, and returns a list of
referenced objects and properties:
In the class definition of the corresponding adapter, the code (finding the information about access paths) looks as follows:
// ------------------------------------------------------------------------ // inner classes // ------------------------------------------------------------------------ public class Info { // property >objects[*].name< // property >properties[*].name< String m_name; public String getName() { return m_name; } public void setName(String value) { m_name = value; } } // ------------------------------------------------------------------------ // property access // ------------------------------------------------------------------------ // property >app< String m_app = ""; public String getApp() { return m_app; } public void setApp(String value) { m_app = value; } // property >page< String m_page = ""; public String getPage() { return m_page; } public void setPage(String value) { m_page = value; } // array property >objects[*]< TEXTGRIDCollection m_objects = new TEXTGRIDCollection(); public TEXTGRIDCollection getObjects() { return m_objects; } // array property >properties[*]< TEXTGRIDCollection m_properties = new TEXTGRIDCollection(); public TEXTGRIDCollection getProperties() { return m_properties; } // ------------------------------------------------------------------------ // public usage // ------------------------------------------------------------------------ /** */ public void onShowAccessPath() { // check if (m_app.trim().length() == 0) { outputMessage(MT_ERROR,"Please specify application project"); return; } if (m_page.trim().length() == 0) { outputMessage(MT_ERROR,"Please specify page"); return; } // fill data m_properties.clear(); m_objects.clear(); String[] objects = CheckAccessPath.getInstance().findAccessedObjects(m_app,m_page); String[] properties = CheckAccessPath.getInstance().findAccessedProperties(m_app,m_page); for (int i=0; i<objects.length; i++) { Info info = new Info(); info.m_name = objects[i]; m_objects.add(info); } for (int i=0; i<properties.length; i++) { Info info = new Info(); info.m_name = properties[i]; m_properties.add(info); } } }