1

我在 java web 应用程序中使用了一个pickList。但是当我测试它的值并没有移动到目标列表时。我单独做了这个,它工作得很好。然后我复制了代码并将其粘贴到我的原始页面中,但它不起作用我不明白为什么需要帮助

这是我的工作 xhtml 代码:

    <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <title>Mobitel - IPP - Areas</title>
</h:head>
<h:body>
    <h:form>
       <p:tabView id="areas_TV" activeIndex="1">  
            <p:tab id="create_area_T" title="Create">      
                <p:growl id="msg" showDetail="true" escape="false" />
                <h3 style="margin-top:0">Basic PickList</h3>
                <p:pickList id="pickList" value="#{a_Area1.addResorcesipList}" var="city" 
                itemLabel="#{city}" itemValue="#{city}" />
                <p:commandButton id="citySubmit" value="Submit" 
                update="displayCities" oncomplete="cityDialog.show()" style="margin-top:5px"/>
                <p:dialog modal="true" showEffect="fade" hideEffect="fade" widgetVar="cityDialog">
                    <h:panelGrid id="displayCities" columns="2">
                        <h:outputText value="Source: " style="font-weight:bold"/>
                        <ui:repeat value="#{a_Area1.addResorcesipList.source}" var="item">
                            <h:outputText value="#{item}" style="margin-right:5px" />
                        </ui:repeat>

                        <h:outputText value="Target: " style="font-weight:bold"/>
                        <ui:repeat value="#{a_Area1.addResorcesipList.target}"var="item">
                            <h:outputText value="#{item}" style="margin-right:5px" />
                        </ui:repeat>
                    </h:panelGrid>
                </p:dialog>
            </p:tab>
       </p:tabView>
    </h:form>
</h:body>

我用标签复制了这个并粘贴在原始文件中,但没有工作,这是原始文件:

    <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <title>Mobitel - IPP - Areas</title>
</h:head>
<h:body>
    <p:layout fullPage="true" id="layout">  

        <p:layoutUnit position="north" size="20%" resizable="false">
            <h:form id="TopMenuBarItems_F">
                <p:menu  id="TopMenuBar"> 
                    <f:facet name="aaa">
                        <h:form id="topform">
                            <p:menuButton id="logout_MBtn" value="Logout" style="margin-right:10px"/>
                        </h:form>                            
                    </f:facet>                                             
                </p:menu> 
            </h:form>

        </p:layoutUnit>  
        <p:layoutUnit position="center">  

            <h:form id="tabMenuItems_F">

                <p:tabMenu activeIndex="2">
                    <p:menuitem id="instance_M" value="Instance" url="/faces/A_Instance.xhtml"/>
                    <p:menuitem id="resources_M" value="Resources" url="/faces/A_Resources.xhtml"/>
                    <p:menuitem id="areas" value="Areas" url="/faces/A_Areas.xhtml"/>
                    <p:menuitem id="subnets_M" value="Subnets" url="/faces/A_Subnet.xhtml"/>
                    <p:menuitem id="vlsm" value="VLSM" url="/faces/A_VLSM.xhtml"/>
                    <p:menuitem id="ipAddress" value="IP Address" url="/faces/A_IP_Address.xhtml"/>

                    <p:menuitem id="logout_MBtn" value="Logout" icon="ui-icon-extlink" style="margin-right:10px"/>
                </p:tabMenu>

                <p:tabView id="areas_TV" activeIndex="1"> 

                    <p:tab id="create_area_T" title="Create">
                        <p:growl id="msg2"/>
                        <h:panelGrid columns="2" cellpadding="10">
                        <h:outputText value="AreaName :"/>
                        <p:inputText id ="areaNAme_Tbx" value="#{a_Area1.areaName}"  />
                        <h:outputText value="Instance :"/>
                        <p:selectOneMenu id="suburbs" value="#{a_Area1.selectedInstanceId}"  >  
                                <f:selectItem itemLabel="Select instance" itemValue="" />  
                                <f:selectItems value="#{a_Area1.instanceList}" />  

                            <p:ajax event="change" update=":tabMenuItems_F:areas_TV:msg2,:tabMenuItems_F:areas_TV:pickList"   
                listener="#{a_Area1.setIpSource2(a_Area1.selectedInstanceId)}"/>  

                        </p:selectOneMenu>
                        </h:panelGrid>
                        <h:outputText value="Resources :"/>                            

                        <p:pickList id="pickList" value="#{a_Area1.ipList}" var="ip" 
            itemLabel="#{ip}" itemValue="#{ip}" />

                        <p:commandButton id="citySubmit" value="Submit" update=":tabMenuItems_F:areas_TV:msg2" action="#{a_Area1.createArea()}"  style="margin-top:5px"/>

    <h:panelGrid id="displayCities" columns="2">
        <h:outputText value="Source: " style="font-weight:bold"/>
        <ui:repeat value="#{a_Area1.ipList.source}" var="item">
            <h:outputText value="#{item}" style="margin-right:5px" />
        </ui:repeat>

        <h:outputText value="Target: " style="font-weight:bold"/>
        <ui:repeat value="#{a_Area1.ipList.target}" var="item">
            <h:outputText value="#{item}" style="margin-right:5px" />
        </ui:repeat>
    </h:panelGrid>
</p:dialog>
                                                 -->
               </p:tab>
                       <p:tab id="view_area_T" title="View">
                     <h:panelGrid columns="1" cellpadding="10">                            
                         <h:form id="area_Tbl">
                                <p:dataTable id="Area_dataTable" var="area" value="#{a_Area1.areaList}" editable="true">  

                                    <p:ajax event="rowEdit" listener="#{a_Area1.onEdit(area)}" />


                                    <p:column id="areaName_Clm" filterBy="#{area.areaName}"    
                                    headerText="Area Name" filterMatchMode="startsWith" >
                                        <p:cellEditor>
                                            <f:facet name="output">
                                                <h:outputText value="#{area.areaName}" />
                                            </f:facet>
                                            <f:facet name="input">
                                                <p:inputText value="#{area.areaName}"/>
                                            </f:facet>
                                        </p:cellEditor>
                                    </p:column>

                                    <p:column id="InstanceName_Clm" filterBy="#{area.areaName}"    
                                    headerText="Area Name" filterMatchMode="startsWith" >
                                        #{area.instanceName}
                                    </p:column>

                                    <p:column style="width:6%">  
                                        <p:rowEditor/>
                                    </p:column>

                                    <p:column style="width:20%" headerText="Delete Area">  
                                        <p:commandLink id="delete_btn" value="Delete"  actionListener="#{a_Area1.deleteArea(area)}" 
                                                       update=":tabMenuItems_F:areas_TV:area_Tbl:Area_dataTable:" 
                                        process=":tabMenuItems_F:areas_TV:area_Tbl:Area_dataTable:">
                                            <p:collector value="#{area}" removeFrom="#{a_Area1.areaList}" />
                                        </p:commandLink>
                                    </p:column>
                                </p:dataTable>

showEffect="fade" hideEffect="explode" modal="true">

                                    <h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">  

                                        <h:outputText value="Resource IP"/>

                                        <p:dataList value="{a_Area1.selectedRow.resourceList}" var="resource" itemType="disc">  
                                                          {resource}  
                                        </p:dataList>  


                                    </h:panelGrid>  

                               </p:dialog>                                  
                                    -->
                            </h:form>
                        </h:panelGrid>  

                    </p:tab> 

                 <p:tab id="edit_resorce_area_T" title="Edit Resource">
                    <h3 style="margin-top:0">Basic PickList</h3>

<p:pickList id="pickList1" value="#{a_Area1.addResorcesipList}" var="city" 
            itemLabel="#{city}" itemValue="#{city}" />

<p:commandButton id="citySubmit1" value="Submit" update="displayCities" oncomplete="cityDialog.show()" style="margin-top:5px"/>



<p:dialog modal="true" showEffect="fade" hideEffect="fade" widgetVar="cityDialog">

    <h:panelGrid id="displayCities" columns="2">
        <h:outputText value="Source: " style="font-weight:bold"/>
        <ui:repeat value="#{a_Area1.addResorcesipList.source}" var="item1">
            <h:outputText value="#{item1}" style="margin-right:5px" />
        </ui:repeat>

        <h:outputText value="Target: " style="font-weight:bold"/>
        <ui:repeat value="#{a_Area1.addResorcesipList.target}" var="item1">
            <h:outputText value="#{item1}" style="margin-right:5px" />
        </ui:repeat>
    </h:panelGrid>

</p:dialog>
                  </p:tab>
               </p:tabView>

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

第一个选项列表有效,而编辑资源选项卡中的第二个选项有问题..

这是java文件:

    private List<String>addResourceIpSource = new ArrayList<String>();
    private List<String>addResourceIpTarget = new ArrayList<String>();
    private DualListModel<String> AddResorcesipList;
        public void setIpSource() throws SQLException, ClassNotFoundException{



    String q = "SELECT * FROM ipp.resource;";
        ResultSet result = DB_Access.getData(q);

        while(result.next()){
            resourceRow r = new resourceRow();
            r.setIpAddress(result.getString(1));
            addResourceIpSource.add(result.getString(1)); 

        }
  //ipSource.add("select resource for perticuler instance.."); 
    // ipList = new DualListModel<String>(ipSource, ipTarget);
     AddResorcesipList = new DualListModel<String>(addResourceIpSource, addResourceIpTarget);
}

函数在类构造函数中被调用......

4

1 回答 1

2

我以前也有类似的问题。跟随 using 一开始并不会发出警报,但它可能会使 primeface 逻辑混乱。不要像下面这样使用。

<h:form>
<h:form></h:form>
</h:form>
于 2013-03-01T08:53:04.547 回答