Java Primefaces拾取列表数据未从源传输到目标
我在JavaWeb应用程序中使用了一个选择列表。但当我测试它时,值并没有移动到目标列表。我单独做了这件事,效果很好。然后我复制了代码并将其粘贴到我的原始页面,当它不工作时,我不明白为什么需要帮助 这是我的xhtml工作代码:Java Primefaces拾取列表数据未从源传输到目标,java,xhtml,primefaces,Java,Xhtml,Primefaces,我在JavaWeb应用程序中使用了一个选择列表。但当我测试它时,值并没有移动到目标列表。我单独做了这件事,效果很好。然后我复制了代码并将其粘贴到我的原始页面,当它不工作时,我不明白为什么需要帮助 这是我的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
<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>
Mobitel-IPP-区域
基本挑选名单
我用标签复制了这张照片并粘贴了原件,但不起作用这是原件:
<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"/>
Mobitel-IPP-区域
-->
#{area.instanceName}
showEffect=“fade”hideEffect=“explode”modal=“true”>
{resource}
-->
基本挑选名单
第一个选择列表工作,第二个选择列表在“编辑资源”选项卡中出现问题
这是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);
}
private-ListaddResourceIpSource=new-ArrayList();
private ListaddResourceIpTarget=新的ArrayList();
私有DualListModel AddResorcesipList;
public void setIpSource()引发SQLException,ClassNotFoundException{
String q=“从ipp.resource中选择*”;
ResultSet result=DB_Access.getData(q);
while(result.next()){
resourceRow r=新的resourceRow();
r、 setIpAddress(result.getString(1));
addResourceIpSource.add(result.getString(1));
}
//add(“为perticular实例选择资源…”);
//ipList=新的DualListModel(ipSource、ipTarget);
AddResorcesipList=新的DualListModel(addResourceIpSource,addResourceIpTarget);
}
函数是在类构造函数中调用的…我以前也遇到过类似的问题。下面的使用一开始不会被警告,但它可能会使primeface逻辑混乱。不要像下面这样使用
<h:form>
<h:form></h:form>
</h:form>
这里有嵌套表单。您不能嵌套不可接受的表单
标记。抱歉,我没有足够的声誉更新一点。。。。添加了一个下拉列表(在菜单上选择),并在使用ajax从下拉列表中选择值时设置加载源
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);
}
<h:form>
<h:form></h:form>
</h:form>