JSF 2.0:には未知のIDが含まれています
問題
AjaxをサポートするJSFのボタン…
<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>
このページが表示されると、次のエラーメッセージが表示されます
javax.faces.FacesException: <f:ajax> contains an unknown id 'output'
- cannot locate it in the context of the component j__idt8
明らかに、 ‘
output
‘のidは見つかりませんが、
<h:outputText id = “output”/>
で明示的に宣言されていますか?
解決策
JSF 2.0では、
<f:ajax>
タグは同じフォーム・レベル内で “レンダリング”出力を必要としました。
<h:outputText id = “output”/>
タグは、フォーム内を移動する必要があります。
<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>