This discussion is archived
4 Replies Latest reply: Nov 1, 2013 9:35 AM by inaser RSS

invoking bound method with argument problem

inaser Newbie
Currently Being Moderated

jdev version 11.1.2.4.0

Hello, i'm having issues invoking a method binded here:

 

<af:selectOneChoice label="Origem" id="soc1" value="#{bindings.DestacamentoDto.inputValue}">  
                    <af:forEach items="#{bindings.listDestacamentosOrigem.iteratorBinding.allRowsInRange}" var="origem">  
                       <!--  <af:selectItem value="#{origem.idDestacamento}" label="#{origem.codDestacamento}" id="si111"/>  -->
                    </af:forEach>  
                </af:selectOneChoice>

 

It calls my method:

 

listDestacamentosOrigem(MesaDto mesa) { ... }

 

I'm trying to invoke it on a method that opens the popup (wich is the selectOneChoice):

 

    public String novoTrem() {
        BindingContext bcx = BindingContext.getCurrent();
        DCBindingContainer bc = (DCBindingContainer)bcx.getCurrentBindingsEntry();
        OperationBinding opb = (OperationBinding)bc.getOperationBinding("listDestacamentosOrigem");
        // someMethod is with signature public void someMethod(String someArg)
        
        //
        MesaUsuarioAppMB mesaUsuarioBean = BeanUtil.getManagedBeanValue("MesaUsuarioAppMB");
        UsuarioSessionMB usuarioBean = BeanUtil.getManagedBeanValue("UsuarioSessionMB");
        MesaDto mesaEmUso = mesaUsuarioBean.getMesaPorUsuario(usuarioBean.getUsuarioDto());
        //
        opb.getParamsMap().put("mesa", mesaEmUso);
        opb.invoke();
        
        RichPopup popup = this.getPopupTrem();
        RichPopup.PopupHints hints = new RichPopup.PopupHints();
        popup.show(hints);
        return null;
    }

 

I can see the method on debugging the OperationBinding opb, put the params, but it doesn't invoke the method, i got an error when calling the JSFF:

 

Caused By: java.lang.Exception: Failed to invoke method: com.all.cs.domain.execucao.services.impl.execucaoService_s3qz1c_ExecucaoServiceImpl.listDestacamentosOrigem

 

Should I put the param in other way? wich one?

 

Thanks,

Icaro

  • 1. Re: invoking bound method with argument problem
    Cvele_new_account Expert
    Currently Being Moderated

    instead of

    opb.invoke();

     

    try with:

    opb.execute();

  • 2. Re: invoking bound method with argument problem
    inaser Newbie
    Currently Being Moderated

    Hi, thanks for the answer

     

    opb.execut(); not working too, still dont enter the method

     

    I made some tests, and:

    <NamedData NDName="mesa" NDValue="#{TremExecucaoMB.teste}" NDType="domain.planejamento.dto.MesaDto" NDOption="1"/>

    on pageDef works if I put a param in the value, but I dont have this parameter anywhere, and it doesn't work with NDValue pointing to a method..

     

    Still w/o solution on how to invoke bound method with parameters

  • 3. Re: invoking bound method with argument problem
    Cvele_new_account Expert
    Currently Being Moderated

    Put some "debug" statements (at least System.out.println()) somewhere, to see how statements executes.

    And, after the statement:

     

    opb.execute();


    check to see if there errors, ie:



    if (!opb.getErrors().isEmpty()) {

    System.err.println("There are errors !");

    }

  • 4. Re: invoking bound method with argument problem
    inaser Newbie
    Currently Being Moderated

    Couldn't get it to work, managed to change the way to populate my SelectOneChoice:

     

    ManagedBean:

    private List<SelectItem> listOrigem;
        public List<SelectItem> recuperarListaDestacamentosOrigem(MesaDto mesa) {
            return ADFUtils.parseSelectItem(service.listDestacamentosOrigem(mesa), "getId", "getValue");
        }
         //(service.listDestacamentosOrigem(mesa) is the method where i find the information and return List
    //somewhere in other method:
    this.listOrigem = recuperarListaDestacamentosOrigem(mesaEmUso);

     

    ADFUtils:

     

        public static List<SelectItem> parseSelectItem(List listaObject, String metodoValue, String metodoLabel) {
            if (listaObject != null) {
                return parseSelectItem(listaObject.toArray(), metodoValue, metodoLabel);
            } else {
                return Collections.emptyList();
            }
        }
         public static List<SelectItem> parseSelectItem(Object[] array, String metodoValue, String metodoLabel) {
             List<SelectItem> listSelectItem = new ArrayList<SelectItem>();
             for (Object item : array) {
                 Class cls = item.getClass();
                 Method methodValue;
                 try {
                     methodValue = cls.getMethod(metodoValue, null);
                     Object value = methodValue.invoke(item, null);
                     methodValue = cls.getMethod(metodoLabel, null);
                     Object label = methodValue.invoke(item, null);
                     SelectItem i = new SelectItem(value,(String)label);
                     listSelectItem.add(i);
                 } catch (NoSuchMethodException e) {
                     LOGGER.severe(JSFUtils.getStringFromBundle("MSG_LOG_ERRO"),e);
                 } catch (IllegalAccessException e) {
                     LOGGER.severe(JSFUtils.getStringFromBundle("MSG_LOG_ERRO"),e);
                 } catch (InvocationTargetException e) {
                     LOGGER.severe(JSFUtils.getStringFromBundle("MSG_LOG_ERRO"),e);
                 }
             }
             return listSelectItem;
         }

     

    page:

    <af:selectOneChoice label="Origem" id="soc1" autoSubmit="true">
                         <f:selectItems value="#{requestScope.TremExecucaoMB.listOrigem}" id="si7"/>
                    </af:selectOneChoice>

     

    now It's working, populate the SelectOneChoice w/o binding

    maybe this can be usefull for someone w/ the same problem as me

     

    thanks Cvele for showing up on my topic :]

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points