0

DropDown Box code:

<p:selectOneMenu id="user" value="#{daywise_Count.selectuserId}" style="width:120px">
    <f:selectItem itemLabel="All" itemValue="0" />
    <f:selectItems value="#{daywise_Count.getAllLoginIds()}"                                            var="uif" itemLabel="#{uif.loginId}" itemValue="#{uif.userId} " />
</p:selectOneMenu>

CheckBox code:

<p:selectBooleanCheckbox  id="checkbox" value="#{deptBean.checkboxvalue}" /> With All Details

reset function:

function resetter()
{
    document.getElementById('myForm:myMenu_label').innerHTML = 'All';

}

Calling Reset Function

    <h:commandButton id="btnReset" value="Reset" update="myForm" onclick="resetter();" 
styleClass="button" type="submit"> 
</h:commandButton> 

I am using reset button in myForm that functionality is not working properly in primefaces.please suggest any solution...

  • what does 'not working' mean? Crash? Errors? WW3? – Kukeltje Dec 08 '15 at 08:40
  • after clicked reset button same value showing in dropdown and checkbox ... –  Dec 08 '15 at 08:51
  • Are you sure you are calling the right Dom functions/setters? Is `.innerHTML` correct in resetting the checkbox? I'm almost sure in SO there are questions on setting the value of a checkbox from javascript. Check that. Same for the selectOneMenu – Kukeltje Dec 08 '15 at 08:55
  • Please use the preview functionality... And check it... Code you added is not visible... and you can remove the comments above with the code... – Kukeltje Dec 08 '15 at 09:23
  • The `h:commandButton` has some peculiarities. The `update="myForm"` attribute is from a `p:commandButton` when ajax is used and does not do anything on an `h:commandButton`. The `type="submit"` is very rarely used in JSF (can't remember ever using it myself ). So maybe you wanted to use a `p:commandButton`? But still then, this is only client-side so maybe you should read http://stackoverflow.com/questions/19737674. And can't you reset everything in a different way? – Kukeltje Dec 08 '15 at 09:47
  • And please debug what actually happens... server roundtrip wise... I think you will learn a lot – Kukeltje Dec 08 '15 at 09:55
  • 1
    you should try this , In update you need to provide your panel id and no need to java script. hope, it will work – Piyush Gupta Dec 08 '15 at 09:56
  • If i am using first time only data refreshed and next time not working... –  Dec 08 '15 at 11:40

1 Answers1

1

you should try this <p:commandButton id="btnReset" value="Reset" update="myForm" process="@this" /> this is working for me, I hope it will help you too. and no need to java script.

update="myForm" attribute means it will update your panel because here you will use panel id and process="@this" means it will execute same content after click on reset button for further details you can search on google or refer this link What is the function of @this exactly?

Community
  • 1
  • 1
Piyush Gupta
  • 2,181
  • 3
  • 13
  • 28