Search code examples
ajaxjsfhidden-fieldvaluechangelistener

Render a panelGroup after a valueChange of a hiddenInput


I want to render an <h:panelGroup> after a valueChange of a hidden input:

    <h:inputHidden id="code" valueChangeListener="bean.myFunc()" />
    ...
    <h:panelGroup id="block">...</h:panelGroup>

How can I do it? I can't add an <f:ajax> inside the <h:inputHidden> because it's a non-ClientBehaviorHolder parent.

Thanks!


Solution

  • You can add it to the list of components to render from the server side, inside myFunc() using the PartialViewContext

    FacesContext cxt = FacesContext.getInstance();
    PartialViewContext partialCtxt = ctxt.getPartialViewContext();
    partialCtxt.getRenderIds.add("block"); //adds the block to the list of items to be ajax-rendered