感谢Makky的帮助!!!
工业化经理
<p:column styleClass="columnB" style="width:15%">
<ui:repeat var="input" value="#{bean.inputTexts}">
<p:inputText size="15" value="#{input}" />
</ui:repeat>
<b style="padding: 0px 0px 0px 18px">
<p:commandButton value="Add Manager" actionListener="#{bean.addInput}" update="tbl"
style=" margin-bottom:10px;width:auto;height:28px;font-style: normal; font-family:Arial;font-size: 13px; color: #000000;
text-align:center;font-weight: normal;text-decoration:none;cursor: pointer" /></b>
</p:column>
</p:row>
答案 0 :(得分:2)
我会给你example
,这将帮助你实现这一目标。您最终会添加自己的code
以使其与您的解决方案一起使用。
网络XHTML文件
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Dummy Test</title>
<link rel=" stylesheet" type="text/css" href="css/style.css"></link>
<h:body>
<br />
<h:form id="form">
<p:messages autoUpdate="true" showDetail="true" id="messages"></p:messages>
<p:dataTable id="tbl" value="#{bean.dummyNames}" var="val">
<p:column>
#{val}
</p:column>
<p:column colspan="4">
<p:column styleClass="columnA" style="vertical-align:top;">Industrialization Manager</p:column>
<p:column styleClass="columnB" style="width:15%">
<ui:repeat var="input" value="#{bean.inputTexts}">
<p:inputText size="15" value="#{input}" />
</ui:repeat>
<b style="padding: 0px 0px 0px 18px"> <p:commandButton
value="Add Manager" actionListener="#{bean.addInput}"
update="tbl,messages"
style=" margin-bottom:10px;width:auto;height:28px;font-style: normal; font-family:Arial;font-size: 13px; color: #000000;
text-align:center;font-weight: normal;text-decoration:none;cursor: pointer ">
</p:commandButton>
</b>
</p:column>
</p:column>
</p:dataTable>
</h:form>
</h:body>
</h:head>
托管bean:
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
@ManagedBean(name = "bean")
@SessionScoped
public class TestBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private List<String> dummyNames;
private String selectedName;
private List<String> inputTexts;
public TestBean() {
dummyNames = new ArrayList<String>();
dummyNames.add("AK");
inputTexts = new ArrayList<String>();
inputTexts.add("");
}
public void addInput(ActionEvent e) {
if (inputTexts.size() == 5) {
System.out.println("excedded limit");
return;
}
inputTexts.add("");
}
public List<String> getDummyNames() {
return dummyNames;
}
public void setDummyNames(List<String> dummyNames) {
this.dummyNames = dummyNames;
}
public String getSelectedName() {
return selectedName;
}
public void setSelectedName(String selectedName) {
this.selectedName = selectedName;
}
public List<String> getInputTexts() {
return inputTexts;
}
public void setInputTexts(List<String> inputTexts) {
this.inputTexts = inputTexts;
}
}
<强>输出强>
点击“添加管理员”后