Hi guys,
my +1 (and I believe this is a must) to include
https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=755
for 2.1 and deferring the rest to 2.2.
@Leonardo: just to clarify - with 755, it will be possible to pass
multiple actions to the same composite component (it is really a
bugger that this is not possible today) and one will still have to
supply a method-signature, right? this is missing from your example.
best regards,
Martin
On 10/27/10, Leonardo Uribe <lu4242(a)gmail.com> wrote:
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
--
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces