[英]Jsf El Expression getter and setter ArrayList
im using inside the backing bean an 我在后备豆里面使用
private ArrayList<String> myList;
init(){
myList = new ArrayList<String>();
myList.add("XYZ");
}
public ArrayList<String> getMyList(){
return myList;
}
public setMyList(ArrayList<String> l){
myList = l;
}
insde the xhtml 插入xhtml
i show the elements by doing: 我通过执行以下操作显示元素:
<h:outputText value="Item: " />
<p:inputText required="true" label="Item"
value="#{mybean.myList[0]}" />
when i show the page i see the value: 当我显示页面时,我看到了值:
XYZ
in the page. 在页面中。
So my question is: 所以我的问题是:
If I do NOT set "XYZ" inside the ArrayList and the user writes inside p:inputText
the value "HKJ", will I find on server-side inside myList
at position 0 the expected "HKJ"? 如果我未在ArrayList内设置“ XYZ”,并且用户在p:inputText
内写入值“ HKJ”,我将在myList
的位置0的myList
内的服务器端找到期望的“ HKJ”吗? Can I use ArrayList
for display and set values or do i have to use String[]
? 我可以使用ArrayList
来显示和设置值,还是必须使用String[]
?
you can find here similar question: 您可以在这里找到类似的问题:
http://www.velocityreviews.com/forums/t303520-jsf-using-arrays-arraylist-in-the-backing-bean.html
JSF is working in a Lifecycle (see JSF lifecycle with example ). JSF正在生命周期中工作(请参见带有示例的JSF生命周期 )。 One of the first parts of this lifecycle is to take user-sent input, validate it and push it into the JSF object tree. 这个生命周期的第一部分是获取用户发送的输入,对其进行验证并将其推送到JSF对象树中。
So, when you connect a h:inputText
s value with a managed beans property - this field will be updated with the input a user did on the frontend (when it passes the validation, and the input field is inside a h:form
). 因此,当您将h:inputText
的值与托管bean属性连接时-该字段将使用用户在前端所做的输入来更新(当它通过验证时,并且输入字段位于h:form
)。
The collection access operator ( []
operator) works in the case you describe the same for Arrays and Collections ( ArrayList
implements Collections). 集合访问运算符( []
运算符)在您为Arrays和Collections描述相同的情况下有效( ArrayList
实现Collections)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.