6 Replies Latest reply on Mar 17, 2009 7:44 PM by Ryan Waggoner

    Command Links and Seam

    Ryan Waggoner Newbie

      From the problem I was having earlier, I started working on a smaller project, but I am again having a problem.


      I have a table with 3 columns, the third is a command link named Edit.


      When I load the page and click Edit, nothing happens.


      If I Add a new entry to this table (from the same page with a text box and button) it refreshes the table to show the new entry.


      It is at this point my command link will then work every time.



      Why won't it work initially?


      Thanks!

        • 1. Re: Command Links and Seam
          Ryan Waggoner Newbie

          So working with this a little bit more, I got it to work...but I don't know why it is working.


          My stateful bean provinceBean has an entity province that looks like...


                 


          @DataModelSelection("provinceList")
                  @Out(required = false)
                  @In(required = false)
                  private SiProvince province;



          My province had these annotations




          @Entity
          @Name("state")
          @SuppressWarnings("all")



          And the page looked like...



          <s:span id="provinceTaxRates">
           <rich:dataTable value="#{state.taxItems}" var="stateTax"
            rowClasses="seamDisplayTableRowOne,seamDisplayTableRowTwo" rules="cols">
             <h:column>
                  <f:facet name="header">Name</f:facet>
                          <h:outputText value="#{stateTax.siName}"/>
             </h:column>
             <h:column>
                  <f:facet name="header">Rate</f:facet>
                          <h:outputText value="#{stateTax.siTaxRate}" />
             </h:column>
             <h:column>
                  <f:facet name="header"> Edit </f:facet>
                          <a:commandLink value="Edit" action="#{stateBean.editTax}" reRender="newTaxInput" />
             </h:column>
          </rich:dataTable>






          My Command link was not populating my text boxes until I added the annotation

          @Scope=(value="ScopeType.CONVERSATION")



          to my province entity class,


          Can someone explain to me why?


          Thanks!


          • 2. Re: Command Links and Seam
            Arbi Sookazian Master

            1) @DataModelSelection injects.  you don't need @In as well.



            Injects the selected value from the JSF DataModel (this is the element of the underlying
            collection, or the map value).

            2) default scope for JPA entity is conversation.


            EJB stateful session bean: Conversation
            JPA entity class: Conversation
            EJB stateless session bean: Stateless
            EJB message driven bean: Stateless
            JavaBean (POJO): Event

            • 3. Re: Command Links and Seam
              Arbi Sookazian Master

              you are reRendering newTaxInput component but where is that component in your xhtml snippet you posted?  If it doesn't exist, nothing will happen, no error either.

              • 4. Re: Command Links and Seam
                Ryan Waggoner Newbie

                That part looks like...



                <!--  New Tax Table -->
                <s:div id="newTaxInput">
                   <h:panelGrid columns="1">
                     <rich:panel>
                          <f:facet name="header">
                          <h:outputText value="New Tax for #{state.siStateCode}" />
                     </f:facet>
                        <h:column>
                          <h:outputText value="Name: " />
                          <h:inputText value="#{stateTax.siName}" />
                     </h:column>
                     <h:column>
                          <h:outputText value="Tax Rate: " />
                          <h:inputText value="#{stateTax.siTaxRate}" />
                     </h:column>
                     <h:column>
                          <a:commandButton value="Add Tax" eventsQue="foo"
                          action="#{stateBean.addTax}" reRender="provinceTaxRates" />
                     </h:column>
                     </rich:panel>
                   </h:panelGrid>
                </s:div>



                What I don't understand is, since the entity's default scope is conversation, why does it not work without the @Scope? (Initially)

                • 5. Re: Command Links and Seam
                  Arbi Sookazian Master

                  You need to show all your code for ppl to help here.  Otherwise, it's difficult to follow.


                  1) in the above xhtml snippet, note that there are three different Seam components referenced: state, stateTax, and stateBean.  Show all of those (don't worry about showing local interface(s) if it's SLSB/SFSB).


                  2) show all your xhtml code, i'm not understanding the overall purpose and logistics of this code


                  3) you can try using

                  <a:outputPanel ajaxRendered="true">

                  to auto-reRender the enclosed area (so add that and remove the
                  <s:div></s:div>

                  ).

                  • 6. Re: Command Links and Seam
                    Ryan Waggoner Newbie

                    Sorry Ron,
                      I was hoping there would have been an easy explanation for the problem I was having, and thus I thought the other code would be irrelevant.


                       It is currently working, and I am not too worried about it, I just wasn't sure why it was working.