0

In my project I have a dialog box where I have some checkboxes for items inside a datagrid and a command button which will add that into a list.

And in the page I have some fields with JSF validation.

My present functionality is like, when user clicks a commandButton in the page that dialog box should appear. Where user will select some items through checkboxes and click the add button of dialog box. Then dialog box will be closed and that item will be added to the table in the page.

Now I want to add some more functionality like, whenever user will open that dialog box he should get those item selected always which he has added to the table. For this I am calling a method by ajax in command button, which opens the dialog box and will update all checkboxes.

Problem is due to validation on my page I am not able to pass validation. I also kept immediate="true" in command button. But in this case I am not able to get selected the checkboxes after updating it.

P.S. Value for checkboxes I am getting through a HashMap. I am using JSF and primefaces

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Kush Sahu
  • 399
  • 1
  • 13
  • 33

1 Answers1

1

Just put the dialog outside the form which you don't want to submit/validate at all and give it its own form.

<h:form>
    ... (button which opens dialog is in this form)
</h:form>

<p:dialog>
    <h:form>
        ... (yeah, dialog has its own form!)
    </h:form>
</p:dialog>

This way other forms won't be bothered when you submit the dialog's form. Don't forget to put the managed bean of the "parent" form in the view scope in order to maintain state across postbacks on the same view.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • hi @BalusC thanks thanks for your ans. But in my project we have a template.xhtml. All of our pages be always inside that template. That template has the form. So everything will be inside that form. – Kush Sahu May 10 '13 at 06:26
  • Yesterday I found this question useful http://stackoverflow.com/questions/9291129/how-to-disable-jsf-valitadions-temporarily and for my problem also I made solution by disabling the validation by param. – Kush Sahu May 10 '13 at 06:29
  • Just fix that template so that you don't have the "God Form" bad practice anymore. – BalusC May 10 '13 at 11:30