IDynamicAccess

Hi,
we are using the IDynamicAccess Interface for our Adapter.
Our goal is to have a generic adapter which uses the name of the property (valueprop) to navigate through out Data Model (the property names (valueprop) are OGNL-like Expressions)
Unfortunately the is a method called “findDynamicAccessProperties()” which returns an array of property names.
It seems it is necessary to return all the strings in this method which we use as property names in our XML Page descriptions.
Is this true?
Is it possible to get around this behavior?

Best regard,
Matthias

Hi Matthias,

yes - the App Designer runtime asks the adapter for dynamic properties (…by calling this method “findDynamicAccessProperties”…). I do not see a possibility to get around this. The adapter (your app) is the one to know which properties are relevant for the page. Not a very positive answer - sorry.

Martin

Hi Matrin,
the only solution I can think of would be to use some API to access the XML defining the page and retrieve the valueProps defined in there.

The issue i see there is: performance (parsing xml on every call to findDynamicAccessProperties() might be costly, solution: caching)

best regards,
Matthias

PS: Thanks for the really quick answer!!

Hi Martin,
or anybody elso who knows the answer.
Which API do I have to use to access the values of the “valueprop” properties contained in my layout (xml file).
Is this the only way:
String layout = Info.getXMLLayout(“Vertrag_Oap_Gui_Referenz”, “oap_gui_ref_2.xml”);

… …

best regards,
Matthias

Hi!

I had some similiar problems in conjunction to some other scenario.
I wanted to store some specific template version inside the xml and also retrieve that version out of the xml.
What I did is:

//First create a file:
String layoutPath = Params.getLayoutDirectoryName(project,true)+layout+“.xml”;
String templateVersion = “1.0”;
File layoutFile = new File (layoutPath);

if(layoutFile.exists()){
System.out.println(“Layout exists!”);
System.out.println("With Version = " + getTemplateVersion(layoutPath));
}

In the method getTemplateVersion I did some “intelligent” parsing:

private String getTemplateVersion(String path){

Document myDocument = null;
	
try 
{			
	DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
	     DocumentBuilder parser = null;
	     
		try 
		{
			parser = factory.newDocumentBuilder();
		} 
		catch (ParserConfigurationException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
			return null;
		}
	      
	      // Check for the traversal module
	      DOMImplementation impl = parser.getDOMImplementation();
	      if (!impl.hasFeature("traversal", "2.0")) {
	        System.out.println(
	         "A DOM implementation that supports traversal is required."
	        );  
	        return null;
	      }

		SAXReader reader = new SAXReader();			
	      try 
	      {
	    	  File inputFile = new File(path);
	    	  if(inputFile.exists()) 
	    		  System.out.println("File exists with Path: "+inputFile.getPath());
	    	  
	    	  // Read the document
	    	  myDocument = parser.parse(inputFile);
	    	  
		} catch (IOException e) {
			System.out.println("Error during reading XML file");
			e.printStackTrace();
			return null;
		} 
		
	    // iterate through xml nodes
        DocumentTraversal traversable = (DocumentTraversal) myDocument;
        NodeIterator iterator = traversable.createNodeIterator(myDocument, NodeFilter.SHOW_ALL, null, true);

        // Iterate over the comments
        Node node;            
        while ((node = iterator.nextNode()) != null) {
        	
        	if(node.getNodeName().equals("page")){
        		if(node.getAttributes().getNamedItem("templateVersion") != null)
        			return node.getAttributes().getNamedItem("templateVersion").getNodeValue();
        		else
        			return "-1.0";
        	}
          
        }//end while
		  
	} catch(SAXException e) {			  
			e.printStackTrace();
			return "-1.0";
		  
	} catch(NullPointerException e) {			
		e.printStackTrace();
		return "-1.0";

	}
	
	return "1.0";

}

If you need more code just contact me directly, my abbr. is KOKI.

Cheers,

Konstantin

Hi Matthias,

in case of dynamic pages (ie the page is generated on runtime) you may think about to “link” the one who generated the page with the one one who serves the page (ie your dynamic adapter). E.g. collect each “valueprop” within a hashtable when building up the XML and pass this information (hashtable) to the page adapter. With that you can avoid the step to parse the layout again.

Martin