Using Handsontable with JSF
-
21-12-2019 - |
سؤال
Does anyone have experience with an jsf implemented handsontable? Is that even possible?
I'd appreciate some brabbling!
المحلول
I'm not aware of a wrapper for handsontable in JSF. Implementing such a wrapper for limited features is fairly simple, but this will really get complex and time consuming if you want to handle all callback hooks with AJAX.
An alternative may be Primefaces dataTable.
نصائح أخرى
Yes you can, make a link as follows:
xhtml
<h:inputHidden id="import_json_data" value="#{managedBean.json_data}" />
<p:commandButton value="Import Data" onstart="loadJson()" actionListener="#{managedBean.importData()}" />
<script type="text/javascript" charset="utf-8">
function loadJson() {
var varieties = $('#value_table').data('handsontable').getData();
var varieties_data = JSON.stringify(varieties);
$('#import_json_data').val(varieties_data);
}
function fillHandsontable() {
var data = [ [ "", "", ""] ];
var $container = $("#value_table");
$container.handsontable({
data : data,
});
};
fillHandsontable();
</script>
ManagedBean
private String json_data; //getters and setters
public void importData() {
System.out.println(this.json_data);
}
لا تنتمي إلى StackOverflow