如何在p:selectOneListbox或h:selectOneListbox中使用Ajax?

时间:2018-03-01 07:59:52

标签: ajax jsf datatable listbox

我目前正在为我的学校开发一个项目,并希望将Ajax与Listbox和Datatable一起使用。我尝试过很多东西,但是他们没有工作。 如果我在列表框中选择一个项目,则没有任何反应。 这是我的.xhtml:

    <ui:define name="content">
    <f:view>
        <p:layout style="min-width:400px;min-height:300px;">
            <p:spacer width="400" height="10" />
            <p:layoutUnit position="west" minSize="400" header="List of Rooms">
                <h:form id="RoomForm">
                    <p:selectOneListbox id="list" value="#{roomBean.currentR.name}" onchange="submit()">
                        <f:selectItems value="#{roomBean.guideService.roomList}" var="r" itemLabel="#{r.name}"/>
                        <f:ajax render="PersonForm" execute="@this"/>
                    </p:selectOneListbox> 
                </h:form>  
            </p:layoutUnit>
            <p:layoutUnit position="center" visible="false"/>
            <p:layoutUnit position="east" minSize="700" header="List of Persons" rendered="#{roomBean.currentR.name}">
                <h:form id="PersonForm">
                    <h:dataTable var="pers" value="#{personBean.guideService.persList}">
                        <f:facet name="header">
                            <h:outputText value="List of Persons"/>
                        </f:facet>

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="First Name"/>
                            </f:facet>
                            <h:outputText value="#{pers.firstName}"/>
                        </h:column>

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Last Name"/>
                            </f:facet>
                            <h:outputText value="#{pers.lastName}"/>
                        </h:column>

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Age"/>
                            </f:facet>
                            <h:outputText value="#{pers.age}"/>
                        </h:column>

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Roomnumber"/>
                            </f:facet>
                            <h:outputText value="#{pers.roomNr}"/>
                        </h:column>

                        <h:column>
                            <h:commandLink value="edit" action="#{personBean.editPerson(pers)}"/>
                        </h:column>

                        <h:column>
                            <h:commandLink value="delete" action="#{personBean.delPerson(pers)}"/>
                        </h:column>
                    </h:dataTable>

                </h:form>
            </p:layoutUnit>

        </p:layout>
        <center>
            <p:commandButton value="New Room" action="createRoom"/>
            <p:commandButton value="New Person" action="createPers"/>
            <p:commandButton value="Delete Room" action="#{roomBean.delRoom(roomBean.currentR)}"/>
        </center>
    </f:view>
    </ui:define> 

现在我的问题:如果在列表框中选择了某些内容,我如何添加Ajax来呈现Datatable?

感谢您的帮助!

0 个答案:

没有答案
相关问题