2014-02-25 13 views
0

我有以下的方法休眠DAOImpl,傳遞一個變量作爲參數..找不到方法[的someMethod]與[1]參數

public List<Oportunidad> verParticipantes(String numeroOportunidad) throws DAOException { 
    List<Oportunidad> lista = getHibernateTemplate().find("SELECT c.cliente FROM Oportunidad o ,OportunidadParticipante op," 
      + "Cliente c WHERE op.oportunidad=o.id and c.idCliente=op.cliente and o.numeroOportunidad=?",numeroOportunidad); 
    return lista; 
} 

和ServiceImpl

public List<Oportunidad> verParticipantes(String numeroOportunidad)throws DAOException {  
    return getOportunidadDao().verParticipantes(numeroOportunidad); 
} 

此在兩者中都使用接口。 這些編譯和運行與junit做測試。 goog,很好


的問題是,當我想通過參數從selectOneListboxt實現的JSF primefaces

代碼ManagedBean:

public String getVerParticipantes(String numeroOportunidad) throws DAOException{ 
    Oportunidad o = new Oportunidad(); 
    o.setNumeroOportunidad(numeroOportunidad); 
     verParticipantes.addAll(getOportunidadService().verParticipantes(numeroOportunidad)); 
    return "envioCotizacion.xhtml"; 
} 

JSF代碼(XHTML):

<p:selectOneListbox id="listaCliente" value="#{clienteMB.cliente}" style="width:26%; height:90%; position:absolute; top:10%; left:12%;"> 
        <f:selectItems value='#{oportunidadMB.verParticipantes("prueba")}'/> 
        <!-- <f:param name="numeroOportunidad" value="prueba" />--> 
        <p:ajax id="numeroOportunidad" listener='#{oportunidadMB.verParticipantes("prueba")}'></p:ajax> 
       </p:selectOneListbox> 

錯誤屏幕:::::::::

javax.el.MethodNotFoundException: Unable to find method [verParticipantes] with [1] parameters 
    at javax.el.BeanELResolver.invoke(BeanELResolver.java:444) 
    at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:161) 
    at org.apache.el.parser.AstValue.getValue(AstValue.java:173) 
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) 
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) 
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) 
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) 
    at javax.faces.component.UISelectItems.getValue(UISelectItems.java:129) 
    at org.primefaces.renderkit.InputRenderer.getSelectItems(InputRenderer.java:55) 
    at org.primefaces.component.selectonelistbox.SelectOneListboxRenderer.encodeMarkup(SelectOneListboxRenderer.java:49) 
    at org.primefaces.component.selectonelistbox.SelectOneListboxRenderer.encodeEnd(SelectOneListboxRenderer.java:42) 
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863) 
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:176) 
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894) 
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:70) 
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57) 
    at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:51) 
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) 
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443) 
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) 

幫我貸款機構......不再出現此錯誤的事情。

回答

0

更改方法名稱getVerParticipantesverParticipantes。偵聽器方法不需要是一個getter。

此外,您不能將偵聽器作爲一個動作,所以它應該是返回類型的void,例如

public void getVerParticipantes(String numeroOportunidad) throws DAOException{ 
    Oportunidad o = new Oportunidad(); 
    o.setNumeroOportunidad(numeroOportunidad); 
     verParticipantes.addAll(getOportunidadService().verParticipantes(numeroOportunidad)); 
    //if you want to navigate then do here dynamically. 
} 
0
<f:selectItems value='#{oportunidadMB.verParticipantes("prueba")}'... 

應該

<f:selectItems value='#{oportunidadMB.getVerParticipantes("prueba")}'... 

但 getVerParticipantes也應該返回一個列表不是一個字符串!

public List<Oportunidad> verParticipantes(String numeroOportunidad)throws DAOException 

在服務聲明,但管理oportunidadMB只有方法getVerParticipantes至極返回一個字符串,而不是列表,你這樣怎麼能叫

value='#{oportunidadMB.verParticipantes("prueba")}' 
相關問題