There's a very good reason why they must be private - because as soon as you annotate them with @Property, @Parameter or similar, they don't exist!
Tapestry replaces your variables with it's own getter and setters - part of the magic that ensures the variables are always correct at runtime. The only way T5 can ensure it's replaced all usage of the variables with getters / setters is by forcing them to be private. (If they were public T5 would have to scan the entire class path and attempt to instrument everything!) If you have many variables, try putting them inside a bean. Then you'll have one getter for the bean and the variables inside can be of any scope you want. If you want access to injected services, simply re-inject them in the subclass. Steve. On 21 October 2011 22:48, hese <1024h...@gmail.com> wrote: > > I understand encapsulation and the need for it, but isn't it very common for > base classes to have protected variables which the derived classes can > access freely without having accessor methods? > > Is there any architectural reason in tapestry for disallowing this for > property and injected variables? I get this error - > > ... contains fields that are not private. You should change these fields to > private, and add accessor methods if needed. > > I have a wizard and there are some common properties and injected stuff ... > but i want to freely access these variables by having them 'protected' > instead of writing numerous getters and setters. > > > > > > > > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/why-does-tapestry-force-variables-to-be-private-tp4924925p4924925.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > 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