JSF 2将值传递给Checkbox Click事件上的ManagedBean文件

时间:2017-03-08 07:46:11

标签: jsf-2 jsf-2.2 jsf-1.2 jfs

我有以下代码:

<h:form id="formId">
    <h:inputHidden id="x" value="#{userBean.x}" />
    <h:inputHidden id="y" value="#{userBean.y}" />
    <h:selectBooleanCheckbox event="click" listener="#{userBean.submit}" />
</h:form>
<script>
    function getVars() {
        var x = 10; 
        var y = 20;

        document.getElementById("formId:x").value = x;
        document.getElementById("formId:y").value = y;
    }
</script>

,ManagedBean代码如下:

public class UserBean {
    public int x;
    public int y;

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void submit() {
        System.out.println("x: " + x);
        System.out.println("y: " + y);
        // ...
    }

在复选框的点击事件中我想要x&amp;的值要传递给托管bean文件的y个变量。怎么做?

0 个答案:

没有答案