如何在javascript中设置和获取Java bean静态变量

时间:2016-09-20 10:33:16

标签: javascript java jsf

在我的jsf页面中,我使用导航选项,使用HTML,CSS和Javascript。 它工作正常,但问题是我想在我的openNev()方法上使用并设置java静态变量值。我的java静态变量'nevOpenState'是我的类SelectedVehicleBean变量:

以下是我的用于打开和关闭导航的javascript函数:

function openNav(){

            if(#{selectedVehicleBean.nevOpenState == true})
                document.getElementById("mySidenav").style.width = "250px";
                document.getElementById("main").style.marginLeft = "250px";

                if (#{selectedVehicleBean.viewId eq '/jsf/mainTracking.xhtml'}) {
                    document.getElementById("gmapPanel").style.marginLeft = "250px";
                    document.getElementById("test2").style.marginLeft = "250px";

                } else {
                    document.getElementById("movementTabview").style.marginLeft = "250px";
                    document.getElementById("searchForm").style.marginLeft = "250px";
                }
            }

        function closeNav() {
            document.getElementById("mySidenav").style.width = "0";
            document.getElementById("main").style.marginLeft = "0";

            if (#{selectedVehicleBean.viewId eq '/jsf/mainTracking.xhtml'}) {
                document.getElementById("gmapPanel").style.marginLeft = "0";
                document.getElementById("test2").style.marginLeft = "0";

            } else {
                document.getElementById("movementTabview").style.marginLeft = "0";
                document.getElementById("searchForm").style.marginLeft = "0";
            }

        }

我成功获得#{selectedVehicleBean.nevOpenState == true}但是如何在导航关闭时在selectedVehicleBean.nevOpenState中设置false值?

0 个答案:

没有答案