Java action not launching on onChange

Hello,
As usual, I make my call to a java method in this way:

<field name="archived" title="Archiver" onChange="com-axelor-apps-contract-method-testAppel"/>

  <!-- Action methode JAVA -->
  <action-method name="com-axelor-apps-contract-method-testAppel">
    <call class="com.axelor.apps.contract.web.ContractController" method="testAppel"/>
  </action-method>

But it doesn’t work… my java class is this one. Looks like the onChange event is not firing on check of the archived button.

package com.axelor.apps.contract.web;

import com.axelor.rpc.ActionRequest;
import com.axelor.rpc.ActionResponse;

public class ContractController {

  public void testAppel(ActionRequest request, ActionResponse response) {
	  response.setAlert("Mon appel marche !");
  }
}

An idea ? Please.

Can’t put an onChange on the default archived field of axelor ?

have you tried following instead of field

button onChange

Hello Siddique,

I don’t understand what you said? Otherwise it is the default « Archived » checkbox of axelor. You want me to try with a button?

<button onClick="action-contract-method-archiverRecurcifExec" name="test" title="test"/>

When I do a test with a button I get this error :

java.lang.NoSuchMethodException: com.axelor.apps.contract.web.ContractController.archiverRecurcifExec(com.axelor.rpc.ActionRequest, com.axelor.rpc.ActionResponse)
	at java.lang.Class.getMethod(Class.java:1786)
	at com.axelor.meta.ActionHandler.call(ActionHandler.java:254)
	at com.axelor.meta.schema.actions.ActionMethod.evaluate(ActionMethod.java:76)
	at com.axelor.meta.schema.actions.Action.execute(Action.java:100)
	at com.axelor.meta.schema.actions.Action.wrap(Action.java:109)
	at com.axelor.meta.schema.actions.ActionGroup.evaluate(ActionGroup.java:231)
	at com.axelor.meta.schema.actions.Action.execute(Action.java:96)

at least it executes my action with a button even if it’s not the desired operation.

<action-method name="action-contract-method-archiverRecurcifExec">
    <call class="com.axelor.apps.contract.web.ContractController" method="archiverRecurcifExec"/>
  </action-method>

In my Controller i have this :

package com.axelor.apps.contract.web;

import com.axelor.apps.contract.service.ContractService;
import com.axelor.apps.project.db.Project;
import com.axelor.inject.Beans;
import com.axelor.rpc.ActionRequest;
import com.axelor.rpc.ActionResponse;
import java.util.List;

public class ContractController {

public void archiverRecurcifExec(ActionRequest request, ActionResponse response) {

}

I don’t understand the problem. I do as usual… Am I making a mistake?

When you write a new function, a new class or change the function signature, you must restart your server. Have you do this ?

I just created another method with another call and the call works…why? database ?

<button onClick="action-contract-method-archiveur" name="test" title="test"/>

<action-method name="action-contract-method-archiveur">
        <call class="com.axelor.apps.contract.web.ContractsController" method="archiveur"/>
      </action-method>


package com.axelor.apps.contract.web;

import com.axelor.rpc.ActionRequest;
import com.axelor.rpc.ActionResponse;

    public class ContractsController {
      public void archiveur(ActionRequest request, ActionResponse response) {
        response.setAlert("JE SUIS EXECUTE !");
      }
    }
1 J'aime

Maybe you forget to reload your views ?

no I always reload the views. And nothing. After the database may need to be restored … I don’t know

Your code helped me a lot. Thank you.

Hi rcarreon-autronic

No problem :wink:

la solution se trouve dans un autre topic :

1 J'aime

La logique d’utiliser on onChange couplé à une action method était bonne, qu’est ce qui n’allez pas précisement ?

You had to add the widget parameter =« inline-chekbox »

To make it work on the field.

1 J'aime

Widget is related to the style how the checkbox works