简体   繁体   English

jsf ajax必须采用相同的形式吗?

[英]jsf ajax must be in the same form?

The jsf page below produces the error as follows. 下面的jsf页面产生如下错误。 Does that mean that the ajax tag must be in the same form as the render target? 这是否意味着ajax标记必须与渲染目标具有相同的形式? Is there anyway to workaround this limitation? 反正有解决此限制的方法吗?

SEVERE: Error Rendering View[/ajax.xhtml] 严重:错误呈现视图[/ajax.xhtml]
javax.faces.FacesException: contains an unknown id 'sum' - cannot locate it in the context of the component x javax.faces.FacesException:包含一个未知的ID'sum'-无法在组件x的上下文中找到它

<h:body>
    <h:form>
        x: 
        <h:inputText id="x" value="#{ajax.x}">
            <f:ajax event="keyup" render="sum mul"/>
        </h:inputText>
        <br/>
        y:
        <h:inputText id="y" value="#{ajax.y}">
            <f:ajax event="keyup" render="sum mul"/>
        </h:inputText>
        <br/>
    </h:form>
    Sum: <h:outputText id="sum" value="#{ajax.sum}"/><br/>
    Multiply: <h:outputText id="mul" value="#{ajax.multiply}"/><br/>
</h:body>

Just prefix the id with a colon 只需在ID前面加上冒号即可

eg. 例如。 <f:ajax event="keyup" render=":sum :mul"/>

See this blog post 看到这篇博客文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM