2
有下列第一.jsf:屬性以JSF託管bean
<ui:repeat var="prod" value="#{showProducts.decoys}">
<h:form>
{prod.price}
{prod.weight}
{prod.size} >
<h:commandButton value="Buy" action="shoppingCart"/>
</h:form>
</ui:repeat>
有以下shoppingCart.jsf:
<h:form>
<h:dataTable value="#{prod}">
<h:column>
#{prod.name}<br/>
</h:column>
<h:column>
#{prod.price}<br/>
</h:column>
<h:column>
<h:inputText value="#{prod.count}" size="3"/>
</h:column>
</h:dataTable>
<h:inputText value="#{order.phone}"/><br/>
<h:inputText value="#{order.mail}"><br/>
<h:inputText value="#{order.city}"/><br/>
<h:commandButton value="Order" action="#{showProducts.persistOrder}">
</h:form>
面 - 配置:
<managed-bean>
<managed-bean-name>showProducts</managed-bean-name>
<managed-bean-class>main.ShowProducts</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
...
<managed-property>
<property-name>product</property-name>
<value>#{product}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>product</managed-bean-name>
<managed-bean-class>main.Product</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
...
的問題:
託管bean名稱定義爲product
迭代變這樣(shoppingCart.jsf):
h:dataTable value="#{prod}">
所以它意味着這個迭代不與命名product
豆無論如何
如何設置屬性prod.price,prod.weight,prod.count
實際管理bean屬性連接:
product.price,product.weight,product.size
BalusC,非常感謝。它工作。我甚至不知道
sergionni
2010-11-30 13:48:07