7 Replies Latest reply on Sep 12, 2010 11:05 AM by kmranganathan

    search from menu.xhtml in toolbar

    kmranganathan
      Hi,
      I have a toolbar in menu.xhtml. I have a search text field and search button in the toolbar. I have my code with seam-gen. I have a List.xhtml.

      Now, From the toolbar button, I want to invoke List.xhtml directly by passing the search text. When the toolbar button is clicked, I want a different superSearch() invoked.

      I have added superSearch params to List.page.xml. My toolbar is like:

      <h:inputText id='superSearch' value='#{list.searchValue}' />
      <s:button id='s' view='/List.xhtml'>
      <f:param name='from' value"toolbar' />
      <f:param name='superSearch' value='#{list.searchValue}' />
      </s:button>

      The superSearch value is not passed to the list, but the from value is passed in the list.
        • 1. Re: search from menu.xhtml in toolbar
          lvdberg

          Hi,


          The s:button doesn't submit values, so the value of the inputText is not received in the bean. Use a simple h:button and if you need the conversation put that also in  a f:param.


          Leo

          • 2. Re: search from menu.xhtml in toolbar
            kmranganathan
            Hi,
            Your tip is working great! Thanks for the quick reply!

            However, I have one more issue. When List.xhtml is the current page and I do this super search from toolbar, this works fine.

            But, say when the initial home page is displayed, I enter text in the toolbar and click on super search, the search happens, but the List.xhtml view is not displayed.

            Basically, how do I 'show' List.xhtml in this case. The <s:button> had this convenience through view.


            Thanks,
            Ranga.
            • 3. Re: search from menu.xhtml in toolbar
              lvdberg

              Hi,


              There are several possibilities. The first which comes to mind is adding an extra rule in pages.xml and calling a method instead of using the view.


              i'll try to explain. What you're doing now is calling List.xhtml with the search parameters. I haven't seen the List-xhtml, but I can image it call some backing bean for the search. In stead of calling the page, you call the method which does the search, and as returns a String which you use to define the navigation-rule in pages.xml which reDirects to List.xhtml


              Once you have that, you can do the same in whatever page and it will work just by adding a navigation rule for that specific page.


              Another possibility is using a ModalPanel for all searching, In this case you submit the values to a backing bean, open the modelPanel and rerender its content. In this case you shoudl switch to a a4j:button and - if necessary - add the conversationId as parameter-


              Hopefully this helps a bit,


              Leo

              • 4. Re: search from menu.xhtml in toolbar
                kmranganathan
                Hi,
                Thanks for the quick reply. I found another idea from this forum. I am now giving the action="/List.xhtml" and this is loading me the view along with the superSearch paramater too.

                However, the 'from' paramater specified in the f:param is not being passed. I think the params don't work for h:commandButton. I have to find a way to overcome this.


                Thanks,
                Ranga.
                • 5. Re: search from menu.xhtml in toolbar
                  lvdberg


                  Hi,


                  maybe a copy-paste error, but in your example the




                  "="





                  is missing.


                  the commandButton does't support param, See the following


                  following


                  You can use the ajax-button which does support params.


                  Leo


                  • 6. Re: search from menu.xhtml in toolbar
                    kmranganathan

                    Hi,
                    That is a copy paste error.


                    The ajax-button is working fine, but still I have one final issue. When I am already in the List.xhtml page and click the tool bar button, the param is passed fine and everything works fine. But, when I am in some other page, the param doesn't appear in the url.


                    Thanks,
                    Ranga.

                    • 7. Re: search from menu.xhtml in toolbar
                      kmranganathan
                      Hi Leo,
                      Its finally working! Thanks very much for your help!!
                      This has been a key requirement for me.

                      Now, I have the following:
                      1) 2 backing bean variables - one for 'from', one for 'superSearch'.
                      2) 2 page params - one for 'from', one for 'superSearch'.
                      3) ajax commandbutton with ajax action paramter - the ajax parameter is really cool having a 'assignTo' parameter - this helped me to set a 'value'
                      4) In the List.page.xml, I have an <action> which executes my bean.superSearch() method if from is not empty.
                      5) Now, in List.xhtml, in the Normal Search button, I have again used ajax action parameter to reset the from value.

                      Now, my search works for me in all scenarios as expected. This is really cool.

                      Thanks a lot again,
                      Ranga.