You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Milan Durovic <mi...@milica.com.au> on 2012/01/22 08:18:53 UTC
tomahawk t:schedule not reacting to mouseListener setting
Hi,
I'm trying to handle mouse click events over schedule entries in t:schedule Tomahawk component. In the page definition I have:
<t:schedule value="#{allEvents.model}" id="myEvents"
rendered="true" readonly="false"
theme="#{allEvents.theme}" tooltip="true"
mouseListener="#{allEvents.clicked}"
entryRenderer="#{allEvents.renderer}"
headerDateFormat="#{allEvents.headerDateFormat}"
expandToFitEntries="true"
splitWeekend="false"
/>
and the method is defined as:
public String clicked( ScheduleMouseEvent event )
{
switch( event.getEventType() )
…
Originally, method "clicked" was void, but I changed this to returning String, after looking at the source code of the ScheduleTagHandler class, "createMetaRuleset" method.
However, in either case, it doesn't work. "clicked" method never gets invoked, and in logs I can't find anything that would indicate if something was wrong.
I was using MyFaces JSF 2.0, then upgraded to JSF 2.1 - no change. t:schedule component works in every aspect (i.e. displaying entries, asking for new entries when the model changes selectedDate etc etc) EXCEPT for capturing mouse clicks.
I remember long ago when I first used this class, capturing events worked, however, I didn't need it. Now I need it, but it doesn't work. I'm using facelets - mentioning this because I saw some people had problems making this work with facelets, but those problems seem to be restricted to several years ago, before facelets got integrated with MyFaces.
Any ideas what's wrong here?
Regards,
Milan
Re: tomahawk t:schedule not reacting to mouseListener setting
Posted by Georg Portwich <po...@blueskye.de>.
Hi Milan,
yes I changed the name of the attribute from mouseListener to
mouseListenerExpression.
Georg
Am 24.01.2012 23:03, schrieb Milan Durovic:
> Thanks Georg,
>
> I also looked into the definition of org.apache.myfaces.UISchedule and
> tried replacing "mouseListener" attribute with mouseListenerExpression,
> like here:
>
> <t:schedule value="#{allEvents.model}" id="myEvents"
> rendered="true" readonly="false"
> theme="#{allEvents.theme}" tooltip="true"
> mouseListenerExpression="#{allEvents.clicked}"<=== see here
> entryRenderer="#{allEvents.renderer}"
> headerDateFormat="#{allEvents.headerDateFormat}"
> expandToFitEntries="true"
> splitWeekend="false"
> />
>
> and finally I did get SOME response in the form of an error report due to
> wrong wiring, but AT LEAST I could see that mouse event WAS being
> delivered. I guess if I do the step you did, it would probably work. One
> question: did you also change the name of the mouseListener t:schedule
> attribute to mouseListenerExpression for this to work?
>
> I think this is definitely a bug and I'll see if I can find out where to
> report it to Tomahawk team. This component is very useful and handling
> mouse events properly is very important.
>
> Thanks,
> Milan
>
> PS. While I'm aware of the role of tag handlers in JSF, I never actually
> studied in detail the mechanics of how they are wired with the rest.
>
>
Re: tomahawk t:schedule not reacting to mouseListener setting
Posted by Milan Durovic <mi...@milica.com.au>.
Thanks Georg,
I also looked into the definition of org.apache.myfaces.UISchedule and
tried replacing "mouseListener" attribute with mouseListenerExpression,
like here:
<t:schedule value="#{allEvents.model}" id="myEvents"
rendered="true" readonly="false"
theme="#{allEvents.theme}" tooltip="true"
mouseListenerExpression="#{allEvents.clicked}" <=== see here
entryRenderer="#{allEvents.renderer}"
headerDateFormat="#{allEvents.headerDateFormat}"
expandToFitEntries="true"
splitWeekend="false"
/>
and finally I did get SOME response in the form of an error report due to
wrong wiring, but AT LEAST I could see that mouse event WAS being
delivered. I guess if I do the step you did, it would probably work. One
question: did you also change the name of the mouseListener t:schedule
attribute to mouseListenerExpression for this to work?
I think this is definitely a bug and I'll see if I can find out where to
report it to Tomahawk team. This component is very useful and handling
mouse events properly is very important.
Thanks,
Milan
PS. While I'm aware of the role of tag handlers in JSF, I never actually
studied in detail the mechanics of how they are wired with the rest.
Re: tomahawk t:schedule not reacting to mouseListener setting
Posted by Georg Portwich <po...@blueskye.de>.
Hi Milan,
I run into a similar problem some month ago. I debuged the class
org.apache.myfaces.custom.schedule.ScheduleTagHandler
This is original class:
/**
*
* @since 1.1.7
*/
public class ScheduleTagHandler extends ComponentHandler {
private static final String MOUSE_LISTENER = "mouseListener";
private static final Class [] mouseListenerParamList = new
Class[]{ScheduleMouseEvent.class};
public ScheduleTagHandler(ComponentConfig tagConfig) {
super(tagConfig);
}
protected MetaRuleset createMetaRuleset(Class type)
{
return super.createMetaRuleset(type).alias("class", "styleClass")
.addRule(
new MethodRule(MOUSE_LISTENER,
String.class, mouseListenerParamList));
}
}
I found that the MOUSE_LISTENER is not listening on mouseListener but on
mouseListenerExpression (see myfaces-metadata.xml definition of type
org.apache.myfaces.UISchedule).
So I have changed the class to:
public class ScheduleTagHandler extends HtmlComponentHandler {
private static final String MOUSE_LISTENER = "mouseListenerExpression";
public ScheduleTagHandler(ComponentConfig tagConfig) {
super(tagConfig);
}
@Override
protected MetaRuleset createMetaRuleset(Class type)
{
return super.createMetaRuleset(type).alias("class", "styleClass")
.addRule(
new MethodRule(MOUSE_LISTENER,
String.class, new Class[]
{ScheduleMouseEvent.class}));
}
}
After I changed the class, the method assigned to
mouseListenerExpression was called on the clickEvents in the t:scheduled
tag.
I never found an confirmation that this is the correct way to handle this.
Georg
Am 22.01.2012 08:18, schrieb Milan Durovic:
> Hi,
>
> I'm trying to handle mouse click events over schedule entries in t:schedule Tomahawk component. In the page definition I have:
>
> <t:schedule value="#{allEvents.model}" id="myEvents"
> rendered="true" readonly="false"
> theme="#{allEvents.theme}" tooltip="true"
> mouseListener="#{allEvents.clicked}"
> entryRenderer="#{allEvents.renderer}"
> headerDateFormat="#{allEvents.headerDateFormat}"
> expandToFitEntries="true"
> splitWeekend="false"
> />
>
> and the method is defined as:
>
> public String clicked( ScheduleMouseEvent event )
> {
> switch( event.getEventType() )
> …
>
> Originally, method "clicked" was void, but I changed this to returning String, after looking at the source code of the ScheduleTagHandler class, "createMetaRuleset" method.
>
> However, in either case, it doesn't work. "clicked" method never gets invoked, and in logs I can't find anything that would indicate if something was wrong.
>
> I was using MyFaces JSF 2.0, then upgraded to JSF 2.1 - no change. t:schedule component works in every aspect (i.e. displaying entries, asking for new entries when the model changes selectedDate etc etc) EXCEPT for capturing mouse clicks.
>
> I remember long ago when I first used this class, capturing events worked, however, I didn't need it. Now I need it, but it doesn't work. I'm using facelets - mentioning this because I saw some people had problems making this work with facelets, but those problems seem to be restricted to several years ago, before facelets got integrated with MyFaces.
>
> Any ideas what's wrong here?
>
> Regards,
> Milan
Re: tomahawk t:schedule not reacting to mouseListener setting
Posted by Milan Durovic <mi...@milica.com.au>.
... just to add something I tried in the meantime. I created a page that
doesn't use facelets, but with the basically same content, to see if
facelets have anything to do with the reported problem. They don't. The
problem is still there: everything works, except for capturing mouse
clicks.