0 Replies Latest reply: Aug 21, 2009 1:06 PM by Dariusz Stachyra RSS

    Problem with extendedDataTable and a4j:actionParam

    Dariusz Stachyra Newbie

      Hello. I have a problem with a4j:actionParam in extendedDataTable. When I click commandButton with actionParam, the set method in Bean doesn't work.


      Bean:



      @Stateful
      @Name("addressList")
      @Scope(ScopeType.EVENT)
      public class AddressList implements IAddressList{
           private static final long serialVersionUID = 4331841100611313508L;     
           protected static final String DATA_MODEL_VALUE = "addressDataModel";
           protected static final String LIST_QUERY_VALUE = "addressListQuery";
           
           @Logger
           Log log;
      
           @RequestParameter
           Long companyId;
      
           private Long selectedAddressIndex;
      
           @In(value=LIST_QUERY_VALUE, required=false)
           Query query;
           
           public AddressList(){}
           
           @Factory(value=LIST_QUERY_VALUE, scope=ScopeType.EVENT)
           public Query prepareQuery(){               
                Query query=new Query(Address.class);
                query.addEntity(Company.class)
                     .addRelationToMasterEntity(Address.class, Type.LEFT_JOIN, "company.id=id");
                
                createRestrictions(query, companyId);
                
                query.setRowMapper(AddressView.class)
                     .addField(Address.class, "id").addField(Address.class, "street").addField(Address.class, "postalCode")
                     .addField(Address.class, "town").addField(Address.class, "streetSorterFilter").addField(Address.class, "townSorterFilter");
      
                return query;
           } 
           
      
           private void createRestrictions(Query query, Long companyId){
                query.addRestriction(Restriction.permanentEq(Address.class, "recordStatus", ERecordStatus.ACTIVE.ordinal()));
                query.addRestriction(Restriction.permanentEq(Company.class, "recordStatus", ERecordStatus.ACTIVE.ordinal()));
                if(companyId!=null)
                     query.addRestriction(Restriction.permanentIdEq(Company.class, companyId));
           }
           
      
           public void setSelectedAddressIndex(Long selectedAddressIndex) {
                this.selectedAddressIndex = selectedAddressIndex;
           }
      
           @Destroy @Remove
           public void destroy(){}
      
           @Create 
           public void create(){}
      }



      This is view:


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:a4j="http://richfaces.org/a4j"
           xmlns:rich="http://richfaces.org/rich"
           xmlns:s="http://jboss.com/products/seam/taglib">
      
      
           <a4j:outputPanel id="addressListForm">  
                <a4j:form ajaxSubmit="true" >
                     <rich:panel columns="1" columnClasses="top,top" id="addressListPanel">
                          <f:facet name="header">#{messages['addressList.header']}</f:facet>
                          <rich:extendedDataTable value="#{addressDataModel}" rowKeyVar="idx"
                               rows="10" rendered="true" selectionMode="single" 
                               selection="#{addressSelection}" var="rowAddress" id="addressList"
                               height="200px">
      
                               <!--ADDRESS ID COLUMN -->
                               <rich:column width="5%">
                                    <f:facet name="header">Id</f:facet>
                                    <h:outputText value="#{rowAddress.id}" />
                               </rich:column>
      
                               <!--ADDRESS TOWN COLUMN-->
                               <rich:column sortable="true"
                                    sortBy="#{rowAddress.townSorterFilter}"
                                    filterBy="#{rowAddress.townSorterFilter}" filterEvent="onkeyup"
                                    width="170px" label="Town">
                                    <f:facet name="header">
                                         <h:outputText value="#{messages['address.town']}" />
                                    </f:facet>
                                    <h:outputText value="#{rowAddress.town}" />
                               </rich:column>
      
                               <!--  ADDRESS STREET COLUM -->
                               <rich:column sortable="true"
                                    sortBy="#{rowAddress.streetSorterFilter}" width="20%"
                                    filterBy="#{rowAddress.streetSorterFilter}" filterEvent="onkeyup"
                                    label="Street">
                                    <f:facet name="header">
                                         <h:outputText value="#{messages['address.street']}" />
                                    </f:facet>
                                    <h:outputText value="#{rowAddress.street}, idx=#{idx}" />
                               </rich:column>
      
                               <!--  ADDRESS POSTAL CODE COLUMN -->
                               <rich:column label="postalCode" align="center" width="15%">
                                    <f:facet name="header">
                                         <h:outputText value="#{messages['address.postal.code']}" />
                                    </f:facet>
                                    <h:outputText value="#{rowAddress.postalCode}" />
                               </rich:column>
      
                               <!-- ACTIONS COLUMN -->
                               <rich:column width="10%">
                                    <f:facet name="header">
                                         <h:outputText value="#{messages['address.actions']}" />
                                    </f:facet>
      
                                    <a4j:commandButton image="/img/delete.gif"                              oncomplete="Richfaces.showModalPanel('deleteAddressPanel');" >
      
                                                            <-- THIS DOESN'T WORK -->
                                         <a4j:actionparam name="selectedAddressIndex" value="#{rowAddress.id}" assignTo="#{addressList.selectedAddressIndex}" />
                                    </a4j:commandButton>                              
                               </rich:column>
                               
                               <f:facet name="footer">
                                    <rich:datascroller align="center" id="scroller"
                                         reRender="addressList" />
                               </f:facet>
                          </rich:extendedDataTable>
                     </rich:panel>
      <!--          </a4j:form>-->
           </a4j:outputPanel>
      
           <div class="actionButtons">
                <s:button id="done" value="#{messages['address.create']}" view="/addressDetails.xhtml"
                rendered="false" />
           </div>
      
      <!--  DELETE MODAL PANEL     -->
           <rich:modalPanel id="deleteAddressPanel" autosized="true" width="200">
                <f:facet name="header">
                     <h:outputText value="#{messages['address.delete.panel.header']}"
                          style="padding-right:15px;" />
                </f:facet>
                <f:facet name="controls">
                     <h:panelGroup>
                          <h:graphicImage value="/img/close.png" styleClass="hidelink"
                               id="hidelink22" />
                          <rich:componentControl for="deleteAddressPanel"
                               attachTo="hidelink22" operation="hide" event="onclick" />
                     </h:panelGroup>
                </f:facet>
                <h:form>
                     <table width="100%">
                     <h:outputText value="#{rowAddress.street}" />
                          <tbody>
                               <tr>
                                    <td align="center" width="50%"><a4j:commandButton id="yes"
                                         value="#{messages['address.delete.panel.yes']}"
                                         action="#{addressHome.prepareRemove}"
                                         oncomplete="#{rich:component('deleteAddressPanel')}.hide();" />
                                    </td>
                                    <td align="center" width="50%"><a4j:commandButton
                                         value="#{messages['address.delete.panel.no']}"
                                         onclick="#{rich:component('deleteAddressPanel')}.hide();return false;" />
                                    </td>
                               </tr>
                          </tbody>
                     </table>
                </h:form>
           </rich:modalPanel>
      
      </ui:composition>



      I'm using JBoss AS 4.2.3 GA and Seam 2.1.2


      Any ideas?