Alright, so here are a few suggestions.

1.  You want to submit the form and have Stripes update the select
statements:

With this approach you need to track a desired state filter.  so you need a
hidden field with this info.  in the onchange event for each state select
you simply update the hidden fields value.  Here is how I did it:

<html>
<head>
  <title>State Select</title>
  <script type="text/javascript">
    function changeDesiredStateFilter(state) {
      document.getElementById('desiredStateFilter').value = state;
    }
  </script>
</head>
<body>
<s:form beanclass="com.pnp.web.action.StateSelectActionBean">
  <s:select name="stateFilterTop" id="stateFilterTop"
onchange="changeDesiredStateFilter(1);">
    <s:options-collection collection="${actionBean.states}"/>
  </s:select>
  <hr/>
  <hr/>
  <s:select name="stateFilterBottom" id="stateFilterBottom"
onchange="changeDesiredStateFilter(2);">
    <s:options-collection collection="${actionBean.states}"/>
  </s:select>
  <br/>
  <s:submit name="search" value="Search"/>
  <s:hidden name="desiredStateFilter" value="1" id="desiredStateFilter" />

</s:form>
</body>
</html>

The next problem is getting the 2 select elements to be the same.  I was
able to achieve it this way:

public class StateSelectActionBean extends BaseActionBean {

  private static final Integer TOP = 1;
  private static final Integer BOTTOM = 2;

  private List<String> states;
  private String stateFilterTop;
  private String stateFilterBottom;
  private Integer desiredStateFilter;
  private String actualStateFilter;

// removed getters and setters to save space

  @After(on = {"display", "search"}, stages =
{LifecycleStage.BindingAndValidation})
  public void initLists() {
    states = new ArrayList<String>();
    states.add("KS");
    states.add("MO");
    states.add("OK");
    states.add("NE");
  }

  @After(on = {"search"}, stages = {LifecycleStage.BindingAndValidation})
  public void checkFilter() {
    if (desiredStateFilter.equals(TOP)) {
      setStateFilterBottom(stateFilterTop);
      actualStateFilter = stateFilterTop;
    } else {
      setStateFilterTop(stateFilterBottom);
      actualStateFilter = stateFilterBottom;
    }
  }


  @DontValidate
  @DefaultHandler
  public Resolution display() {
    return new ForwardResolution("/WEB-INF/jsp/state_select.jsp");
  }

  public Resolution search() {

    //TODO use actionStateFilter to perform your search

    return new RedirectResolution(StateSelectActionBean.class)
        .addParameter("stateFilterBottom", stateFilterBottom)
        .addParameter("stateFilterTop", stateFilterTop);
  }
}

I had to use a redirect because of how the population strategy works in
Stripes.  If you are able to change it app wide then you can still do a
forward and it will work as expected.  Otherwise you would need to append
your search results to the redirect as well. This could be kind of messy.
But doable.

2.  Simply use JavaScript to do the brunt of the work.

Have a hidden field that stores the desired filter.  Use JavaScript so that
when one of the select elements changes it modifies the other one to be the
same.  Then they submit the same results.  But all you care about is the
desired state that you wrote to the hidden field.

Either way, you need javascript and I would personally opt for option #2 as
it is the simplest.

Gregg


On Fri, Aug 29, 2008 at 3:12 PM, Stripes-payal <[EMAIL PROTECTED]> wrote:

