2
 <h:panelGroup id="userPanel"><f:subview rendered="#{searchView.isUser}">
    <h:commandButton value="test" action="#{searchAction.doFindUsers}"   >
        <f:ajax execute="@this" event="action" render="userPanel" />
    </h:commandButton> </f:subview></h:panelGroup>

I am getting the error as: cannot locate it in the context of the component j_idt26

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
CSK
  • 83
  • 1
  • 9

1 Answers1

5

Because the <f:subview> is a NamingContainer.

See also:


Just use <h:panelGroup>,

<h:panelGroup id="userPanel">
    <h:panelGroup rendered="#{searchView.isUser}">
        <h:commandButton value="test" action="#{searchAction.doFindUsers}">
            <f:ajax execute="@this" event="action" render="userPanel" />
        </h:commandButton>
    </h:panelGroup>
</h:panelGroup>

or <ui:fragment> (which has only a little less overhead)

<h:panelGroup id="userPanel">
    <ui:fragment rendered="#{searchView.isUser}">
        <h:commandButton value="test" action="#{searchAction.doFindUsers}">
            <f:ajax execute="@this" event="action" render="userPanel" />
        </h:commandButton>
    </ui:fragment>
</h:panelGroup>

or in this specific example just directly on command button (surely your case is more complex than that)

<h:panelGroup id="userPanel">
    <h:commandButton value="test" action="#{searchAction.doFindUsers}"  rendered="#{searchView.isUser}">
        <f:ajax execute="@this" event="action" render="userPanel" />
    </h:commandButton>
</h:panelGroup>

See also:

Community
  • 1
  • 1
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452