Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 23 Next »


1. What is custom method?

You can create custom method and attach it to defined model or view. Using this elements, you can connect defined xml to JAVA code.

To create custom method first you must create service, then implement one or more custom methods. Then you insert reference to created method in xml files.

2. Create custom methods service

2.1. service structure

Custom methods service is basicly normal JAVA class. Only additional element is Spring '@Service' annotation.

import org.springframework.stereotype.Service;

@Service
public class ClassName {

       // CLASS BODY

}

2.2. additional services access

In created service you can access many additional services that helps you manipulate data or view.

Access to outside service are made by Spring '@Autowired' annotation.

import org.springframework.beans.factory.annotation.Autowired;

...

    @Autowired
    private ServiceType setviceName;

2.3. additional services

2.3.1. DataDefinitionService

TODO

2.3.2. TranslationService

TODO

2.3.3. SecurityService

TODO

3. custom methods

3.1. Custom validators

Custom validator is used by model to validate entities.

Custom validator function has structure:

public boolean validatorMethodName(final DataDefinition dataDefinition, final Entity entity) {

        // VALIDATOR METHOD BODY

}

Where

  • validatorMethodName - name of validator method
  • dataDefinition - dataDefinition of validated entity
  • entity - entity to validate

This method should return true if validation was successfull and false otherwise.

When validation was unsuccessfull you can also add validation message to entity field using construction:

   entity.addError(dataDefinition.getField("fieldName"), "validationMessage");

Where

  • fieldName - name of entity model field
  • validationMessage - validation message

2.2. Model hooks

Model hooks are methods that is executed on specific model actions (defined in xml file). Model hook method has structure:

public void modelHookMethodName(final DataDefinition dataDefinition, final Entity entity) {

        // MODEL HOOK BODY

}

Where

  • modelHookMethodName - name of model hook method
  • dataDefinition - dataDefinition of hook event entity
  • entity - hook event entity

2.3. View hooks

TODO

1
2
3
4
5
6

2.4. View listeners

TODO

1
2
3
4
5
6

3. Example

TODO

  • No labels