如何在javascript中检索复合组件中的元素?

时间:2012-06-12 14:22:00

标签: jsf composite-component

我希望能够在javascript中访问复合组件中的元素。由于页面上可能有此组件的多个实例。如何访问该组件的特定实例中的某些特定元素?

<ui:component
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:cc="http://java.sun.com/jsf/composite"
    xmlns:p="http://primefaces.org/ui">

    <cc:implementation> 
        <script type='text/javascript'>
            function getAddedTagsInputField(){
                return ...;
            }             
        </script>        
        ...
        ...        
        ...
        <h:inputHidden id="tagsToAdd_in" /> 
    </cc:implementation>

</ui:component>

1 个答案:

答案 0 :(得分:1)

让JSF动态打印元素的客户端ID。您可以使用#{cc.clientId}获取组合本身的客户端ID,然后将JSF组件的ID附加到其中。

var hiddenElement = document.getElementById("#{cc.clientId}:tagsToAdd_in");
相关问题