My scenario: on an ajax event I replace a webmarkupContainer with one of my
components which have some wicket IBehaviorListener.
The problem is that this replace happen due to Ajax request, and the
behavior gets listed on don ready:
Wicket.Event.add(window, "domready", function(event) {
Wicket.Ajax.get({'u': 'some/url', 'c': 'linkId', 'e':'click'}));
// ... more event registrations and onDomReady scripts }
I'm assuming that, being generated in the this event registration code
happens for all components that are added explicitly, but not for any
components that are added dynamically by me.
How can I call the new container with the Ajax behaviors or change the
current implementation so the wicket Ajax behaviors would be called?
To be more precise I have a table with a filter which rendered by replacing
web markup container with this TableWithFilter. This scenario happens on
Ajax so when the page loaded by the first time the TableWithFilter does not
exist, it will appear on screen due to Ajax request that will occur
TableWithFilter contains AbstractFilterPanel which has a org.apache.wicket.
ajax.markup.html.form.AjaxButton which render the table by Ajax the button
is
initilze in the c'tor like this :
public abstract class AbstractFilterPanel extends Panel {
public AbstractFilterPanel(String id, IModel<?> model, BMDefaultDataGrid
toRender, SearchCriteria searchCriteriaIn, FeedbackPanel feed) {
super(id, model);
this.tableTorender = toRender;
this.setSearchCriteria(searchCriteriaIn);
this.feedbackPanel = feed;
}
//called by the AbstractFilterPanel sons
protected void init() {
Injector.get().inject(this);
setOutputMarkupId(true);
form = new ExpendedForm(FORM);
form.setOutputMarkupId(true);
form.setMarkupId("fillter-form");
add(form);
new AjaxButton(SUBMIT_FILLTER_FORM, form) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
getSearchCriteria().clear();
onFillterSubmited();
if (getPreDefinedSearchCriteria() != null) {
getSearchCriteria().and(getPreDefinedSearchCriteria());
}
toRender.resetSelectedItems();
target.add(toRender);
toRender.resetCurrentPage();
target.add(feedbackPanel);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(feedbackPanel);
}
@Override
public boolean isEnabled() {
return super.isEnabled() && isApplyBtnEnabled();
}
}
}
what should AbstractFilterPanel implement in order to add a javascript that
register his appaly btn when it's rendered on page ?
Thanks in advance.