在JSF中有很多材料区分value属性和binding属性.
我对这两种方法如何彼此不同感兴趣.鉴于:
public class User {
private String name;
private UICommand link;
// Getters and setters omitted.
}
Run Code Online (Sandbox Code Playgroud)
<h:form>
<h:commandLink binding="#{user.link}" value="#{user.name}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)
value指定属性时会发生什么变化.getter运行以返回bean 的name属性值User.该值将打印到HTML输出.
但我无法理解它是如何binding运作的.生成的HTML如何维护与bean link属性的绑定User?
下面是手动美化和注释后生成的输出的相关部分(注意id j_id_jsp_1847466274_1是自动生成的,并且有两个隐藏的输入小部件).我正在使用Sun的JSF RI 1.2版.
<form action="/TestJSF/main.jsf" enctype="application/x-www-form-urlencoded"
id="j_id_jsp_1847466274_1" method="post" name="j_id_jsp_1847466274_1">
<input name="j_id_jsp_1847466274_1" type="hidden" value="j_id_jsp_1847466274_1">
<a href="#" onclick="...">Name</a>
<input autocomplete="off" id="javax.faces.ViewState" name="javax.faces.ViewState"
type="hidden" value="-908991273579182886:-7278326187282654551">
</form>
Run Code Online (Sandbox Code Playgroud)
在哪里binding存放在这里?
如何在我的HTML表单中启用提交按钮,如果未选中复选框则禁用?
这段代码有什么问题?
EnableSubmit = function(val)
{
var sbmt = document.getElementById("Accept");
if (val.checked == true)
{
sbmt.disabled = false;
}
else
{
sbmt.disabled = true;
}
}
Run Code Online (Sandbox Code Playgroud)
复选框
<td width="30%">Do you accept Terms of Service agreement?</td>
<td width="10px" style="min-width: 10px"></td>
<td width="70%">
<input type="checkbox" name="TOS" value="Accept" onClick="EnableSubmit"> I agree to Terms of Service agreement.
</td>
Run Code Online (Sandbox Code Playgroud)