1

I have problem with f:ajax tag. I want to show and hide some data after click on commandLink but i get error:

error from browser

My code:

<h:form prependId="false" id="contactDataForm">
    <h:commandLink value="Edit" action="#{cc.attrs.userBB.showHideEditForm()}">
        <f:ajax render="editableContactData notEditableContactData"/>
    </h:commandLink>
    <h:panelGroup id="notEditableContactData" rendered="#{cc.attrs.userBB.show == false}">
        test1
    </h:panelGroup>
        test2
    </h:panelGroup>
</h:form>
Tomasz Gutkowski
  • 1,388
  • 4
  • 20
  • 28
  • Related: http://stackoverflow.com/questions/9010734/why-do-i-need-to-nest-a-component-with-rendered-some-in-another-component-w – BalusC Sep 12 '12 at 12:12

1 Answers1

2

I think the errors that you are getting is cause you are trying to refer to elements that are not rendered from your f:ajax , instead : refer to the wrappers of h:panelGroup that may or may not be rendered

Wrap the notEditableContactData , so basically :

try to change

<h:panelGroup id="notEditableContactData" rendered="#{cc.attrs.userBB.show == false}">
    test1
</h:panelGroup>

into

<h:panelGroup id="notEditableContactData" rendered="#{cc.attrs.userBB.show == false}">
   <h:panelGroup rendered="#{cc.attrs.userBB.show == false}">
        test1
    </h:panelGroup>
</h:panelGroup>

do the same for the other h:panelGroup too

take a look at this answer of mine Can you update an h:outputLabel from a p:ajax listener?

Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200