【发布时间】:2012-05-25 08:38:08
【问题描述】:
我想遍历一个元素列表,并为每个元素显示一个表单。在那种形式中,我希望能够为循环的每个元素填充一个不同的 bean。这是我到目前为止得到的,但它当然不起作用;)
<ui:repeat value="#{productBean.productPositions}" var="position">
<div>position info here</div>
<div>list price ranges</div>
<div>
<h5>Create new price range for product position position</h5>
<h:form>
Min:
<h:inputText
value="#{priceRangeBean.priceRanges[productPositionRangeSearch.productPositions.indexOf(position)].min}" />
Max:
<h:inputText
value="#{priceRangeBean.priceRanges[productPositionRangeSearch.productPositions.indexOf(position)].max}" />
price:
<h:inputText
value="#{priceRangeBean.priceRanges[productPositionRangeSearch.productPositions.indexOf(position)].price}" />
<h:commandButton value="create"
action="#{priceRangeController.createRange(productPositionRangeSearch.productPositions.indexOf(position))}" />
</h:form>
</div>
</ui:repeat>
我的 PriceRangeBean:
@SessionScope
public class PriceRangeBean {
private List<PriceRange> priceRanges = new ArrayList<PriceRange>();
public List<PriceRange> getPriceRanges() {
return priceRanges;
}
public void setPriceRanges(List<PriceRange> priceRanges) {
this.priceRanges = priceRanges;
}
}
PriceRange 是一个 POJO,包含最小、最大、价格为 String
调用页面的控制器用与ProductPositions 一样多的PriceRanges 填充PriceRangeBean,以便在列表中准备好创建一个“新”PriceRange 对象。但是输入似乎没有到达支持 bean。
任何想法我做错了什么?
谢谢!
【问题讨论】: