简体   繁体   English

每个ajax请求上的JSF更新组件

[英]JSF update component on every ajax request

Hi i want to render the JSF messages as bootstrap alerts 您好我想将JSF消息呈现为引导警报

<ui:repeat value="#{facesContext.messageList}" var="facesMessage">
    <div class="alert">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <strong>Warning!</strong> #{facesMessage.summary}
    </div>
</ui:repeat>

in primefaces there is 在素面中有

<p:messages autoUpdate=true>

means it is rerendered on every ajax request without explicit adding it to the render-attribute of a commandLink 意味着它会在每个ajax请求上重新呈现,而不会将其显式添加到commandLink的render-attribute中

is there a way to achieve this with plain JSF-ajax tags? 有没有办法用普通的JSF-ajax标签来实现这个目的?

You might try something like this during your page load: 您可以在页面加载期间尝试这样的事情:

jsf.ajax.addOnEvent(autoRender);

And in autoRender you would be able to trigger a kind of action in order to render the target component. autoRender您可以触发一种操作以呈现目标组件。 For instance: 例如:

function autoRender() {
    $(":form:autoRenderHiddenButton").click();
}

And in the button: 在按钮中:

<h:commandButton id="autoRenderHiddenButton" 
                 style="display: none">

    <f:ajax render="theComponentIdYouWantToRender"/>
</h:commandButton>

Or you can easily achieve the same behavior by using Omniface's commandScript : 或者您可以使用Omniface的commandScript轻松实现相同的行为:

<o:commandScript name="autoRender" render="theComponentIdYouWantToRender"/>

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

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