reset

on page load

前端 未结 2 1192
清歌不尽
清歌不尽 2021-01-29 04:04

How to reset on page load? Using JSF or onClick event of a CommandButton

Please post here an example either in Javascript or Ajax

Please some one help me for th

相关标签:
2条回答
  • 2021-01-29 04:47

    You can clear the value of the checkbox in the constructor.

    This is how your checkbox might look:

        <p:selectBooleanCheckbox value="#{BeanClass.value1}" > </p:selectBooleanCheckbox>
    

    When the checkbox is checked, value1 becomes true. In the constructor of the bean class, you make value1 false.

    You bean class:

        Class BeanClass
        {
    
            private boolean value1;
            public BeanClass()
            {
                value1 = false;
                //Someother statements might follow.
            }
    
            public boolean getValue1()
            {
                return value1;
            }
    
            public void setValue1(boolean value1)
            {
                this.value1 = value1;
            }
        }
    

    Notice that I have set the value of value1 to false in the constructor, which gets called on page load, thereby rendering false in the primeface tag. Hope this helps.

    0 讨论(0)
  • 2021-01-29 04:49

    If I understood what you want to achieve then it's pretty much simple...

    first set dialog ID

     <p:dialog id="assignPermissionDlgId" widgetVar="assignPermissionDlg" width="75%">
    

    then alter your button to this

    <p:commandButton value="Assign Permission" update=":assignPermissionDlgId"
        oncomplete="assignPermissionDlg.show()"></p:commandButton>
    

    I think that each time you are opening the dialog you are seeing the previous checkboxes selected, in this way you update the dialog before you show it, the update cause the re-rendering.

    But I can't see where you are saving the checkboxes values ! Note: If you have values in checkboxes the answer would be different.....

    0 讨论(0)
提交回复
热议问题