Q:

commandLink with ajax doesnt work in JSF2

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

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>

A:

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?

