You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, if someone needs to set second level jQuery property (for example properties oLanguage.oPaginate.sPrevious and oLanguage.oPaginate.sPrevious which can be used in DataTable) and uses method JQueryUtils#merge, he will ends up with
with partially rewritten options instead of merged options. JAVADoc and method name is little bit misleading
We can change method behaviour or (from backward compatibility reasons) add recursive (stack based) method with no such strict merge restrictions.
Example of ugly merging (see comments in code)
packagecz.donarus.tagr.web.components.bootstrap;
importorg.apache.tapestry5.annotations.Import;
importorg.apache.tapestry5.ioc.Messages;
importorg.apache.tapestry5.ioc.annotations.Inject;
importorg.apache.tapestry5.json.JSONObject;
importorg.got5.tapestry5.jquery.utils.JQueryUtils;
@Import(library = "DataTable.js")
publicclassDataTableextendsorg.got5.tapestry5.jquery.components.DataTable {
@InjectprivateMessagesmessages;
@OverridepublicJSONObjectgetOptions() {
JSONObjectoriginalPaginate = originalPaginate = newJSONObject();
originalPaginate.put("sPrevious", messages.get("datatable.oPaginate.sPrevious"));
originalPaginate.put("sNext", messages.get("datatable.oPaginate.sNext"));
JSONObjectoriginalLanguage = newJSONObject();
originalLanguage.put("oPaginate", originalPaginate);
/* FIXME: UGLY COPY PASTE FROM org.got5.tapestry5.jquery.components.DataTable, because without these lines call of JQueryUtils#merge in parent#setJS method will overwrite all oLanguage values by our returned properties (so without these lines only with pagination titles). */originalLanguage.put("sProcessing", messages.get("datatable.sProcessing"));
originalLanguage.put("sLengthMenu", messages.get("datatable.sLengthMenu"));
originalLanguage.put("sZeroRecords", messages.get("datatable.sZeroRecords"));
originalLanguage.put("sEmptyTable", messages.get("datatable.sEmptyTable"));
originalLanguage.put("sLoadingRecords", messages.get("datatable.sLoadingRecords"));
originalLanguage.put("sInfo", messages.get("datatable.sInfo"));
originalLanguage.put("sInfoEmpty", messages.get("datatable.sInfoEmpty"));
originalLanguage.put("sInfoFiltered", messages.get("datatable.sInfoFiltered"));
originalLanguage.put("sInfoPostFix", messages.get("datatable.sInfoPostFix"));
originalLanguage.put("sSearch", messages.get("datatable.sSearch"));
originalLanguage.put("sUrl", messages.get("datatable.sUrl"));
/* FIXME: END OF UGLY COPY PASTE */JSONObjectoptions = newJSONObject();
options.put("oLanguage", originalLanguage);
JQueryUtils.merge(options, super.getOptions());
returnoptions;
}
}
The text was updated successfully, but these errors were encountered:
Hi, if someone needs to set second level jQuery property (for example properties oLanguage.oPaginate.sPrevious and oLanguage.oPaginate.sPrevious which can be used in DataTable) and uses method JQueryUtils#merge, he will ends up with
with partially rewritten options instead of merged options. JAVADoc and method name is little bit misleading
We can change method behaviour or (from backward compatibility reasons) add recursive (stack based) method with no such strict merge restrictions.
Example of ugly merging (see comments in code)
The text was updated successfully, but these errors were encountered: