On 14-02-2009 at 10:16, Eric Palmitesta wrote:
> Users have Projects, and can view one at a time.
> 
> class User {  Set<Project> projects; Project current; }
> class Project { String name; }
> 
>  My BaseActionBean has methods to retrieve the currently logged in
> User, and the Project they're currently viewing:
> 
> User getCurrentUser() { ... }
> Project getCurrentProject() { ... }
> 
> I want a select box which lists all the Projects the currently logged
> in User has, with a Swtich button which submits to a
> SwitchEventActionBean, which does the work of switching to the newly
> selected event.
> 
> <s:form beanclass="blah.action.SwitchEventActionBean">
>   <s:select name="event">
>     <s:options-collection
> collection="${actionBean.currentUser.projects}" label="name" />
>   </s:select>
>   <s:submit name="switch" value="switch" />
> </s:form>
> 
> This does everything properly, thanks to stripersist.  That's the
> setup for my question.
> 
> How do I pre-select the Project a User is currently viewing in that
> select box?  No javascript.

By setting the property "event" on your SwitchEventActionBean to the current
project before the page is displayed. The select tag will then mark the
correct dropdown item as selected.

Also, why do you use "event" instead of "currentUser.current"? This way, you
only need to store the currentUser as it's bound by Stripes & Stripersist.


Oscar

-- 
   ,-_
  /() ) Oscar Westra van holthe - Kind      http://www.xs4all.nl/~kindop/
 (__ (
=/  ()  DRM "manages access" in the same way that a jail "manages freedom".

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to