You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by rbrunet <rb...@forwardlogictech.com> on 2008/01/01 16:41:17 UTC

Re: [tomahawk schedule] model.getSelectedEntry() always null unless page reloaded

Hi Lukasz
      I had the same problem and figured out it might be related to the
lifecycle of the JSFs. Indeed, the getSelectedEntry() is null in the
scheduleClicked() call back. But if you add an action to your <t:schedule
...> that  
 refers to a method in your backing bean, then the getSelectedEntry() in
this method will be non-null. Mind you, I needed to have a reference to the
scheduleModel in my backing bean. So in my case, the tag is 

<t:schedule value="#{schedController.schedModel}"  theme="default"
tooltip="true"
			 mouseListener="#{schedController.processMouseEvent}"
action="#{schedController.createScheduleAction}" submitOnClick="true"
rendered="true" />
 

and the code in my backing bean (ScheduleController) is 

    public String createScheduleAction() {
        ScheduleEntry entry = this.schedModel.getSelectedEntry();
        
        createSchedule(entry);
        
        return "success";
    }


Hope this helps,

Richard


Łukasz Budnik wrote:
> 
> Hi All!
> 
> I have problem with Tomahawk Schedule.
> 
> When I click on existing entry, model returns null.
> 
> In my backing bean I have (snippet):
> 
> public void scheduleClicked(ScheduleMouseEvent event)  {
> 
> switch (event.getEventType()) {
>             case ScheduleMouseEvent.SCHEDULE_BODY_CLICKED:
> 
>                 // it always works...
> 
>                 break;
> 
>             case ScheduleMouseEvent.SCHEDULE_ENTRY_CLICKED:
> 
> 
> System.out.println("event.getSchedule().getModel().getSelectedEntry()
> = " + event.getSchedule().getModel().getSelectedEntry());
> 
> System.out.println("schedule.getModel().getSelectedEntry() = " +
> schedule.getModel().getSelectedEntry());
>                 System.out.println("model.getSelectedEntry() = " +
> model.getSelectedEntry());
>         }
> }
> 
> when I click empty space I get SCHEDULE_BODY_CLICKED, when I click
> existing
> entry I I get SCHEDULE_ENTRY_CLICKED but unfortunately I cannot  fetch
> selected entry
> 
> the code produces:
> 
> event.getSchedule().getModel().getSelectedEntry() = null
> schedule.getModel().getSelectedEntry() = null
> model.getSelectedEntry() = null
> 
> 
> the entry is selected (CSS has changed) but selected entry is null
> 
> when I reload page (with POST data, not refresh) it works:
> 
> event.getSchedule().getModel().getSelectedEntry() =
> pl.yourvision.crm.web.model.schedule.CrmScheduleEntry@12737a1
> schedule.getModel().getSelectedEntry() =
> pl.yourvision.crm.web.model.schedule.CrmScheduleEntry@12737a1
> model.getSelectedEntry() =
> pl.yourvision.crm.web.model.schedule.CrmScheduleEntry@12737a1
> 
> 
> but reloading whole page is not what one would really want to do...
> 
> any idea how to fetch selected entries?
> 
> best regards
> Łukasz
> 
> 

-- 
View this message in context: http://www.nabble.com/-tomahawk-schedule--model.getSelectedEntry%28%29-always-null-unless-page-reloaded-tp14275452p14567354.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.