Andy Schwartz wrote:
Hey Ken -

Ken Paulsen wrote On 4/13/2009 2:34 AM ET:

My 2 cents....

I'd rather see us pick a *standard value* for "a" ("ezcomp", "compositeComponent" too long??, etc.).

I would be okay with picking a standard value, though if we do this, the name should include something to indicate that this refers to an attribute map and not to the component.  So, "attrs" (or something like that) - not "ezcomp" or "compositeComponent", since this should refer to the composite component itself.
Ok, sounds good to me.  Maybe compAttrs?  (I'm not particularly good at naming. ;) )

  This is less confusing.  Less to worry about in the ezcomp declaration.

Hmm... Personally I don't find the use of a "var" attribute especially confusing, though perhaps I am not the typical user.  :-)  Anyone who has used  c:forEach or h:dataTable is already familiar with this concept, so there is precedent for this approach in the platform.  I keep thinking about c:forEach and h:dataTable and wondering whether these tags would have been better if the designers had just said: "Forget the var and varStatus attributes - let's just spec 'item' and 'status' implicit variables."  Personally I don't think this would have been an improvement.
Agreed... but if you have nested loops, that model falls apart.  I don't think we have that problem re: nested composite components (assuming scoping is done correctly -- it should).

BTW, we've been using the "var" approach for the ADF Faces page template component for years.  I don't remember our clients ever raising this as a point of confusion.  Actually, if composite component authors do find this confusing, they can of course always stick with good old compositeComponent.attrs.
If we go that route, why not alias any other variable that way?  I'd like to see a general mechanism, not a one-off impl for areas we deem to be special.

  Page author won't have to worry about the EZComp author masking their values.

Unless I am missing something here, the same is true if we go with a "var" approach.

I think you mean "without" the var approach?  The difference is the page author can expect what the reserved word will be vs. every component being different.

  And if scoping is done correctly, this value won't exist automatically outside the component which consumes it... so there's no name-space collision issue here.

I don't think we have namespace collision problems if we allow the composite component author to define their own attribute var name.
Agreed, and I don't think it is a problem if every composite component uses "X".  This value should only be meaningful while processing that composite component.


If a mapping *is* desired to make it shorter in later references, I'd suggest solving it more generically.  For example, in JSFTemplating an event handler can set a request attribute:

<event type="beforeCreate">
    setAttribute(key="a" value="#{compositeComponent.attributes}");
</event>


The above is not a proposal.  I am trying to point out that there are more generic easy solutions for this.  I don't like the complexity involved in a dynamic variable name -- it'll just confuse people.  Keep it simple.

To me the "var" approach seems much simpler than, say, requiring the composite component author to manually move the attributes map to a request-scoped variable.  Also, a solution where we shove the attributes map into some other scope (eg. request scope) has the downside of raising the name collision problem again, since now we need to compete with managed beans names that occupy that scope.
The above was not a suggested syntax, it's just one that works today.  If I had to pick a syntax on the fly, perhaps:

    <f:alias var="foo" target="#{some.el}" />

We could then make the "alias" scope it's own scope to avoid EL collisions, but masking will still be a problem (EL is poor that way unless you always are explicit... i.e: #{alias.foo} vs. #{foo}).

I guess the bottom line is that I can live with picking a standard name, but the "var" approach seems more elegant to me, and not especially confusing/complex, since this approach should already be familiar to JSTL/JSF users.  I can also live with not doing anything of course, though it would be nice to provide a more concise syntax so that composite component authors can tighten up their implementations.
I'm for it if its generalized (i.e. <f:alias /> type of solution)), I don't see the rationale for making a special case here.

Thanks!

Ken

Andy