It works! Thanks in advance ..!
joshcanfield wrote: > > This doesn't really have anything to do with the Environment, the > problem is with your FilterContainer property. > > Every time tapestry pulls your page from the pool (or puts it I don't > recall which) it initializes the page properties with the values you > set in the constructor or set in the property declaration. That means > your page is always going to get back the same instance of the object > it instantiated when it the page created. Which is great for objects > that users don't manipulate. > > It sounds like what you want is to hold on to the FilterContainer in > the session, so change your property declaration like this: > > @Persist("session") > private FilterContainer container; // Defaults to null, persisted > classes should be Serializable > > And: > void setupRender() { > // If there is no container in the session then create a > new one. > if ( container == null ) container = new FilterContainer(); > environment.push(FilterContainer.class, container) ; > } > > Josh > > On Wed, Apr 16, 2008 at 2:28 PM, Fidel Chavarria > <[EMAIL PROTECTED]> wrote: >> >> Hi, I 've a list of filter components to make the user experience more >> confortable when he is looking at a list of issues in my app. I use >> Tapestry >> radiogroup component technique to enclose those filtters in a FilterGroup >> component, It works ..! but it's not stateless. when I login to my >> application as another user with a new instance of another web browser >> (to >> avoid browser session ) it keeps all filters applyed from a previous >> user. >> >> Environment services are not stateless ...? >> How can I avoid this behaviour ..? >> >> public class FilterGroup { >> >> private FilterContainer container = new FilterContainer() ; >> >> @Inject >> private Environment environment ; >> >> void setupRender() { >> environment.push(FilterContainer.class, container) ; >> } >> >> void afterRender() { >> environment.pop(FilterContainer.class) ; >> } >> >> public void onAction(Object[] ctx) { >> if (container.getActiveFilters().contains((String) >> ctx[0])) >> container.getActiveFilters().remove(ctx[0]) ; >> else { >> container.getActiveFilters().clear() ; >> container.getActiveFilters().add((String) ctx[0]) >> ; >> } >> } >> >> public Collection<Filter<BacklogItem>> getFilters() { >> List<Filter<BacklogItem>> filters = new >> ArrayList<Filter<BacklogItem>>() ; >> for (String activeFilter : container.getActiveFilters()) >> >> filters.add(container.getAvailableFilters().get(activeFilter)) ; >> return filters ; >> } >> } >> ********************************************************************************** >> public abstract class AbstractFilter { >> >> @Inject >> private ComponentResources resources ; >> >> @Parameter(defaultPrefix = >> TapestryConstants.LITERAL_BINDING_PREFIX, >> required=true) >> private String label ; >> >> @Environmental >> private FilterContainer container ; >> >> protected abstract String getFilterName() ; >> >> protected abstract Filter<BacklogItem> getFilter() ; >> >> @SetupRender >> void setupRender() { >> container.getAvailableFilters().put(getFilterName(), >> getFilter()) ; >> } >> >> void beginRender(MarkupWriter writer) { >> Link link = >> resources.createActionLink(TapestryConstants.ACTION_EVENT, >> false, getFilterName()) ; >> >> writer.writeRaw("<li>") ; >> writer.element("a", "href", link.toURI()) ; >> writer.write( container.getFilterState(getFilterName()) ) >> ; >> writer.write(label) ; >> writer.end() ; >> writer.writeRaw("</li>") ; >> } >> >> >> -- >> View this message in context: >> http://www.nabble.com/Environment-services-are-not-stateless-...---tp16733862p16733862.html >> Sent from the Tapestry - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > > -- > -- > TheDailyTube.com. Sign up and get the best new videos on the internet > delivered fresh to your inbox. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Environment-services-are-not-stateless-...---tp16733862p16734948.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]