tags:

views:

112

answers:

1

I have a mix of columns in my htmltable: 1 column is an actionlistener, 2 columns are actions and other columns are simple output.

<h:dataTable styleClass="table" id="orderTable" value="#{table.dataModel}"
             var="anOrder" binding="#{table.dataTable}"                                    
             rows="#{table.rows}"  
    <an:listenerColumn backingBean="${orderEntry}"   entity="${anOrder}"
                            actionListener="closeOrder"/>                                  
    <an:column label="#{msg.hdr_orderStatus}"  entity="#{anOrder}" 
                            propertyName="orderStatus" />
    <an:actionColumn backingBean="${orderEntry}"   entity="${anOrder}"
                            action="editOrder" />                               
    <an:actionColumn backingBean="${orderEntry}"   entity="${anOrder}"
                            action="viewOrder"/>
.... 

I'm using custom tags, but it's the same behavior if I use the default column tags.
I've noticed a very strange effect: when clicking the actionlistenercolumn, the actionevent is handled 3 times. If I remove the 2 action columns then the actionevent is handled only once.
The managed bean has sessionscope, bean method:

    public void closeOrder(ActionEvent event) {
        OrdersDto order;
        if ((order = orderRow()) == null) {
            return;
        }
        System.out.println("closeOrder() 1 ");
        orderManager.closeOrder();
        System.out.println("closeOrder() 2 ");
    }

the console prints the'debug' text 3 times.

A: 

Check for the event (name?) in java method.

I think you are adding listener and events to whole table. Instead you should add them to columns by nesting them into column declaration.

<h:column> 
  <h:commandLink value="Edit" .../>
</h:column> 
Imre L
<an:listenerColumn ... is a custom tag and is implemented as: <ui:composition> <h:column> <f:facet name="header"> <h:outputText id="hdr_${action}" value="#{label}"/> </f:facet> <h:commandButton id="btn_${action}" image="${image}" title="${tooltip}" actionListener="#{backingBean[action]}"> </h:commandButton> </h:column> </ui:composition>
Rose