Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

6. Hooks and Listeners

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

...

Hooks have to be grouped in tag:

Code Block
themeEclipse
languagexml
themeEclipse
linenumberstrue

<hooks>

     // HOOK DEFINITIONS

</hooks>

Every hook has structure:

Code Block
themeEclipse
languagexmlthemeEclipse
linenumberstrue

<hookType class="className" method="beanMethod" />

...

6.1.1. view hook types

hook type

description

beforeInitalize beforeInitialize

This hook is executed before view state initialization

afterInitialize

This hook is executed after initialization, but before event execution

beforeRender

This is most common used hook type. This hook is executed after event execution, just before response is send to clients browser

...

Anchor
viewListeners
viewListeners

Refreshing ribbon after hook's change we must:

  • call button.requestUpdate(true) on ribbon action item
  • call window.requestRibbonRender() on window component.

6.2. listeners

6.2.1 view listener structure

Listeners are methods that will be executed when specified event is fired. Every listener has structure:

Code Block
themeEclipse
languagexmlthemeEclipse
linenumberstrue

<listener event="eventname" class="className" method="beanMethod" />

...

  • eventname - name of event on which this lisiner is waiting
  • className - class (path + name) which contains listener method
  • beanMethod - name of listener method that should be executed when event is fired
6.2.2 view listener event names
nameusage
onInputChange
Code Block
languagexml
<layoutElement column="2" row="2">
	<component type="input" name="quantity" field="quantity" reference="quantity">
		<option type="alignment" value="right" />
		<listener event="onInputChange" method="someMethod" class="someClass" />
    </component>
</layoutElement>
onSelectedEntityChange
Code Block
languagexml
<layoutElement column="2" row="1">
	<component type="lookup" name="product" reference="product" field="product">
		<option type="column" name="name" fields="name" link="true" />
		<option type="searchable" value="name,number" />
	    <option type="orderable" value="name,number" />
	    <option type="expression" value="#number + ' - ' + #name" />
	    <option type="fieldCode" value="number" />
	    <listener event="onSelectedEntityChange" method="someMethod" class="someClass" />
    </component>
</layoutElement>

For more informations about listeners see 'view listeners section'

Anchor
rowStyleResolvers
rowStyleResolvers

6.3. row style resolvers

Row style resolvers returns set of CSS clas names for given row entity. You can use them to mark specified grid rows, e.g. whith negative balance of some arbitrary values. 
Resolver method is invoked for each of grid's entity.

Info

Currently row style resolvers can be used only with grid or lookup component.

Every resolver has structure:

Code Block
themeEclipse
languagexml
linenumberstrue
<rowStyleResolver class="className" method="beanMethod" />

Where:

  • className - class (package path + name) which contains resolver method
  • beanMethod - name of resolver method that should be executed for each of row entity

For more informations about row style resolvers see 'row style resolvers section'.

6.4. criteria modifiers

Criteria modifiers allow you to modify state of SearchCriteriaBuilder used by given view component to fetch row entities.

Info

Currently criteria modifiers can be used only with grid or lookup component.

Every modifier has structure:

Code Block
themeEclipse
languagexml
linenumberstrue
<criteriaModifier class="className" method="beanMethod" />

Where:

  • className - class (package path + name) which contains modifier method
  • beanMethod - name of method

For more informations about criteria modifier see 'criteria modifier section'.