0 Replies Latest reply on Nov 5, 2010 7:17 PM by Paul Dijou

    Buttons not working in dataTable and Conversation Context not active

    Paul Dijou Newbie

      Hi,


      I have quite a big problem in an application. I am trying to realise a basic CRUD but fail to do it. The example is quite simple : I have permissions in my database and want to CRUD them using two pages : "permissionsList.xhtml" for listing them and "permissionEdit.xhmlt" for adding and updating them.


      Here is "permissionsList.xhtml" with an "Add" button and a "rich:dataTable" for the listing. The "Update" button after the "Add" button is here for the test I will explain later. Each row detail the permission and have an "Update" button like the first one (exactly the same).




      <h1>Permissions</h1>
                
      <h:form>
      
           <rich:panel header="Liste des permissions">
      
                <h:commandButton action="permissionCreate"
                     actionListener="#{permissionHome.clearInstance()}"
                     value="#{messages['global.button.add']}"
                     styleClass="actionButton actionButtonAdd">
                </h:commandButton>
                     
                <h:commandButton action="permissionEdit"
                          value="#{messages['global.button.update']}">
                          
                </h:commandButton>
                
                <p>
                     <h:outputText value="Result count : #{permissionsQuery.resultList.size()}"/>
                </p>
                          
                <rich:dataTable
                     value="#{permissionsQuery.resultList}"
                     var="_permission"
                     rendered="#{not empty permissionsQuery.resultList}">
                     
                     <rich:column>
                          <f:facet name="header">
                               <h:outputText value="#{messages['pages.identification.permission.label.action']}"></h:outputText>
                          </f:facet>
                          <h:outputText value="#{_permission.action}" />
                     </rich:column>
                     
                     <rich:column>
                          <f:facet name="header">
                               <h:outputText value="#{messages['pages.identification.permission.label.target']}"></h:outputText>
                          </f:facet>
                          <h:outputText value="#{_permission.target}" />
                     </rich:column>
                     
                     <rich:column styleClass="rich-table-action">
                          <f:facet name="header">
                               <h:outputText value="#{messages['glabel.label.actions']}"></h:outputText>
                          </f:facet>
                          
                          <h:commandButton action="permissionEdit"
                               value="#{messages['global.button.update']}">
                          </h:commandButton>
                     </rich:column>
                
                </rich:dataTable>
           
           </rich:panel>
      
      </h:form>





      The "permissionEdit.xhtml" is just a form with two inputText. The "Permission" class is a POJO. "PermissionHome" class as an "@Name("permissionHome")" annotation and extends "EntityHome<Permission>", and "PermissionsQuery" is "@Name("permissionsQuery")" and extends "EntityQuery<Permission>". For navigation between the both pages, here is a piece of the pages.xml :




      <page view-id="/pages/identification/permissionsList.xhtml">
           <navigation from-action="permissionCreate">
                <redirect view-id="/pages/identification/permissionEdit.xhtml" />
           </navigation>
           
           <navigation from-action="permissionEdit">
                <redirect view-id="/pages/identification/permissionEdit.xhtml" />
           </navigation>
      </page>





      So, the problem is : the "Update" buttons in the dataTable only render the current page and do not perform the navigation from-action. If I click on the buttons outside the dataTable, it works fine and I arrive on the "permissionEdit.xhtml" page. But, if I click on a button inside the dataTable, I can see the current page re-rendering and the conversation id increasing by one. I have checked and have no nested form (the only other one wrap the menu and don't interfere). If I replace the "h:commandButton" with a "s:button", it works fine but I know that the "h:commandButton" should work and I need to submit data.


      I don't know if it's linked, but when I click on one of the buttons, I have the following warning :




      WARN  [org.jboss.seam.Component] Cannot create Seam component, scope is not active: permissionsQuery(CONVERSATION)





      After a few investigations and a lot of reading on this forum, I can't figure out the problem. It seems that during the Component.getInstance(...), the Conversation scope is not active : the "Contexts.lookupInStatefulContexts(String name)" try to load my component from the context but "Contexts.isConversationContextActive()" return false and so skip to look inside the Conversation Context. Of course, the component is not finded and when it try to create it, because the Conversation Context is not active, it return the warning.


      I've tried to manage the conversation several ways : always having a temporary conversation, always a long-running one, nested a conversation when going to the "permissionEdit.xhtml"... always the same warning. Notice that the warning appears only if I put the dataTable. Meaning that if I remove it, but keep the result count on an outputText which need the permissionsQuery component, I will have no warning. I don't know why it only appear using the dataTable and more critical, I really don't understand why the Conversation Context is not active.


      If someone has an idea to solve the problem, thanks a lot.