Search code examples
javagenexus

Call Genexus procedure stub in Java environment


I'm currently trying to create a procedure in Genexus 15 and call from Java Environment, but when I import the jar file to Java the function cannot be called.

I am creating a simple procedure with a stub as follows:

stub salvadados(in:&StringTeste, out:&StringRetorno)
   &StringRetorno = "ola " + &StringTeste
endstub

Genexus is generating the .jar file when deploying the application, then I import it on NetBeans. The import is successfull and it recognizes the procedure I created, but when I access its methods, there's no call for my stub.

My Java class is as follows. I want to call my stub in the Function EnviaDados.

import com.genexus.GXProcedure;
import com.genexus.GXutil;
import com.genexus.ModelContext;
import com.genexus.reports.GXcfg;
import com.kbtesteintegracao.projeto.ptesteintegracao;

public class IntegracaoGenexus extends GXProcedure {

    ptesteintegracao ptesteintegracao; 


    public void executeCmdLine(String args[]) {
        execute();
    }

    public IntegracaoGenexus(int remoteHandle) {
       super(remoteHandle, new ModelContext(IntegracaoGenexus.class), "");
    }

    public IntegracaoGenexus(int remoteHandle, ModelContext context) {
       super(remoteHandle, context, "");
    }

    public void iniciar() {
        ptesteintegracao = new ptesteintegracao(remoteHandle, context); 

    }

    public void EnviaDados(String strDados) {
        //ptesteintegracao.gxep_salvadados(strDados);
    }

    public void execute() {
       execute_int();
    }

    private void execute_int() {
       initialize();
       privateExecute();
    }

    private void privateExecute() {  
       new ptesteintegracao(remoteHandle, context).gxep_salvadados("teste");
       cleanup();
    }

    public static Object refClasses() {
       GXutil.refClasses(IntegracaoGenexus.class);
       return new GXcfg();
    }

    protected void cleanup() {
       CloseOpenCursors();
       exitApplication();
    }

    protected void CloseOpenCursors() {
    }

    /* Aggregate/select formulas */
    public void initialize() {
       /* GeneXus formulas. */
       Gx_err = (short)(0) ;
    }

    private short Gx_err ;

}

What I am missing? I appreciate any help.


Solution

  • I've found a solution. What I did was create a test Web Panel on my Genexus project and called the procedure I created. In this WPanel I just put a Button component that triggers the following event:

    Event 'Teste'
      ptesteintegracao.salvadados("oi", &retorno)
    Endevent
    

    I don't know why, but by making this call to my procedure, in some way it forced Genexus to recreate the .java file of my procedure, which it was not doing with the build, rebuild or Build with this only options. When recreated, my java class was with the function corresponding to my procedure stub.

    After that, I just deployed the application, generating a new .jar file and imported it on my NetBeans project and my function was available:

    ptesteintegracao.gxep_salvadados("teste", stringReturn);