[jboss-user] [JBoss Seam] - DataModelSelection always returns first row from h:dataTable
dkane
do-not-reply at jboss.com
Fri Jun 22 05:19:43 EDT 2007
When I click "Remove" in any row of the table, removeSelectedPosition() is always being called for first row(entity). What is wrong ?
XHTML :
<h:dataTable value="#{cart.cartList}" var="item">
| <h:column>
| <f:facet name="header">Quantity</f:facet>
| <h:inputText value="#{item.quantity}" style="width: 30px;"/>
| </h:column>
| <h:column>
| <f:facet name="header">Item</f:facet>
| #{item.part.description}
| </h:column>
| <h:column>
| <s:link id="cancel" value="Remove" action="#{cart.removeSelectedPosition}"/>
| </h:column>
| </h:dataTable>
cart component :
@Stateful
| @Name("cart")
| @Scope(ScopeType.SESSION)
| @Restrict("#{identity.loggedIn}")
|
| public class ShoppingCartBean implements ShoppingCart, Serializable
| {
| private OrderCMP cartOrder = new OrderCMP();
|
| @DataModelSelection
| private OrderPositionCMP selectedPosition;
|
| public void addPart(PartCMP part, int quantity)
| {
| cartOrder.addPosition(part, quantity);
| }
|
| public void addPart(PartCMP part)
| {
| this.addPart(part,1);
| }
|
| public void removeSelectedPosition()
| {
| if (selectedPosition!=null) removePart(selectedPosition);
| }
|
| public void removePart(OrderPositionCMP orderPos)
| {
| cartOrder.removePosition(orderPos.getPart());
| }
|
| @DataModel
| public List<OrderPositionCMP> getCartList()
| {
| return(cartOrder.getOrderPositions());
| }
|
| public boolean getIsEmpty()
| {
| return(cartOrder.getOrderPositions().size()==0);
| }
|
| public int getTotalPositions()
| {
| return(cartOrder.getOrderPositions().size());
| }
|
| public void resetCart()
| {
| cartOrder = new OrderCMP();
| }
|
| public OrderCMP getOrder()
| {
| return(cartOrder);
| }
|
| @Destroy @Remove
| public void destroy()
| {
| }
|
| }
|
Thank you
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056782#4056782
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056782
More information about the jboss-user
mailing list