Problem

A JSF’s button with Ajax support…

<h:outputText id="output" value="#{helloBean.sayWelcome}" />
<h:form>    	
   <h:inputText id="name" value="#{helloBean.name}"></h:inputText>
   <h:commandButton value="Welcome Me">
   	 <f:ajax execute="name" render="output" />
   </h:commandButton>
</h:form>

When this page is displayed, it prompts the following error message

javax.faces.FacesException: <f:ajax> contains an unknown id 'output'
                             - cannot locate it in the context of the component j_idt8

Obviously, the id of ‘output‘ is not found, but it’s explicitly declared in the <h:outputText id=”output” /> already?

Solution

In JSF 2.0, the <f:ajax> tag required the “render” output within the same form level. The <h:outputText id=”output” /> tag should move inside the form.

<h:form>    	
   <h:outputText id="output" value="#{helloBean.sayWelcome}" />
   <h:inputText id="name" value="#{helloBean.name}"></h:inputText>
   <h:commandButton value="Welcome Me">
   	 <f:ajax execute="name" render="output" />
   </h:commandButton>
</h:form>

Reference

  1. JSF 2.0 + Ajax hello world example
Note : You can find more similar articles at - JSF 2 Tutorials