Man, thank you! In case somebody else will search for this answer before reading http://tapestry.apache.org/environmental-services.html here is a sample code:
Index.java ================== @Inject private Environment environment; private MyComponentContext myComponentContext; public void setupRender() { environment.push(MyComponentContext.class, new MyComponentContext(myString, myInteger)); } public void afterRender() { environment.pop(MyComponentContext.class); } MyComponentContext.java ================== public class MyComponentContext { String myString; Integer myInteger; public MyComponentContext(String myString, Integer myInteger) { this.myString= myString; this.myInteger= myInteger; } // getters and setters } MyComponent.java ================== public class MyComponent { @Environmental private MyComponentContext myComponentContext; public String someMethod() { String justSomething = myComponentContext.getMyString(); return "Hello " + justSomething; } } Cheers, borut 2011/8/24 Steve Eynon <steve.ey...@googlemail.com> > > As soon as one component pops the object(s) > > Ahh - that's why there's an Environement.peek() !!! > > Or, in your component, you could just annotate the Object with > @Environmental, e.g. > > @Environmental > private MyTwoStrings ss; > > Steve. > -- > Steve Eynon > > > On 24 August 2011 21:33, Borut Bolčina <borut.bolc...@gmail.com> wrote: > > 2011/8/24 Steve Eynon <steve.ey...@googlemail.com> > > > >> If the component needs 2 string parameters to function, then it needs > >> 2 string parameters! (Much like if a method needs 2 strings, then you > >> need to pass 2 strings.) > >> > >> > > Well, yes :-) > > > > > >> Other alternatives are dependent on re-usability requirements: > >> > >> a) If the 2 strings are always used together then wrap them in a value > >> object and pass that (you can pass anything as Component parameters). > >> > >> > > Goes without saying - OO style. > > > > > >> b) If the component is deeply nested and / or the strings need to be > >> available to multiple components (and you're certain they'll always > >> exist) then you could push them on the Environmental stack and not > >> pass any parameters - just have the component query the stack. > >> > >> > > Wouldn't that work just for one component? As soon as one component pops > the > > object(s) from the Environment stack, others won't have it (them) > anymore? > > > > Thanks, > > borut > > > > > > Steve. > >> -- > >> Steve Eynon > >> > >> > >> On 24 August 2011 18:07, Borut Bolčina <borut.bolc...@gmail.com> wrote: > >> > Hi, > >> > > >> > if a component needs to have its parent's activation context (say two > >> > strings), is the preffered way to pass it as parameters or is there a > >> "less > >> > code way"? > >> > > >> > The solution must not use a session. > >> > > >> > Cheers, > >> > Borut > >> > > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > >> For additional commands, e-mail: users-h...@tapestry.apache.org > >> > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >