5 Replies Latest reply on Apr 26, 2010 9:11 PM by Busssard Buss

    Search page not holding values whn returning to page

    eli hamburger Newbie

      I have a search page that works like a seam-gen list page that has a box with filter options.  I'm looking for a way to retain what the user enters in the filter boxes so when the user return to the search page (via a link on the subsequent details page), he will see the exact page as before with all the filter options he entered.


      I have tried a few things including starting a conversation in the list/search page and prpegating it to the back button on the details page. However, the filter box always clears.


      Any ideas?


        • 1. Re: Search page not holding values whn returning to page
          Monkey Den Master

          I assume by filter box you mean an HTML select/combo box.  I further assume you are seeing this behavior in IE.  But alas, all I can do is assume with a tenuous description and no code.

          • 2. Re: Search page not holding values whn returning to page
            eli hamburger Newbie

            Here is the xhtml for the filterbox:


            <h:form id="orgSearch" styleClass="edit">
                
                    <rich:simpleTogglePanel label="Click Here search for shuls" switchType="client" opened="true">
                  
                        <s:decorate template="/layout/display.xhtml">
                            <ui:define name="label">Shul Name</ui:define>
                            <h:inputText id="name" value="#{shulList.org.name}" />
                        </s:decorate>
            
                        <s:decorate template="/layout/display.xhtml">
                            <ui:define name="label">City</ui:define>
                            <h:inputText id="city" value="#{shulList.org.address.city}"/>
                        </s:decorate>
                        <s:decorate template="/layout/display.xhtml">
                            <ui:define name="label">State</ui:define>
                            <h:inputText id="state" value="#{shulList.org.address.state}"/>
                        </s:decorate>
                      <div class="actionButtons" style="clear: left;">
                        <h:commandButton id="search" value="Search" action="/shul/list.xhtml"/>
                    </div>
                    </rich:simpleTogglePanel>
                <br/><br/>    
                </h:form>
            



            Here is the associated list.page.xml:


            <?xml version="1.0" encoding="UTF-8"?>
            <page xmlns="http://jboss.com/products/seam/pages"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
               <begin-conversation join="true"/>  
               <param name="firstResult" value="#{shulList.firstResult}"/>
               <param name="order" value="#{shulList.order}"/>
               <param name="from"/>
               <param name="name" value="#{shulList.org.name}" required="false"/>
               <param name="city" value="#{shulList.org.address.city}"/>
               <param name="state" value="#{shulList.org.address.state}"/>
            
            </page>
            



            Here is the link for each org's details page:


            <s:link view="/#{empty from ? 'shul/show' : from}.xhtml" 
                               value="Select" 
                               id="org" propagation="nest">
                  <f:param name="nickname" value="#{org.nickname}"/>
            </s:link>
            



            Here is the back botton on the orgdetails.page:


            <s:link view="/shul/list.xhtml" value="Back To List" propagation="end"/>
            




            As can be seen, I tried using nested conversations for my last go at this, but was unsuccessful.  Using the browser's back button work fine, but my link does not.  Is there a proper seam way for implementing the back button, or should i just use some javascript?

            • 3. Re: Search page not holding values whn returning to page
              David Knaus Newbie

              I'm not an expert, maybe someone else can check this...


              You didn't show the definition of shulList and not the details page XML, but two things come to my mind:


              First: shulList looks like an extended EntityQery from the Application Framework. AFAIK the EntityQuery is by default Event scoped, try to use it in Conversation scope to be part of your conversations.


              Second: AFAIK if you don't define the corresponding page parameters for the list Query in your details page, the <s:link> doesn't include them. So your search restrictions are lost by navigating back to list. If you include them, the new Event scoped list should get filtered.


              I'm also struggling with search restrictions, did you try to use  join fetch with entities in your Query restrictions? Any working example is welcome...thanks.

              • 4. Re: Search page not holding values whn returning to page
                eli hamburger Newbie

                I tried the first option but it didn't work.  What I think is going on is that: since the org in the shulList EntityQuery is filled in by the page parameters, nulls are entered into all the fields when i go back without the page parameters filled out.  Therefore, it doesn't matter what scope the entityQuery is. 


                I was trying to avoid the second option as i would need to carry a lot of variables around in the url.


                I ended up just making the back button into a 'javascript:history.back();' call.


                As far as your question, you need to override the getEjbql function. Here is what I did:


                @Override
                public String getEjbql() {
                     return "select org from Org org inner join fetch org.address where org.enabled = true";
                



                you can do whatever joins you want there and even static restrictions. For hql/ejbql help, you should look at ejb websites as they often have good examples.

                • 5. Re: Search page not holding values whn returning to page
                  Busssard Buss Newbie

                  there's realy no way to do this only with seam resources ??