提问人:Albyx97 提问时间:7/29/2018 最后编辑:KukeltjeAlbyx97 更新时间:7/29/2018 访问量:89
f:ajax 不会使用从 selectOneMenu [duplicate] 中选择的值呈现 DataTable
f:ajax doesn't render DataTable with a value choosen from selectOneMenu [duplicate]
问:
我正在尝试使用a根据先前选择的值显示dataTable。DataTable 不会被呈现,我也尝试过或没有 panelGroup 或指定事件或执行,但它不起作用。我不知道如何解决它。代码如下:<f:selectOneMenu>
<f:ajax render="tabella">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://java.sun.com/jsf/core">
<ui:composition template="/template.xhtml">
<ui:define name="content">
<h:form id="form1">
<h:panelGroup id="pannello" >
<h:selectOneMenu id="marcaScelta" value="#{marcaController.marca}" >
<f:selectItem itemLabel="Scegli una marca"/>
<f:selectItems value="#{marcaController.listaMarche()}" var="m" itemLabel="#{m.nome}" itemValue="#{m.nome}">
</f:selectItems>
<f:ajax render="pannello form1" />
</h:selectOneMenu>
<h1 align="center"> Elenco prodotti #{marcaController.marca.nome} </h1>
<h:dataTable id="tabella" value="#{marcaController.marca.prodotti}" var="prodotto">
<h:column>
<f:facet name="header">
<h:outputText value="Nome" />
</f:facet>
<h:outputText value="#{prodotto.nome}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Prezzo" />
</f:facet>
<h:outputText value="#{prodotto.prezzo}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Quantita" />
</f:facet>
<h:outputText value="#{prodotto.quantita}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Azioni" />
</f:facet>
<h:commandLink action="#{carrelloController.aggiungiAlCarrello(prodotto)}" value="Aggiungi al Carrello"></h:commandLink>
</h:column>
</h:dataTable>
</h:panelGroup>
</h:form>
</ui:define>
</ui:composition>
</html>
答:
-2赞
Vinh Can Code
7/29/2018
#1
我认为没有添加列表。因此,您可以执行以下操作:
- 向 marcaController 添加一个新方法,例如 'public void doChangeXX()'
- 取代
< f:ajax render=“pannello form1” />
跟
<f:ajax listener="#{marcaController.doChangeXX}" render="pannello form1" />
希望这有帮助。
评论
0赞
Albyx97
7/29/2018
嗨,我试过了,但似乎没有调用该方法,因为它里面的打印没有显示在控制台上。我也不知道这种方法中的确切句柄是什么。
0赞
Vinh Can Code
7/29/2018
您能否在代码中显示 doChangeXX 函数,它应该更新 marca.prodotti 对象以更改表“tabella”。
2赞
Kukeltje
7/29/2018
不需要监听器...
0赞
Vinh Can Code
7/29/2018
查看 BalusC 的答案:stackoverflow.com/questions/6089924/...
上一个:从后备 Bean 更新嵌套面板
评论