3 Replies Latest reply on Jun 17, 2009 7:45 PM by gonorrhea

    injecting session-scoped component into conversation-scoped component

    gonorrhea

      I have the following component:


      @Name("manageSiteId")
      @Stateful
      @Scope(ScopeType.SESSION)
      @AutoCreate
      public class ManageSiteIdAction implements ManageSiteIdLocal{...}



      which is being injected into this component:


      @Stateful
      @Name("manageEquipment")
      @Scope(ScopeType.CONVERSATION)
      @SuppressWarnings("unchecked")
      public class ManageEquipmentAction implements ManageEquipmentLocal {...}



      ManageEquipment.xhtml:


      <h:form>
                     <h:panelGrid columns="2" style="vertical-align:top; float: right;">
                          <h:outputText value="Current Site: " />                         
                          <h:selectOneMenu value="#{manageSiteId.selectedListValueForSiteId}">
                               <s:selectItems var="lv"
                                    value="#{populateDropDown.getListValueList('SITES')}"
                                    label="#{lv.description}"
                                    noSelectionLabel="Please Select..." />                                                                                
                               <s:convertEntity />
                               <a4j:support event="onchange" action="#{manageSiteId.changeSiteId()}"/>
                          </h:selectOneMenu>
                     </h:panelGrid>
                </h:form>



      The problem has to do with the setting (displaying of selected) of HtmlSelectOneMenu component.  Sometimes it's showing the set/selected property, sometimes it's not.  Seems like a bug but it was working before I refactored the code into two SFSB components.  I ran it thru the debugger and not sure why it's not working in some cases.


      The other interesting thing is that if I don't use the @Begin(join=true) annotation in the session-scoped component, the selected value for the drop down never displays.


      Must a session-scoped component join the LRC to be injected in and used in a conversation-scoped component?


        • 1. Re: injecting session-scoped component into conversation-scoped component
          gonorrhea

          I changed the code to the following:


          @Name("manageSiteId")
          @Stateful
          @Scope(ScopeType.CONVERSATION)
          @AutoCreate
          public class ManageSiteIdAction implements ManageSiteIdLocal{...}



          and removed the @Begin(join=true) annotations from the two business methods, and now the drop-down magically behaves properly (the drop down value is properly set and displayed in different situations).


          We actually want the properties associated with HtmlSelectOneMenu and that component to be session-scoped.  How can I fix this problem and use an injected session-scoped component?


          pages.xml:


          <page view-id="/ManageEquipment.xhtml">
                   <description>Manage Equipment</description>
                   <!-- <action execute="#{manageEquipment.init}" if="#{not manageEquipment.isInitComplete()}"/> -->
                   <begin-conversation join="true"/>
                   <action execute="#{manageSiteId.init}"/>                  
                   <navigation from-action="#{manageEquipment.processRepairHistorySelection}">
                        <redirect view-id="/RepairCaseDetails.xhtml"/>                          
                  </navigation>
                  
                  <navigation from-action="#{manageEquipment.searchSerialNumber}">
                       <redirect view-id="/ManageEquipment.xhtml"/>
                  </navigation>
                  
              </page>

          • 2. Re: injecting session-scoped component into conversation-scoped component
            gonorrhea

            well apparently you should be able to inject a session-scoped component into a conversation-scoped component.  I checked the older version of my code and it works as intended.


            still not sure exactly what's causing the anomalous behavior (now on to backfactoring!)

            • 3. Re: injecting session-scoped component into conversation-scoped component
              gonorrhea

              I fixed it but not sure how.  Anyways, I'm wondering if non-matching scoped injection will be supported in Seam 3 and/or Web Beans???