2013-05-03 89 views
-1

Iam嘗試通過我的JSF facelet從託管bean檢索屬性值如下所示的Javascript調用,但我沒有從託管bean中獲取值。無法通過JavaScript調用檢索托管bean屬性

我的託管bean也已設置爲getPreviewScreen = false,並且也有getter和setter。 有人可以幫忙嗎?

這兩個警報不給我在下面的代碼中的值。

<script type="text/javascript"> 
function #{facesContext.externalContext.response.namespace}verifyStatus(data){ 
    alert("#{contactBean.isPreviewScreen}"); 
    if (data.isPreviewScreen){ 
    alert(data.isPreviewScreen); 
    $("##{facesContext.externalContext.response.namespace}previewScreenHeaderAlert").dialog(); 
    }else{ 
    $("##{facesContext.externalContext.response.namespace}previewScreenHeaderArea").show(); 
    } 
}; 
</script> 

這裏是我的內部形狀內容:

<h:commandLink action="#{contactBean.loadPreviewScreenContents}"> 
           <h:outputText title="#{crs.dateTime}" value="#{crs.dateTime}"> 
            <f:convertDateTime pattern="MM/dd/yyyy hh:mm a" type="date" /> 

           </h:outputText> 
           <f:setPropertyActionListener target="#{contactBean.crs}" value="#{crs}" /> 
           <f:ajax render=":form1:previewScreenHeader" onevent="#{facesContext.externalContext.response.namespace}verifyStatus"/> 

          </h:commandLink> 

回答

1

更改data.isPreviewScreen#{data.isPreviewScreen}這樣的:

<script type="text/javascript"> 
function #{facesContext.externalContext.response.namespace}verifyStatus(data){ 
    alert("#{contactBean.isPreviewScreen}"); 
    if (#{data.isPreviewScreen}){ 
    alert(#{data.isPreviewScreen}); 
    $("##{facesContext.externalContext.response.namespace}previewScreenHeaderAlert").dialog(); 
    }else{ 
    $("##{facesContext.externalContext.response.namespace}previewScreenHeaderArea").show(); 
    } 
}; 
</script> 
+0

nopes ..這是不正確...它偷竊裏面所有的jQuery fucntionalities ..我已經從豆檢索bean的屬性嘗試同樣的它的工作原理是: – SuperStar 2013-05-06 21:23:46

0

都能跟得上。這是不正確的......它撕掉了裏面的所有jQuery功能。我已經從豆檢索bean的屬性嘗試相同的,它的工作:

function #{facesContext.externalContext.response.namespace}verifyStatus(data){ 
    if ("#{contactBean.previewScreen}"==false){ 
    $("##{facesContext.externalContext.response.namespace}previewScreenHeaderAlert").dialog(); 
    }else{ 
$("##{facesContext.externalContext.response.namespace}previewScreenHeaderArea").show(); 
    } 
}; 
相關問題