Re: Will renderHead method be invoked when a component is rendered via wicket events?
On Tue, Mar 10, 2015 at 3:11 AM, MadasamySankarapandian < madas...@mcruncher.com> wrote: > On Mon, Mar 9, 2015 at 3:03 PM, Martin Grigorov > wrote: > > > Hi, > > > > If a component is rendered then its #renderHead() should be called! > > > > On Mon, Mar 9, 2015 at 4:08 AM, MadasamySankarapandian < > > madas...@mcruncher.com> wrote: > > > > > I am using bootstrap-timepicker.js in a single page > application > > . > > > Time picker is added in a panel which is then embedded in the page. > When > > > the entire page is reloaded, the timepicker is working fine. However, > > when > > > the respective panel is displayed via Wicket events, the time picker is > > not > > > rendered. I am using Component#onEvent(Ievent) method to display the > > panel. > > > The javascript resource reference for timepicker is added in renderHead > > > method. I would like to know if a panel is reloaded during onEvent > call, > > > will rendeHead method be invoked or not? > > > > > > > > > Here are few code snippets to help you all understand what I am trying? > > > > > > public class BasePage > > > { > > > > > > public void renderHead(IHeaderResponse response) > > > > > > > >>Call super.renderHead(response) too. > > > > >>Is this a method in the page or in SelectionPanel ?! > > > > This method is in BasePage. > > > > > > { > > > response.render(JavaScriHeaderItem.forReference(new > > > JavaScriptResourceReference(bootstrap-timepicker.js))); > > > response.render(JavaScriHeaderItem.forReference(new > > > JavaScriptResourceReference(common.js))); > > > } > > > > > > //event is received to display panel > > > public void onEvent(IEvent ievent) > > > { > > > super.onEvent(ievent) > > > if(event.getPayLoad() instance of Notification) > > > { > > > Notification notification = (Notification) event.getPayload(); > > > PageParameters parameters = notification.getPageParameters() > > > Panel selectedPanel = getSelectedPanel(parameters, > > > notification.getPanelClass); > > > BasePage.this.selectedPanel.replaceWith(selectedPanel); > > > > > > > >>There is no Ajax here, so the whole page is re-rendered and > #renderHead() > > >>should be called for all visible components. > > >Sorry here ajax is involved. In the sample code i forgot to > add. >selectedPanel.setOutputMarkupId(true); >notification.getTarget().add(selectedPanel); > In that case only selectedPanel's #renderHead() will be called. BasePage#renderHead() won't be called because the page is not re-rendered with the Ajax response. Martin Grigorov Funemployed! Available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov > > > > > > } > > > } > > > } > > > > > > > > > -- > > > Thanks and regards > > > Madasamy > > > > > > > > > -- > Thanks and regards > Madasamy >
Re: Will renderHead method be invoked when a component is rendered via wicket events?
On Mon, Mar 9, 2015 at 3:03 PM, Martin Grigorov wrote: > Hi, > > If a component is rendered then its #renderHead() should be called! > > On Mon, Mar 9, 2015 at 4:08 AM, MadasamySankarapandian < > madas...@mcruncher.com> wrote: > > > I am using bootstrap-timepicker.js in a single page application > . > > Time picker is added in a panel which is then embedded in the page. When > > the entire page is reloaded, the timepicker is working fine. However, > when > > the respective panel is displayed via Wicket events, the time picker is > not > > rendered. I am using Component#onEvent(Ievent) method to display the > panel. > > The javascript resource reference for timepicker is added in renderHead > > method. I would like to know if a panel is reloaded during onEvent call, > > will rendeHead method be invoked or not? > > > > > > Here are few code snippets to help you all understand what I am trying? > > > > public class BasePage > > { > > > > public void renderHead(IHeaderResponse response) > > > > >>Call super.renderHead(response) too. > > >>Is this a method in the page or in SelectionPanel ?! > > This method is in BasePage. > > > { > > response.render(JavaScriHeaderItem.forReference(new > > JavaScriptResourceReference(bootstrap-timepicker.js))); > > response.render(JavaScriHeaderItem.forReference(new > > JavaScriptResourceReference(common.js))); > > } > > > > //event is received to display panel > > public void onEvent(IEvent ievent) > > { > > super.onEvent(ievent) > > if(event.getPayLoad() instance of Notification) > > { > > Notification notification = (Notification) event.getPayload(); > > PageParameters parameters = notification.getPageParameters() > > Panel selectedPanel = getSelectedPanel(parameters, > > notification.getPanelClass); > > BasePage.this.selectedPanel.replaceWith(selectedPanel); > > > > >>There is no Ajax here, so the whole page is re-rendered and #renderHead() > >>should be called for all visible components. > Sorry here ajax is involved. In the sample code i forgot to add. selectedPanel.setOutputMarkupId(true); notification.getTarget().add(selectedPanel); > > > } > > } > > } > > > > > > -- > > Thanks and regards > > Madasamy > > > -- Thanks and regards Madasamy
Re: Will renderHead method be invoked when a component is rendered via wicket events?
Hi, If a component is rendered then its #renderHead() should be called! On Mon, Mar 9, 2015 at 4:08 AM, MadasamySankarapandian < madas...@mcruncher.com> wrote: > I am using bootstrap-timepicker.js in a single page application . > Time picker is added in a panel which is then embedded in the page. When > the entire page is reloaded, the timepicker is working fine. However, when > the respective panel is displayed via Wicket events, the time picker is not > rendered. I am using Component#onEvent(Ievent) method to display the panel. > The javascript resource reference for timepicker is added in renderHead > method. I would like to know if a panel is reloaded during onEvent call, > will rendeHead method be invoked or not? > > > Here are few code snippets to help you all understand what I am trying? > > public class BasePage > { > > public void renderHead(IHeaderResponse response) > Call super.renderHead(response) too. Is this a method in the page or in SelectionPanel ?! > { > response.render(JavaScriHeaderItem.forReference(new > JavaScriptResourceReference(bootstrap-timepicker.js))); > response.render(JavaScriHeaderItem.forReference(new > JavaScriptResourceReference(common.js))); > } > > //event is received to display panel > public void onEvent(IEvent ievent) > { > super.onEvent(ievent) > if(event.getPayLoad() instance of Notification) > { > Notification notification = (Notification) event.getPayload(); > PageParameters parameters = notification.getPageParameters() > Panel selectedPanel = getSelectedPanel(parameters, > notification.getPanelClass); > BasePage.this.selectedPanel.replaceWith(selectedPanel); > There is no Ajax here, so the whole page is re-rendered and #renderHead() should be called for all visible components. > } > } > } > > > -- > Thanks and regards > Madasamy >
Will renderHead method be invoked when a component is rendered via wicket events?
I am using bootstrap-timepicker.js in a single page application . Time picker is added in a panel which is then embedded in the page. When the entire page is reloaded, the timepicker is working fine. However, when the respective panel is displayed via Wicket events, the time picker is not rendered. I am using Component#onEvent(Ievent) method to display the panel. The javascript resource reference for timepicker is added in renderHead method. I would like to know if a panel is reloaded during onEvent call, will rendeHead method be invoked or not? Here are few code snippets to help you all understand what I am trying? public class BasePage { public void renderHead(IHeaderResponse response) { response.render(JavaScriHeaderItem.forReference(new JavaScriptResourceReference(bootstrap-timepicker.js))); response.render(JavaScriHeaderItem.forReference(new JavaScriptResourceReference(common.js))); } //event is received to display panel public void onEvent(IEvent ievent) { super.onEvent(ievent) if(event.getPayLoad() instance of Notification) { Notification notification = (Notification) event.getPayload(); PageParameters parameters = notification.getPageParameters() Panel selectedPanel = getSelectedPanel(parameters, notification.getPanelClass); BasePage.this.selectedPanel.replaceWith(selectedPanel); } } } -- Thanks and regards Madasamy