简体   繁体   中英

jsf ajax must be in the same form?

The jsf page below produces the error as follows. Does that mean that the ajax tag must be in the same form as the render target? Is there anyway to workaround this limitation?

SEVERE: Error Rendering View[/ajax.xhtml]
javax.faces.FacesException: contains an unknown id 'sum' - cannot locate it in the context of the component 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

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

See this blog post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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