简体   繁体   English

如何通过AJAX加载JSF 2.0复合组件

[英]How to load a JSF 2.0 composite component via AJAX

I have designed a composite component that looks something like this: 我设计了一个复合组件,看起来像这样:

 <cc:interface>
    <cc:attribute name="value" required="true" />
    <cc:attribute name="title" required="true" />
</cc:interface>

<!-- IMPLEMENTATION -->
<cc:implementation>
    <div class="inputTile">
        <div class="inputTitle">
            <span>#{cc.attrs.title}</span>
        </div>
        <div class="inputTileContent">
            <input type="text" value="#{cc.attrs.value}" />
        </div>

    </div>
</cc:implementation>

I am trying to load this onto a div on my web page through AJAX. 我正在尝试通过AJAX将其加载到网页上的div上。

Any ideas on how to do that? 关于如何做到这一点的任何想法?

Something like this maybe? 像这样的东西?

<h:panelGroup id="foo" layout="block">
    <your:composite rendered="#{bean.loadCompositeInDiv}" />
</h:panelGroup>

<h:commandButton value="Load composite in div" action="#{bean.setLoadCompositeInDiv(true)}">
    <f:ajax render="foo" />
</h:commandButton>

with

@ManagedBean
@ViewScoped 
public class Bean {

    private boolean loadCompositeInDiv;

    // Getter+setter
}

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

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