0

How can I prevent a popupPanel from closing after I sumbit a form inside it?

My code for button:

<h:commandButton value="Search" action="#{facesBean.search()}" >
<f:ajax execute="@form" render="result" />
</h:commandButton>

My code for the panel to be rendered after submit:

<h:panelGroup id="result" rendered="#{facesBean.list != null}">
TEST TO RERENDER
</h:panelGroup>

They're in the same h:form.

Is there something wrong? I don't get any error when running it.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
nataliaoliveira
  • 73
  • 3
  • 15

1 Answers1

1

There are basically two ways:

  1. Just submit the form by ajax.
  2. If you can't submit by ajax for some reason, just reopen the popup panel on postback.
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I tried to do it by ajax. My action gets executed, but my table won't rerender. How can I reopen it automatically on postback? – nataliaoliveira Aug 08 '12 at 16:32
  • Just specify the table's ID in `render` attribute of ajax component. Opening on postback is to be done by specifying the `show` attribute of `` accordingly. – BalusC Aug 08 '12 at 16:34
  • I tried that way, but it didn't worked. Maybe I'm doing something wrong. – nataliaoliveira Aug 08 '12 at 16:39
  • I edited my main post with the code for my button and my panel to rerender. – nataliaoliveira Aug 08 '12 at 16:44
  • Strangely it works if I take "rendered="#{facesBean.list != null}" out. – nataliaoliveira Aug 08 '12 at 16:56
  • This is not strange. If a JSF component is not rendered, then JavaScript/Ajax can't find anything in the HTML DOM tree to update. See also http://stackoverflow.com/questions/9010734/why-do-i-need-to-nest-a-component-with-rendered-some-in-another-component-w/9010771#9010771 Perhaps you're confusing JSF's `rendered` attribute with CSS' `display` attribute. – BalusC Aug 08 '12 at 16:58