【发布时间】:2015-12-02 06:36:12
【问题描述】:
在这里,我从 Javascript 中的函数返回我的计数变量,如下所示:
<script type="text/javascript">
var count = 0;
function resetGroupsSelector(groupId){
//alert(groupId);
console.log("search_report_form:"+groupId)
//alert("search_report_form:"+groupId)
var id = "search_report_form:"+groupId;
//alert(count);
if(document.getElementById(id).checked)
{
count=count+1;
alert(count);
}
else
{
count=count-1;
alert(count);
}
return count;
}
</script>
现在,如何从我的 JSF 代码中获取计数值,以便使用 htm() 函数打印它?
final class GroupsSelector extends BaseRenderablePanel<GroupsSelector> {
private GroupsSelector group(LabourInputReportCriteria.Level level) {
HtmlSelectBooleanCheckbox box = new HtmlSelectBooleanCheckbox();
boolean isSelected = selections.isGroupSelected(level);
box.setSelected(isSelected);
// box.setDisabled(isDaySelectedOnFirst(level));
String id="groupBy" + level.getClass().getSimpleName();
box.setId(id);
box.setOnclick("resetGroupsSelector('"+id+"')");
box.addValueChangeListener(u.addExpressionValueChangeListener("#{reportSearchCriteriaModel.groupBy}"));
HtmlOutputText labelComponent = new HtmlOutputText();
labelComponent.setValue(getGroupSelectionValue(level));
tr().td();
html(box);
//html(" ");
html(labelComponent);
//html("<script> function resetGroupsSelector() { var x = document.getElementById('search_report_form:groupByWeekLevel'); alert(x); } </script>");
endTd().endTr();
return this;
}
请帮帮我。
谢谢, 斯鲁蒂斯
【问题讨论】:
标签: javascript jsf