>
> ya that is also part of problem.
>
> Gregg Bolinger-7 wrote:
> >
> > So how do you know which one you think you are supposed to be using for
> > the
> > search?  Say the top one submits KS and the bottom one submits OK.  How
> > does
> > your code know which one you meant for the search?  Or is that also part
> > of
> > the problem?
> >
> > Gregg
> >
> > On Fri, Aug 29, 2008 at 2:45 PM, Stripes-payal <[EMAIL PROTECTED]>
> > wrote:
> >
> >>
> >> yes,this is correct,and also when again i start selecting values form
> top
> >> it
> >> shows the result with old values.
> >> neither it changes the value of dropdown.
> >>
> >>
> >> Gregg Bolinger-7 wrote:
> >> >
> >> > I found it very difficult to read your question so I hope that I am
> >> making
> >> > some correct assumptions.  My assumption is that you have 2 drop down
> >> > select
> >> > lists.  Both contain states.  When the top one is selected every thing
> >> > works
> >> > correctly.  When the bottom one is selected the filter works right but
> >> the
> >> > top select isn't updated with the selected search state from the
> bottom
> >> > one.
> >> >
> >> > Is this correct?  Is so, I can take a stab at helping you solve your
> >> > problem
> >> > so let me know.
> >> >
> >> > Gregg
> >> >
> >> > On Fri, Aug 29, 2008 at 1:50 PM, Stripes-payal <[EMAIL PROTECTED]>
> >> > wrote:
> >> >
> >> >>
> >> >>  have two dropdowns in my search page one at up and one at down
> >> >> and both have the values of states.
> >> >> When I select the value from dropdown at top of page it gives the
> >> result
> >> >> and
> >> >> updates the down dropdown by states what i have selected.
> >> >> This is what I want.
> >> >> But Now when I select any location from down dropdown it shows the
> >> result
> >> >> from what i have selected in down dropdown but dosent update the up
> >> one.
> >> >> Now if I again goes to up dropdown selection it display the old
> values
> >> >> and
> >> >> dosent update any of those.
> >> >> I have named my dropdown as
> >> >>
> >> >>  <stripes:select name="updropdown"
> >> >> onchange="document.eventForm.submit();">
> >> >>                                    <%if(services.location!="" &&
> >> >> services.location!=null)
> >> >> {System.out.println("inLocation"+services.location);%>
> >> >>
> >> >>     <stripes:option value=""
> >> >> selected="true"><%=services.location%></stripes:option>
> >> >>
> >> >> <%}
> >> >> else{%>
> >> >>                                    <stripes:option value="">---- View
> >> All
> >> >> ----</stripes:option>
> >> >>
> >> >> <%}
> >> >> %>
> >> >>
> >> >>  <stripes:options-collection collection="${actionBean.locations}"/>
> >> >>                                </stripes:select>
> >> >>
> >> >> &
> >> >> <stripes:select name="doenDropdown"
> >> >> onchange="document.eventForm.submit();">
> >> >>                                      <%if(services.location!="" &&
> >> >> services.location!=null)
> >> >> {System.out.println("inLocationDown"+services.location);%>
> >> >>
> >> >>     <stripes:option value=""
> >> >> selected="true"><%=services.location%></stripes:option>
> >> >>
> >> >> <%}
> >> >> else{%>
> >> >>                                    <stripes:option value="">---- View
> >> All
> >> >> ----</stripes:option>
> >> >>
> >> >> <%}
> >> >> %>
> >> >>
> >> >>  <stripes:options-collection collection="${actionBean.locations}"/>
> >> >>                                </stripes:select>
> >> >> and in my java class
> >> >> i take it as
> >> >>
> >> >> code:
> >> >>
> >> >>
> >>
> --------------------------------------------------------------------------------
> >> >>
> >> >>  uplocation=request.getParameter("updropdown");
> >> >> locationDown=request.getParameter("downdropdown"); if(uplocation!="")
> >> >> {
> >> >> location=uplocation;     }       }if(locationDown!="")   {
> >> >> location=locationDown;
> >> >> }
> >> >>
> >> >>
> >> >>
> >>
> --------------------------------------------------------------------------------
> >> >>
> >> >>
> >> >> and with "location " variable i am doing the search.
> >> >> Please help me how to handle 2 dropdowns with the same values for the
> >> >> search.
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/problem-with-search-using-2-dropdowns-with-same-values-tp19225391p19225391.html
> >> >> Sent from the stripes-users mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >>
> >>
> -------------------------------------------------------------------------
> >> >> This SF.Net email is sponsored by the Moblin Your Move Developer's
> >> >> challenge
> >> >> Build the coolest Linux based applications with Moblin SDK & win
> great
> >> >> prizes
> >> >> Grand prize is a trip for two to an Open Source event anywhere in the
> >> >> world
> >> >> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> >> _______________________________________________
> >> >> Stripes-users mailing list
> >> >> [email protected]
> >> >> https://lists.sourceforge.net/lists/listinfo/stripes-users
> >> >>
> >> >
> >> >
> >>
> -------------------------------------------------------------------------
> >> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> >> > challenge
> >> > Build the coolest Linux based applications with Moblin SDK & win great
> >> > prizes
> >> > Grand prize is a trip for two to an Open Source event anywhere in the
> >> > world
> >> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> > _______________________________________________
> >> > Stripes-users mailing list
> >> > [email protected]
> >> > https://lists.sourceforge.net/lists/listinfo/stripes-users
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/problem-with-search-using-2-dropdowns-with-same-values-tp19225391p19226307.html
> >> Sent from the stripes-users mailing list archive at Nabble.com.
> >>
> >>
> >>
> -------------------------------------------------------------------------
> >> This SF.Net email is sponsored by the Moblin Your Move Developer's
> >> challenge
> >> Build the coolest Linux based applications with Moblin SDK & win great
> >> prizes
> >> Grand prize is a trip for two to an Open Source event anywhere in the
> >> world
> >> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> _______________________________________________
> >> Stripes-users mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/stripes-users
> >>
> >
> > -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> > challenge
> > Build the coolest Linux based applications with Moblin SDK & win great
> > prizes
> > Grand prize is a trip for two to an Open Source event anywhere in the
> > world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > Stripes-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/stripes-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/problem-with-search-using-2-dropdowns-with-same-values-tp19225391p19226687.html
> Sent from the stripes-users mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to