5 Replies Latest reply on Apr 5, 2007 7:00 AM by Grégory Tanneau

    Injection failed on form submit using rich:datatable binding

    Grégory Tanneau Newbie

      Hi !

      I want to have the rows of my <rich:datatable> clickable.
      OnRowClick, i want to perform an ajax4jsf action using <a4j:support>.

      Here is my form :

       <h:form id="sampleAction">
       <h:commandButton id="sampleAction" value="sampleAction!"
       action="#{sampleAction.sampleAction}"/>
      
       <rich:dataTable id="tatable"
       cellpadding="0" cellspacing="0" width="700" border="0"
      
       value="#{sampleAction.myDataList}"
       var="myDataItem"
       binding="#{sampleAction.myDataTable}">
      
       <!-- This is what i want to do
       <a4j:support
       actionListener="#{sampleAction.rowSelected}"
       event="onRowClick" />
       -->
      
       <rich:column>
       <f:facet name="header">Select</f:facet>
       <h:outputText value="#{myDataItem}" />
       </rich:column>
       </rich:dataTable>
      
       </h:form>
      


      Here is my backing stateful bean :


      
      @Stateful
      @Name("sampleAction")
      @Scope(SESSION)
      public class SampleActionBean implements SampleAction {
      
       @Logger
       private Log log;
      
       @In(create=true)
       FacesMessages facesMessages;
      
       // seam-gen method
       public String sampleAction() {
       // implement your business logic here
       log.info("sampleAction.sampleAction() action called");
      // facesMessages.add("sampleAction");
       return "success";
       }
      
      
       // Properties ----------------------------------------------------------
       @DataModel
       public String[] myDataList = {"Valeur 1", "Valeur 2", "Valeur 3", "Valeur 4", "Valeur 5"};
       public String myDataItem;
       public UIData myDataTable;
      
       // Actions ----------------------------------------------------------
      
       public String rowSelected(ActionEvent event) {
       myDataItem = (String) getMyDataTable().getRowData();
       log.info("rowSelected ==> " + myDataItem);
       return "success";
       }
      
       public String getSelectedItem() {
       log.info("sampleAction.getSelectedItem() called");
       log.info("----> " + myDataItem);
      
       // Do your thing with the MyData item in myDataItem.
       //facesMessages.add("Get selected item : " + myDataItem);
      
       return "success"; // Navigation case.
       }
      
       public String getMyDataItem() {
       return myDataItem;
       }
      
       public void setMyDataItem(String myDataItem) {
       this.myDataItem = myDataItem;
       }
      
       public String[] getMyDataList() {
       return myDataList;
       }
      
       public void setMyDataList(String[] myDataList) {
       this.myDataList = myDataList;
       }
      
       public UIData getMyDataTable() {
       return myDataTable;
       }
      
       public void setMyDataTable(UIData myDataTable) {
       this.myDataTable = myDataTable;
       }
       @Destroy
       @Remove
       public void destroy() {
       }
      }
      
      


      BUT ... on submit (ajax or simple action with my <h:commandButton>) i have the following exception :

      
      19:26:02,890 ERROR [ExceptionFilter] exception root cause
      javax.faces.el.EvaluationException: /sampleAction.xhtml @31,47 binding="#{sampleAction.myDataTable}": Exception setting property myDataTable of base with class org.javassist.tmp.java.lang.Object_$$_javassist_1
       at com.sun.facelets.el.LegacyValueBinding.setValue(LegacyValueBinding.java:74)
       at org.apache.myfaces.shared_impl.util.RestoreStateUtils.recursivelyHandleComponentReferencesAndSetValid(RestoreStateUtils.java:70)
       at org.apache.myfaces.shared_impl.util.RestoreStateUtils.recursivelyHandleComponentReferencesAndSetValid(RestoreStateUtils.java:41)
       at org.apache.myfaces.shared_impl.util.RestoreStateUtils.recursivelyHandleComponentReferencesAndSetValid(RestoreStateUtils.java:78)
       at org.apache.myfaces.shared_impl.util.RestoreStateUtils.recursivelyHandleComponentReferencesAndSetValid(RestoreStateUtils.java:41)
       at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:179)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      
      ...
      
      Caused by: javax.ejb.EJBException: org.jboss.seam.RequiredException: In attribute requires non-null value: sampleAction.facesMessages
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
      
      


      It's just like if my injected facesMessages is not injected after a submit.

      If I dont use any @In-jected attribute, it works.
      If i do, the bind="..." attribute of my <rich:dataTable> makes me go into troubles...

      Please, any idea ?