You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Robert Patt-Corner <ro...@gmail.com> on 2008/02/23 18:24:59 UTC

Re: Java MethodBinding syntax for Tomahawk Scheduler ScheduleMouseEvent

In reply to my own message, in case others find it useful.

Fairly straightforward (after weeks of research!) ... the constructor for a
method binding takes the class of the argument as an argument to the
constructor.  So do this:

Class args[] = {ScheduleMouseEvent.class};
MethodBinding clickBinding =
getFacesContext().getApplication().createMethodBinding("#{
myHandlerName.myClickHandlingMethod}", args);


Sigh.

On Fri, Dec 28, 2007 at 8:29 AM, Robert Patt-Corner <ro...@gmail.com>
wrote:

> Other clues to what I may be doing wrong:
>
> 1. If I use the <t:schedule> tag to place a tag-created (distinct from my
> managed bean-created) schedule directly below the dynamically created
> schedules I see the following behaviour when clicking the tab-created
> schedule:
>
> a. If the dynamically created schedule is present (e.g. executed) a click
> on the tag-created schedule fails in the same way, e.g. method not found.
> b. If I comment out the creation of the dynamically created schedule, a
> click on the tag-created schedule succeeds!
>
> Suggesting that my creation technique in the managed bean is doing
> something evil.
>
> 2. I am creating the dynamic components in the setter of the parent
> component.  I was unable to create them in the backing bean constructor, as
> the parent component is not yet instantiated.  I see references to an
> "init()" method of managed beans in the literature but cannot create an
> effective one.  A simple public void init() is never invoked.
>
> The setter looks like this:
>
> public void setTabbedPaneTarget(HtmlPanelTabbedPane tabbedPaneTarget) {
>         this.tabbedPaneTarget = tabbedPaneTarget;
>         if (tabbedPaneTarget != null && tabbedPaneTarget.getChildCount ()
> == 0) {
>             populateTabs(tabbedPaneTarget);
>         }
>     }
>
> where populateTabs does the dirty work of instantiating tabs and a
> schedule as a child of each, shown below.
>
> R.
>
>
> On Dec 28, 2007 12:18 AM, Robert Patt-Corner <ro...@gmail.com> wrote:
>
> > Hi ...
> >
> > Can someone assist me with how to create a method binding in a Java
> > backing bean that will successfully bind a tomahawk Scheduler component's
> > ScheduleMouseEvent?
> >
> > I find that I can create valuebindings with no problem, and action
> > methodbindings (which take no argument).  However any attempt to create a
> > methodbinding for a method
> > that has a nonempty signature results in the method not being found by
> > the methodbinding code.
> >
> > for example, in the code below the commented out line attempts to bind
> > the mouse listener to an extant method.  If the method exists with the
> > proper signature:
> >
> > public void handleScheduleClick(ScheduleMouseEvent event)
> > or even:
> > public void handleScheduleClick(Object e){
> >
> > we get a "method not found" from the binding code.
> >
> > If, however the method has no arguments:
> > public void handleScheduleClick()
> >
> > then all goes swimmingly ... except that the arguments are wrong and we
> > get the corresponding error.
> >
> > Clearly I'm missing something, probably how to add an argument to a
> > method binding from the Java side.
> >
> > FWIW, the tag code, should I use a tag, works fine -- but I need to
> > generate these schedules dynamically in tabs.
> >
> > My current workaround involves dredging up the schedule in the action
> > method and probing for its lastClickedDate, but it's not a pretty sight.
> >
> > Any thoughts?
> >
> > R.
> >
> >
> >
> >
> > ============= Attempted Method Binding===============
> > HtmlSchedule mySchedule = new HtmlSchedule();
> >             mySchedule.setId("schedule" + p.getPid());
> >             mySchedule.setValueBinding("value", scheduleBinding);
> >             mySchedule.setValueBinding("visibleStartHour",
> > createValueBinding("#{scheduleSettings.visibleStartHour}"));
> >             mySchedule.setValueBinding("visibleEndHour",
> > createValueBinding("#{scheduleSettings.visibleEndHour}"));
> >             mySchedule.setValueBinding("workingStartHour",
> > createValueBinding("#{ scheduleSettings.workingStartHour}"));
> >             mySchedule.setValueBinding("workingEndHour",
> > createValueBinding("#{scheduleSettings.workingEndHour}"));
> >             //mySchedule.setValueBinding("readonly",
> > createValueBinding("#{ scheduleSettings.readonly}"));
> >             mySchedule.setValueBinding("theme", createValueBinding("#{
> > scheduleSettings.theme}"));
> >             mySchedule.setValueBinding("compactWeekRowHeight",
> > createValueBinding("#{ scheduleSettings.compactWeekRowHeight}"));
> >             mySchedule.setValueBinding("compactMonthRowHeight",
> > createValueBinding("#{scheduleSettings.compactMonthRowHeight}"));
> >             mySchedule.setValueBinding ("detailedRowHeight",
> > createValueBinding("#{scheduleSettings.detailedRowHeight}"));
> >
> >             //mySchedule.setMouseListener(createMethodBinding("#{
> > providerTemplateScheduleHandler.handleScheduleClick }"));
> >
> >             mySchedule.setAction(createMethodBinding("#{
> > providerTemplateScheduleHandler.scheduleAction}"));
> >             mySchedule.setReadonly(false);
> >             mySchedule.setSubmitOnClick (true);
> >             UIComponentTagUtils.setStringProperty(getFacesContext(),
> > mySchedule, "headerDateFormat", "EEEE");
> > =========End===============
> >
>
>