jsr344-experts@javaserverfaces-spec-public.java.net

[jsr344-experts] [1089-PassThroughAttributes] Make it even better.

From: Edward Burns <edward.burns_at_oracle.com>
Date: Fri, 22 Jun 2012 15:22:06 -0700

>>>>> On Thu, 21 Jun 2012 22:06:03 -0400, Andy Schwartz <andy.schwartz_at_oracle.com> said:

PD> Hi guys,
PD>
PD> Even if I find it awesome to have pass through attributes in JSF, I
PD> can't really find the current draft acceptable from a user
PD> perspective. It really gives me the feeling it's only half-baked. It
PD> does its job, yes, but it's so verbose, so heavy... Let's take a
PD> simple example. Here is a classic HTML5 usage of the input:

PD> <input type="email" placeholder="To..." autofocus="autofocus"
PD> multiple="multiple"/>
PD>
PD> How would I write it in JSF with the current proposal? Probably
PD> something like that:
PD>
PD> <h:inputText>
PD> <f:passThroughAttribute name="placeholder" value="Email"/>
PD> <f:passThroughAttribute name="autofocus" value="autofocus"/>
PD> <f:passThroughAttribute name="multiple" value="multiple"/>
PD> </h:inputText>
PD>
PD> What can we see here?
PD>
PD> I can't find a way to set the type to "email" (maybe I'm missing the
PD> solution).

I just committed spec and implementation to make this possible:

<h:inputText value="#{user.email}">

  <f:passThroughAttributes value="#{user.attrs}" />

</h:inputText>

User.java {

  Map<String, Object> getAttrs() {

    make your map have attrs for type, placeholder, autofocus, and multiple.

  }

PD> But it would be good that the spec handle the fact that if
PD> you write a pass trough attribute (like writting
PD> <f:passThroughAttribute name="type" value="email"/>) that collide with
PD> a generate one (<h:inputText> should have generated type="text"), the
PD> pass through override the generated one.

The spec does provide for the passThroughAttributes to take precedence
over any renderer-specific attributes. Look in the nightly build of the
spec. [1]

PD> In HTML5, my input is one line and auto-closed, in JSF, it's 5 lines,
PD> with an opening and a closing to the inputText.

We can't get around the fact that the facelets VDL is XML. If you want
to have a JSF VDL that is *not* XML, then that's a different VDL.
There's nothing stopping someone from having a non-XML VDL.

PD> Seriously? I'm 100% in
PD> favor of supporting pass trough directly inside the JSF component. It
PD> will make the code less verbose, more readeable, more HTML5 like...
PD> just better. Something like:
PD>
PD> <h:inputText required="true" p:placeholder="Email"
PD> p:autofocus="autofocus" p:multiple="multiple" />

PD> Isn't that so much better? Honestly?

CC> p:placeholder

CC> instead of

CC> f:passThroughAttribute

CC> looks much better and clean.

I chose to leave it off for now but I'm willing to do it because others
have indicated that they want it. I'll add it. It will be "in addition
to" not "instead of".

>>>>> On Fri, 22 Jun 2012 11:39:20 -0400, Andy Schwartz <andy.schwartz_at_oracle.com> said:

AS> Although I am behind our effort to produce a more HTML-centric authoring
AS> experience (ie. jsfc++), I suspect that even if we deliver the most
AS> complete, beautiful solution possible for this, there will always be
AS> folks who will just want to use the plain old Facelets tags (h:*, or in
AS> my case, af:* tags). For these folks (which, btw, is pretty much
AS> everyone at the moment, since jsfc is fairly limited in its current
AS> form), having a more convenient way to tack on pass through attributes
AS> would be a nice addition to the spec, regardless of what we do with
AS> jsfc.

Yes. I just committed today the what we agreed to, minus the JSON
support and the namespaced attributes.

PD> And since we are at making life easier, you might see that lots of
PD> HTML5 attribute have the same name and value (autofocus, multiple,
PD> checked, disabled, readonly, ...). Wouldn't it be cool that if a pass
PD> through attribute has a name but no value, it takes it's name as value?

PD> <h:inputText p:autofocus p:multiple/> => <input type="text"
PD> autofocus="autofocus" multiple="multiple"/>

Sure, why not!

PD> <h:inputText>
PD> <f:passThroughAttribute name="autofocus" />
PD> <f:passThroughAttribute name="multiple" />
PD> </h:inputText>

PD> => <input type="text" autofocus="autofocus" multiple="multiple"/>

And why not!

PD> One more for the road, I know most of the EG members didn't really
PD> like it,

Remember, I put JSON in right away but other EG members wanted it out.

PD> Right know, by not supporting JSON inside <f:passThroughAttributes>
PD> you will only force people who need JSON support to create a parser
PD> that will convert a JSON array to a Java Map, and do the conversion in
PD> their backing beans.

>>>>> On Fri, 22 Jun 2012 17:54:32 +0200, Frank Caputo <frank_at_frankcaputo.de> said:

FC> Absolutely right. But there is obviously a big opposition (even for
FC> enhancing jsfc).

I'm not necessarily opposed, but I am not convinced composite components
are insufficient. I'm willing to be convinced, though.

Ed

-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/
| 19 Business days til JSF 2.2 Public Review to EG
[1] http://weblogs.java.net/blog/edburns/archive/2012/05/17/how-view-absolute-latest-jsf-22-spec-snapshot