Vjeran Marcinko <vjeran.marcinko <at> email.t-com.hr> writes:

> I started experimentally porting my small Tapestry3.0 apps to 4.0), and 
> cannot get away from feel that dependency injection is a bit overkill for 
> web pages/components. (BTW, boot time in 4.0 is much, much larger. I assume 
> it is due to HiveMind bytecode enhancing many things in there ?)

Agreed (regarding the boot time). I think this is a major issue to be 
tackled.

> Burden is that when using service locator, if some dependency is needed on 
> many places (such as Visit) I can centralize fetching of this object in 
> superclass, and on the other hand, with DI, I have to define it in every 
> spec XML. I know that annotations will come to rescue, but untill then.... 

Right. It may help a little by encapsulating it into a component:

ClearingHouse.jwc:
<component-specification>
  <inject property="visit" type="state" object="visit"/>
  <inject property="global" type="state" object="global"/>
</component-specification>

Foo.html:
<span jwcid="[EMAIL PROTECTED]"/>

Foo.java:

  getComponent("ch").getProperty("visit");
  getComponent("ch").getProperty("global");

It isn't too much work as the ClearingHouse component is defined
only once.

> Similar case is page that requires many messages from .properties. In old 
> 3.0 days it's not much work, just call getMessage(key) and that's it. Now, I 
> would have to inject every message by specifying it in XML. Too much typing 
> just for simple message fetch. Same for injecting pages..etc...

You don't have to use injection. For example, you may try:

  getMessages().getMessage(key);

You can also define a convenient method in your base page:

class Base {
  String getMsg(String key) {
    return getMessages().getMessage(key);
  }
}

--
Author of an e-Book for learning Tapestry (http://www.agileskills2.org/EWDT)


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to