请教jsf二级联动的问题
网上介绍的两种做法 我都试了 虽然可以联动了 但是调用不了bean中的方法 这是为什么呀
如方法一:
<script>
function formSubmit(){
... ...
document.getElementById( "myForm:myButton ").click();
}
</script>
<f:view>
<h:form id= "myForm ">
<h:selectOneMenu id= "gradeId "
onchange= "formSubmit() "
value= "#{myBean.gradeId} "
required= "true ">
<f:selectItems value= "#{myBean.gradeList} " />
</h:selectOneMenu>
<h:selectOneMenu id= "classId " value= "#{myBean.classId} ">
<f:selectItems value= "#{myBean.classList} " />
</h:selectOneMenu>
<h:commandButton id= "myButton "
value= "Submit "
action= "#{myBean.update} "
style= "visibility:hidden; " />
</h:form>
</f:view>
myBean:
private String gradeId;
private String classId;
public void update() {
System.out.println( "********************************* ");
System.out.println( "gradeId: " + this.gradeId);
System.out.println( "classId: " + this.classId);
}
用方法一去做 运行时 选择grade后 页面会刷新一次 又回到没选的状态 而且没有执行update方法 请问高手们 可能是什么原因呢
方法二
<h:selectOneMenu id= "gradeId "
value= "#{myBean.gradeId} "
onchange= "submit() "
required= "true "