使用bean from Java脚本中设置的枚举值
我想从使用bean from Java脚本中设置的枚举值,java,javascript,jsf,enums,Java,Javascript,Jsf,Enums,我想从JSF中的java脚本中检查托管bean中的enum值集。我该怎么做 我的JSF有如下内容 <script language="javascript"> function displayMsg() { setwindowOverlayPos('popup_window', - 100, - 150); } window.onload = function () { // this is the enum
JSF
中的java脚本中检查托管bean中的enum
值集。我该怎么做
我的JSF有如下内容
<script language="javascript">
function displayMsg() {
setwindowOverlayPos('popup_window', - 100, - 150);
}
window.onload = function () {
// this is the enum value I want to check. if the value is cust1 , I call the popup window.
var cust1= '#{myBean.customerType.custType == "cust1"}';
if(cust1){
displayMsg();
}
}
</script>
}
还有我的豆子
@ManagedBean(name = "home")
@ViewScoped
public class HomeBean extends BaseOrderStepBean {
private CustomerTypeEnum customerType;
public void method1(){
customerType = CustomerTypeEnum.CUST1;
}
}
我写这篇文章是为了造福他人。我把这个修好了。只需对javascript进行如下更改
var od = '#{MyBean.customerType.custType == "OD"}';
var alreadyHasIC = '#{sessionBean.icNumber}'
if ("true" == od) {
if(!alreadyHasIC){
displayMyForm();
}
}
这意味着你可以像这样从Java脚本访问Bean的枚举。你的帖子不够清晰!
var od = '#{MyBean.customerType.custType == "OD"}';
var alreadyHasIC = '#{sessionBean.icNumber}'
if ("true" == od) {
if(!alreadyHasIC){
displayMyForm();
}
}