Axelor Doc

Methods "contructor"

The Axelor platform can generate customizable manufacturer. The constructor arguments generated will all fields with the attribute initParam = "true" .

By default, an empty constructor is generated.

Example:

<entity name="Contact">
  ...
  <string name="firstName" required="true" initParam="true"/>
  <string name="lastName" required="true" initParam="true"/>
  <string name="email" required="true" unique="true" initParam="true" />
  ...
</entity>

The constructor is generated:

public Contact() {
}

public Contact(String firstName, String lastName, String email) {
  this.firstName = firstName;
  this.lastName = lastName;
  this.email = email;
}

Instances of the object contact can quickly be created with this constructor:

Contact c = new Contact("John", "Smith", "[email protected]");

By default, if the entity contains the fields name and / or code , then a constructor will be created automatically as arguments name and / or code without needing to specify initParam = "true".

In the case of an entity with fields named name and / or code .

<entity name="Title">
    <string name="code" required="true" unique="true"/>
    <string name="name" required="true" unique="true"/>
</entity>

The constructor below is generated:

public Title(String code, String name) {
    this.code = code;
    this.name = name;
}

The values used for the parameters of these manufacturers must be valid because they are used directly without going through a method "setter".