Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
f:ajax没有';t使用从SelectOne菜单中选择的值呈现数据表_Ajax_Jsf_Xhtml - Fatal编程技术网

f:ajax没有';t使用从SelectOne菜单中选择的值呈现数据表

f:ajax没有';t使用从SelectOne菜单中选择的值呈现数据表,ajax,jsf,xhtml,Ajax,Jsf,Xhtml,我试图使用来显示基于先前选择的值的数据表。没有呈现DataTable,我也尝试了,或者没有使用panelGroup,或者没有指定event或excecute,但是没有效果。我不知道怎么解决它。代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="

我试图使用
来显示基于先前选择的值的数据表。没有呈现DataTable,我也尝试了
,或者没有使用panelGroup,或者没有指定event或excecute,但是没有效果。我不知道怎么解决它。代码如下:

   <!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>

埃伦科·普罗多蒂{marcaController.marca.nome}

我认为没有添加listner。因此,您可以:

  • 向marcaController添加新方法,例如“public void doChangeXX()”
  • 替换
  • 
    

    希望有帮助。

    您好,我试过了,但似乎没有调用该方法,因为控制台上没有显示其中的打印。我也不知道这个方法中的确切句柄是什么。如果你能在代码中显示doChangeXX函数,它应该更新marca.prodotti对象以更改表“tabella”。不需要侦听器…请参阅BalusC的答案:
    <f:ajax listener="#{marcaController.doChangeXX}" render="pannello form1" />