BootsFacesJSF2.2需要根据cookie值从DB自动填充表单

BootsFacesJSF2.2需要根据cookie值从DB自动填充表单,jsf,bootsfaces,Jsf,Bootsfaces,我面临着JSF生命周期的问题。问题如下: 我有一个cookie,它从另一个页面被带到一个xhtml页面,准备如下: window.onload = function() { var cookieName = "uuid" var theCookie = " " + document.cookie; var ind = theCookie.indexOf(" " + cookieName + "="); if (ind == -1) ind = th

我面临着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并调用了另一个方法,然后用通过cookie注入的实际值填充uuid实例变量


任何帮助都将不胜感激

因为您已经在JSF2.2上了,所以它是不必要的,可以由替换。尝试将其替换为,您可能希望在服务器端检索cookie值-也许吧。谢谢@Tiny和BalusC。这两个想法都有效…你介意解释一下为什么有效和无效吗?