Just curious, CAI seems to have some weird behaviour when the Adapter object gets created the first time. It seems to call all the get* methods in the class even if they are user created public void get* methods. Changing this to a private void get* seems to fix the problem but why does it do this?
Heres my test XML and Java code.
// This class is a generated one.
import java.util.*;
import com.softwareag.cis.server.*;
import com.softwareag.cis.server.util.*;
import com.softwareag.cis.util.*;
public class IndexAdapter
extends Adapter
{
/** */
public void test()
{
// TODO Auto-generated method stub
}
public void getwhateva()
{
System.out.println("testing");
}
private void getwhateva2()
{
System.out.println("testing23");
}
}
…you are right. We should only call get-methods returning something… (on the other hand: to name a method get* and not return something is against all programming styles… ;-)…).
Please have a look into the Developer’s Guid chapter “Binding between page and adapter” to get detailled infos on which get methods are called at which point of time.
Thanks Bjoern, that makes more sense after reading the developers guide.
I haven’t programmed in an object oriented language for a while, Natural programming for the past few years, so I do tend to use get in a different sense of the word. :oops:
On a side note can we suggest features or something for the IDE somewhere? or just directly in this forum?
Let’s say I have 5 objects in the layout. Let’s say all these objects have getters. Plus to these getters there are 5 getters not related to layout objects (whatever the reason to have them public). CAI calls all 10 methods with get* irrespectively. What is the rational behind that behavior? Shouldn’t CAI call just related 5 get methods? :?
to be very precise: when we have an object (e.g. an adapter) then we…
/1/ always process the get-ters for simple types (String/int/…/Integer/…/CDate/…)
/2/ process these getters for “complex” objects which are required from page point of view
The reason behind: “it was always done this way” - we always a little bit mis-trust that controls are 100% correct in referencing the properties they require. We keep this information internally (and e.g. use it inside the code assistant part of the layout editor) but are not brave enough to use this also at runtime. - This answer is true and honest ;-), maybe we are braver in one of the next releases.
BTW: there is a special interface with which you can tell us not to collect some properties:
package com.softwareag.cis.server;
/**
Adapter classes and other classes that are accessed by the CI
runtime in order to provide for data to be send to the browser client
may optionally implement this interface in order to fine-tune the
property access.
The interface is used the first time an object is accessed, afterwards
the CISrunimte internally buffers the data and does not access
the interface anymore. /
public interface IControlPropertyAccess
{
/*
When CISaccesses an object ot collect data then all
properties are collected that represent simple data type
objects. Simple data type objects are of class: int/ Integer/
String/ float/ Float/ BigDecimal/ and more.
With this method you can define get-Porperties that are not
accessed by CISand as consequence are not transferred
to the browser client.
This method is only relevant for get-Properties that are
implemented as corresponding get-methods. Dynamic properties
that you may provide by using IDynamicAccess interface are not
trreated.
*/
public String findPropertiesNotToBeCollected();
}
I implemented the IControlPropertyAccess interface and wrote some method names in the method findPropertiesNotToBeCollected(). But some of these methods are called anyway (although they are not called via the xml-file).
Is there something wrong in the method?
public class Test implements IControlPropertyAccess
{
public String getTestSystem() throws SomeException
{
// ....
}
public int getTimestampStatus() throws SomeException
{
// ...
}
/**
* @see com.softwareag.cis.server.IControlPropertyAccess#findPropertiesNotToBeCollected()
*/
public String[] findPropertiesNotToBeCollected()
{
String toReturn[] = {
"getTimestampStatus", "getTestSystem" };
return toReturn;
}
}
Sorry, I am a bit confused: getName() on grid item level should not be called anymore according to your interface implementation. If it is used in the grid or not - this is not relevant, the interface just decides not to use it.
Is this matching your problem? If not: please tell me what you expect to happen in the code above or what you expect not to happen…
I expected that getName() would be called by LayoutA and getValue() by LayoutB independent from the content in findPropertiesNotToBeCollected. Otherwise, this method doesn’t make much sense in my opinion because that would be like “take all or nothing” (either all methods would be called - regardless if they are really called by the xml file - or none of them).
I hope you understand my problem now a bit better…
Is there no possibilty to call only the getter methods which are really used by the current xml file?
For example: if I display all customers in a grid with their names and ids, I do not want that the method getOrders() in the customer class is also called which I perhaps need for another grid in another xml file.