In ATG, in order to create a component we first create a java class with default constructor along with its configuration file. What if I want to have a parameterized constructor for my class. Can I create a component now with this? If yes, explain how this can be done and how to pass those parameters. If no, give the reason for it.
Asked
Active
Viewed 258 times
1 Answers
1
we can create parameterized constructor in ATG and you can achive this as follows.
package mycompany;
public class MyClass {
private String mystring;
private int mynumber;
// The constructor requires two arguments.
public MyClass (String pMyString, int pMyNumber) {
mystring = pMyString;
mynumber = pMyNumber;
}
public String getmMyString() {
return mystring;
}
public int getmMyNumber() {
return mynumber;
}
}
and components for this.
$class=mycompany.MyClass
$instanceFactory=/atg/dynamo/nucleus/ParameterConstructorInstanceFactory
$constructor.param[0].value=Hello
$constructor.param[0].type=String
$constructor.param[1].value=321
$constructor.param[1].type=int
for details please follow atg doc. http://docs.oracle.com/cd/E36434_01/Platform.10-1-2/ATGPlatformProgGuide/html/s0208parameterconstructorinstancefact01.html

sumit sharma
- 1,067
- 8
- 24