我正面临着JSF生命周期的问题。问题如下:
我有一个cookie从另一个传递到xhtml页面并准备就绪:
window.onload = function() {
var cookieName = "uuid"
var theCookie = " " + document.cookie;
var ind = theCookie.indexOf(" " + cookieName + "=");
if (ind == -1)
ind = theCookie.indexOf(";" + cookieName + "=");
if (ind == -1 || cookieName == "")
return "";
var ind1 = theCookie.indexOf(";", ind + 1);
if (ind1 == -1)
ind1 = theCookie.length;
var x = unescape(theCookie.substring(ind + cookieName.length + 2, ind1));
alert("Got Cookie: " + x);
document.getElementById('amodalform:amodaluuid').value = x;
document.getElementById('cmodalform:cmodalIT').value = x;
document.getElementById('amodalformstatus:cmodaluuidstatus').value = x;
document.getElementById('hidden:link').onclick();
};
这个cookie" uuid"然后使用以下值来查询数据库:
<f:event listener="#{portalAdminManagedBean.isConfigureAdmin}"
type="preRenderView" />
我也试过
<h:form id="hidden" style="display:none">
<h:commandLink id="link">
<f:ajax event="click" listener="#{portalAdminManagedBean.onload}" />
</h:commandLink>
</h:form>
但是实例变量的值限制在输入文本区域:
<h:form id="amodalformstatus">
<b:inputText id="amodaluuid"
value="#{portalAdminManagedBean.uuid}">
</h:form>
但是,portalAdminManagedBean的isConfigureAdmin和onload方法都将uuid的值变为null。
为了测试uuid边界是否正确,我添加了一个commandButton并调用了另一个方法,然后uuid实例变量填充了通过cookie注入的实际值。
非常感谢你的帮助!!