3 Replies Latest reply on Apr 16, 2007 11:33 AM by delphi'sghost

    Problems with extended EL syntax.

    adamkoprowski

      Hello,
      I'm trying to use the great extension of Seam allowing to pass parameters to action methods, but for some reason I keep on getting null as the value of the parameter (no exceptions). I did a simple test with:

      <h:dataTable var="string" value="#{bean.strings}>
       <h:column>
       <s:link value="#{string}" action="#{bean.test(string)}" />
       </h:column>
      </h:dataTable>
      


      When I replace 'string' in action attribute with some literal string value then it gets passed property. I'm using Seam 1.2.0 patch 1, however I'm pretty positive that I had the same issue when trying Seam 1.2.1. I'm using icefaces. Any ideas what I may be doing wrong?

      Thanks a lot in advance for any help!
      Adam

        • 1. Re: Problems with extended EL syntax.
          delphi'sghost

          Here's my take on it, I'm not a seam expert, but I have had my fair share of these types of problems. However, trying some or all of these ideas may help you out.

          I believe that the standard JSF way of accessing a list (i.e. MyBean.myList) isn't good enough for the enhanced EL syntax, nor for the DataModelSelection, you need to make into a "seam variable".

          You can see this in action in the UI demo in the examples directory, just look at the Factories.java code :



          @Name("factories")
          public class Factories
          {
           @Factory("honorifics")
           public Honorific[] getHonorifics() {
           return Honorific.values();
           }
          
          }
          
          


          I'm guessing here, they provide a method which can be used to generate the honorifics array and provide it as a seam contexted variable called "honorifics"

          So, in your action bean (you didn't say what datatype strings is (list, array etc), but assuming a list), you have :

          
           List<String> strings;
          
           @Factory("strings")
           public makeStrings() {
           strings = new List<String>();
           strings.add("Name1");
           strings.add("Name2");
           }
          
          


          In your page, you use :

          <h:dataTable var="string" value="#{strings}>
          


          Where strings is the name of your factory generated seam variable.

          Alternatively, in your bean, you could just put :

          @DataModel
          List<String>strings;
          


          and make your web page code the same as above. This essentially does the same thing, creating a seam variable with the name strings, which you can access from your page.

          I'm sure someone with more knowledge and/or experience will correct me, but this might get you started on your way.

          If you have no luck, post a bit more of your simple test (page and action bean code) and I'm sure I, or someone else will be able to find the answer.




          • 2. Re: Problems with extended EL syntax.
            fernando_jmt

            Actually, you should have this in your component:

            
             @DataModel
             List<String> strings;
            
             @Factory("strings")
             public void makeStrings() {
             strings = new List<String>();
             strings.add("Name1");
             strings.add("Name2");
             }
            
            


            And this in your page:

            <h:dataTable var="string" value="#{strings}>
             <h:column>
             <s:link value="#{string}" action="#{bean.test(string)}" />
             </h:column>
            </h:dataTable>
            


            Remember @Factory definition:
            "@Factory specifies that the method of the component is used to initialize the value of the named context variable, when the context variable has no value.". So if you should use a @Factory for a context variable, and that context variable is defined in this case using @DataModel.


            HTH.


            • 3. Re: Problems with extended EL syntax.
              delphi'sghost

               

              Actually, you should have this in your component:


              Ah yes, you are correct, the factory is used to generate the content, not the to declare actual variable itself which must be specified elsewhere (using the datamodel in this case).

              Thanks for the correction,

              DG