You are right, component annotations are clumsy. But, currently there
are 3 ways to define a component in a page - you might find .jwc or
.html way more apealing, and still use annotations for injecting or
setting defaults - that way you still can use what you like
(annotations) *and* convenient component defs.
ציטוט Matt Welch:
I'm just getting into Tapestry and while I like many of the concepts,
I'm finding it to be a little complex. Here's an example. It's my
understanding that specifying components for you pages via annotation
is new to Tapestry 4.0. I'm a fan of annotations however, in this case
they seem a little clumsy. Here's an example from my adaptation of the
tutorial I'm following (Kent Tong's Enjoying Web Development with
Tapestry):
@Component(
id="productsLoop",
type="For",
bindings={
"source=products",
"value=currentProduct",
"element=literal:tr"
}
)
public abstract IComponent getProductsFor();
That's how I declared a For component for the eStore tutorial. I guess
that's really not so bad and my IDE keep the indentation clean so that
it's not too hard to follow, but to be honest, what I was kind of
expecting was something a little more code intensive rather than XML
or annotation intensive. For instance, if the BasePage or AbstractPage
had a method like addPageComponent() then in some kind of
intialization method or perhaps the contstructor I might do something
like:
{
For productsLoop = new For();
products.setId("productsLoop");
productsLoop.setSource(getProducts());
productsLoop.setValue(getCurrentProduct());
productsLoop.setElement("tr");
addPageComponent(productsLoop);
}
I'm guessing that this alternate way of doing things doesn't exist
since I haven't seen any tutorials or examples that show anything like
that. Has anyone ever tried to do something like that or would there
be drastic changes to core framework needed?
Again, I'm pretty new to Tapestry so it may be that I'll get used to
such heavy annotations/XML in time, so take this for what it is: a
newb's first impressions.
Matt Welch
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]