12 Replies Latest reply on Jan 22, 2008 2:32 AM by nickarls

    expression language empty parameter

      hello,

      I have a strange problem with the seam EL that I didn't had with version 1.2.1 GA .
      Now I moved from 1.2.1 to 2.0.0GA.
      The problem is that if I pass a parameter like #{searcher.searchByCreator(c)} the function is getting called in my bean searchBean.searchByCreator(String creator) but the value of String creator is empty (not null). Parm. c is not empty because it gets printed on the screen.

      Where can I look for failures or what did I do wrong, because I don't get any strange debug messages or any error messages.


      thank you

      best regards.

      V.


      <div id="center">
       <h:messages globalOnly="true" styleClass="message" />
      
       <h:form id="search_Form">
       <h:inputText id="value" required="false" value="#{searcher.searchString}" style=" width : 300px; "/>
       <h:commandButton id="search" value="search" action="#{searcher.search}" style="width : 50px; "/>
       </h:form>
      
       <!-- RESULT LIST -->
      
       <h:dataTable id="DT_docs" var="docResult" value="#{docs}">
       <h:column id="Column_docs">
      
       <h:outputText value=" Creator: " rendered="#{not empty docResult.doc.creator}" />
       <h:dataTable id="DT_creator" var="c" value="#{docResult.doc.creator}">
       <h:column id="Column_creator">
       <h:form id="Form_creator" styleClass="subText" style="margin:auto;padding:auto; /*just for the IE*/">
       <s:link id="Link_searchByCreator" value="[#{c}]," action="#{searcher.searchByCreator(c)}"/>
       </h:form>
       </h:column>
       </h:dataTable>
      
       </h:column>
       </h:dataTable>
      
       </div> <!-- center-->
      




      My bean code looks like this

      
      @Stateful
      @Name("searcher")
      public class SearchBean implements Search, Serializable {
      
       @DataModel
       private List<SearchResult> docs = null;
      
       public void search(){
       log.info("search.search() action called " + searchString);
       docs = indexer.search(searchString);
       }
      
      
       public void searchByCreator(String creator){
       searchString = "creator:"+ creator ;
       search();
       }
      
       @Destroy
       @Remove
       public void destroy() {}
      
      


        • 1. Re: expression language empty parameter
          nickarls

          and #{docResult.doc.creator} resolves to a normal String?

          • 2. Re: expression language empty parameter

            no docResult.doc.creator is an array of String

            In the second dataTable I loop thou the array and bind each array element to the var "c" and the elements of docResult.doc.getCreator() are instanceof Strings

            <h:dataTable id="DT_creator" var="c" value="#{docResult.doc.creator}">
             <h:column id="Column_creator">
             <h:form id="Form_creator" styleClass="subText" style="margin:auto;padding:auto; /*just for the IE*/">
             <s:link id="Link_searchByCreator" value="[#{c}]," action="#{searcher.searchByCreator(c)}"/>
             </h:form>
             </h:column>


            • 3. Re: expression language empty parameter

              a note

              if I put a constant as a param in JSF
              like this
              <s:link id="Link_searchByCreator" value="bla bla," action="#{searcher.searchByCreator('test String')}"/>

              then my bean function SearchBean.searchByCreator(String c){}
              is called with the value 'test String' the variable c is always empty !!!

              • 4. Re: expression language empty parameter

                what reasons are responsible that a value of a var is not passed to the bean?
                "#{searcher.searchByCreator(var)}" // var is not empty but it is in the bean

                • 5. Re: expression language empty parameter
                  pmuir
                  • 6. Re: expression language empty parameter

                    thx for this hint.

                    "You must ensure that the parameters are available not only when the page is rendered, but also when it is sub-
                    mitted
                    If the arguments can not be resolved when the page is submitted the action method will be called with
                    null arguments" --> Stateful bean, right?

                    I did read the chapter and adapted my program according to it. I didn't had any luck.
                    I changed my Project so it looks same like the booking example.

                    I dont see any difference in my code the the booking example. I am quite frustrated because i don't get any feedback from the system and I am trying all kind of combinations since 3 days now with no luck.

                    I have a list of results If the user clicks on an author from the list the page is redisplay according to the parameter passed in the function call searchByCreator();

                    
                    <h:form id="searchForm">
                     <h:inputText id="value" required="false" value="#{searcher.searchString}" style=" width : 300px; "/>
                     <h:commandButton id="search" value="search"
                    action="#{searcher.search}" style="width : 50px; "/>
                    </h:form>
                    
                    
                    <h:dataTable var="resultElem" value="#{searchResult}">
                     <h:column>
                     <!-- Creator -->
                     <h:form styleClass="subText" style="margin:auto;padding:auto; /*just for the IE*/">
                     <ui:repeat var="a" value="#{resultElem.doc.creator}" >
                     <h:commandLink value="[#{a}]," action="#{searcher.searchByCreator(a)}" />
                     </ui:repeat>
                     </h:form>
                    </h:column>
                    </h:dataTable>
                    


                    @Stateful
                    @Name("searcher")
                    public class SearchBean implements Search, Serializable {
                    
                     @DataModel
                     private List<SearchResult> searchResult;
                    
                     public void searchByCreator(String creator){
                     ....
                     }
                     ...
                    
                     @Destroy
                     @Remove
                     public void destroy() {}
                    
                    


                    if I use h:commandLink my function is never called the page is just rerendered

                    If I user s:link the function gets called but the parameter is empty!

                    If i put the h:command link outside the ui:repeat this makes no difference the result is the same like above.

                    If I use the in second loop a h:dataTable i have the same result as above

                    simplified system:

                    If i make a function call outside the DataTable id doesn't work always

                    inside the search form
                    <h:form id="searchForm">
                     <h:inputText id="value" required="false" value="#{searcher.searchString}" style=" width : 300px; "/>
                     <h:commandButton id="search" value="search"
                    action="#{searcher.search}" style="width : 50px; "/>
                    <h:commandLink styleClass="subText" value="#{searcher.searchString}," action="#{searcher.searchByKeyword(searcher.searchString)}" />
                    Does work
                    </h:form>
                    



                    Two Forms
                    <h:form id="searchForm">
                     <h:inputText id="value" required="false" value="#{searcher.searchString}" style=" width : 300px; "/>
                     <h:commandButton id="search" value="search"
                    action="#{searcher.search}" style="width : 50px; "/>
                    <h:commandLink styleClass="subText" value="#{searcher.searchString},"
                    </h:form>
                    
                    <h:form>
                    action="#{searcher.searchByKeyword(searcher.searchString)}" />
                    don't work
                    </h:form>
                    
                    


                    • 7. Re: expression language empty parameter
                      pmuir

                      Put the form around the whole datatable.

                      • 8. Re: expression language empty parameter

                        Thank you,

                        Did try it but without any changes

                        If s:link is used function gets called with the null parameter
                        with h:commandLink function is not called at all.

                        
                        <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                        <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                         xmlns:s="http://jboss.com/products/seam/taglib"
                         xmlns:ui="http://java.sun.com/jsf/facelets"
                         xmlns:f="http://java.sun.com/jsf/core"
                         xmlns:h="http://java.sun.com/jsf/html"
                         xmlns:rich="http://richfaces.org/rich"
                         xmlns:a="http://richfaces.org/a4j"
                         template="layout/template.xhtml">
                        
                         <ui:define name="body">
                        
                         <h:form>
                         <h:inputText id="value" required="false" value="#{searcher.searchString}" style=" width : 300px; "/>
                         <h:commandButton id="search" value="search" action="#{searcher.search}" style="width : 50px; "/>
                         </h:form>
                        
                         <!-- RESULT LIST -->
                         <h:form>
                         <h:dataTable var="resultElem" value="#{searchResult}">
                         <h:column>
                        
                         <!-- Creator -->
                         <h:outputText value="Creator:" rendered="#{not empty resultElem.doc.creator}" />
                         <ui:repeat var="a" value="#{resultElem.doc.creator}" >
                         <s:link value="[#{a}]," action="#{searcher.searchByCreator(a)}" />
                         <h:commandLink value="[#{a}]," action="#{searcher.searchByCreator(a)}" />
                         </ui:repeat>
                        
                         </h:column>
                         </h:dataTable>
                         </h:form>
                        
                        
                         </ui:define>
                        </ui:composition>
                        


                        • 9. Re: expression language empty parameter
                          pmuir

                          Nesting loops in JSF is tricky. What about if you don't use the nested loop? Does it work then?

                          • 10. Re: expression language empty parameter

                            Finally !

                            I found out the the bean behaved "Stateless" although I did annotate it as Stateful, no wonder it didn't work, I just found it out by coincidence.
                            After changing it from conversation scope to the Session scope it suddenly worked like a charm !
                            For Seam the Conversation was over after a request and response but for me it wasn't done with it. I didn't notice it until now.

                            There is one question left.
                            How can I determine precisely from my code and my code structure when a conversation will be over?


                            In the docs it is just written that the conversation scope can last for several request, responses and over multiple pages but it is not very precise.

                            thank you people for investing you time.



                            • 11. Re: expression language empty parameter

                              Finally !

                              I found out the the bean behaved "Stateless" although I did annotate it as Stateful, no wonder it didn't work, I just found it out by coincidence.

                              After changing it from conversation scope to the Session scope it suddenly worked like a charm !

                              The Conversation was over for seam after a request and response but for me it wasn't done with it.

                              There is one question left.

                              How can I determine precisely from my code and my code structure when a conversation is over?


                              thank you people for investing you time.



                              • 12. Re: expression language empty parameter
                                nickarls

                                By looking at the code, no way since the methods can be called in arbitrary order. But you can check it programmatically with Conversation.getInstance().isLongRunning().