[jsr-314-open-mirror] [jsr-314-open] [755-cc:attributesSpecialKeys] (was: Re: composite:attribute "targets" property does not match with ViewDeclarationLanguage.retargetMethodExpressions)

Leonardo Uribe lu4242 at gmail.com
Tue Oct 26 20:56:55 EDT 2010


Hi

Attached to this issue:

https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=755

 there is a patch that shows what is required to use

#{cc.attrs.action} ,
#{cc.attrs.actionListener} ,
#{cc.attrs.validator} ,
#{cc.attrs.valueChangeListener}

The idea is just use this expressions instead set "targets" property on
cc:attribute.

In this way it is possible to write something like this:

testActionVE.xhtml

<testcc:actionVE label="Press me" action="#{helloWorld.send2}"/>

actionVE.xhtml

<cc:interface>
    <cc:attribute name="action"/>
    <cc:attribute name="label"/>
</cc:interface>
<cc:implementation>
    <h:commandButton value="#{cc.attrs.label}" action="#{cc.attrs.action}"/>
</cc:implementation>

Fortunately, this change does not prevent "targets" attribute to work. From
my point
of view seems to be very intuitive, compared with the other style.

<cc:interface>
    <cc:attribute name="action" targets="button" />
    <cc:attribute name="label"/>
</cc:interface>
<cc:implementation>
    <h:commandButton id="button" value="#{cc.attrs.label}"/>
</cc:implementation>

So at least for cc:attribute it seems valid (and wanted) to do the change.

Thinking more about this issues I have a proposal to solve:

https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=859

Composite components only support one action attribute

Why this syntax is not possible?

<cc:interface>
    <cc:attribute name="action" method-signature="Object myMethod();void
myMethod()" ..../>
    <cc:attribute name="actionListener" method-signature="void
myMethod(javax.faces.event.ActionEvent);void myMethod()" ..../>
    <cc:attribute name="label"/>
</cc:interface>

That means, allow multiple signatures for a method expression and use some
wrapper
like the one proposed with the previous patch.

One last comment: How to deprecate "targets" also for cc:actionSource,
cc:valueHolder,
cc:editableValueHolder and cc:clientBehavior? One possibility is do
something like this:

      <ez:loginPanel id="loginPanel" model="#{bean}">
        <f:actionListener for="loginEvent"
                          binding="#{bean.loginEventListener}" />
        <f:actionListener for="cancelEvent"
                          binding="#{bean.cancelEventListener}" />
      </ez:loginPanel>

      <composite:interface name="loginPanel">
        <composite:actionSource name="loginEvent" />
        <composite:actionSource name="cancelEvent" />
      </composite:interface>
      <composite:implementation>
                  <h:commandButton name="button1">
                         <composite:insertActionSource name="loginEvent"/>
                  </h:commandButton>
                  <x:mycompositecomponent name="button2">
                         <composite:insertActionSource name="cancelEvent"
for="someOtherEvent"/>
                  </x:mycompositecomponent>
      </composite:implementation>

In few words, use a tag to insert the attached objects. That will work,
because
in a composite component first it is resolved the body on the page than the
tags
inside composite:implementation. The advantage over "targets" stuff is the
implementation details are when the people expect and it could handle
complex
cases in a better way like nested composite components usage, and override
"for"
attribute.

I know implement that proposal could be complex to implement, but I think it

could be good to at least take it into consideration.

I can provide more code of each proposal if necessary.

best regards,

Leonardo Uribe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jsr-314-open-mirror/attachments/20101026/df126a4a/attachment-0002.html 


More information about the jsr-314-open-mirror mailing list