I have a checkbox that triggers a javascript function which shows/hides another component.

The problem is if I hit submit, but there is a required field missing the submit rerenders the page but doesnt retrigger the javascipt shows/hides. So some of the checkboxes that would show a different component will still be checked but the hidden component will still be hidden.

Is there a way to avoid re-rendering on submit, without using immediate=true because I still need validation?

1 Answer 1


Rather than looking for a way to change the way submit behaves you can address this in your JavaScript.

The basic idea is that as well as writing code that responds to events (such as checkbox changes) you also need to write code that is run when the page loads that applies the current state of the input fields (such as the checkbox) to the page. As well as addressing the submit problem, in the general case this allows the page to be used as an edit page and display correctly.

(I think you are talking about the whole page re-rendering; if you are using partial page rendering via reRender attributes, then there is also an oncomplete attribute that lets you run JavaScript to get the re-rendered part of the page directly displayed.)

  • Yah thats what I was thinking and looks like what Im going to have to do. I was just hoping there was a simpler solution because this will make the script much more complicated taking into account how many things render others. And since this code isnt for my eyes only and the rerendering isnt even a requirement I may just scrap it. Jul 30, 2014 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .