i have problem to use widgetVar while its name is generated dynamicly. How properly we can call such widget ? Code of component:
<cc:attribute name="id" required="true" type="java.lang.String" />
...
<cc:implementation>
<p:selectOneRadio widgetVar="widgetVariable#{cc.attrs.id}" id="#{cc.attrs.id}" required="false" immediate="#{cc.attrs.immediate}"
value="#{cc.attrs.value}">
<p:ajax event="click" oncomplete="checkRadio()"/>
<cc:insertChildren/>
</p:selectOneRadio>
<script type="text/javascript">
/* <![CDATA[ */
function checkRadio() {
var widgetVariable = widgetVariable#{cc.attrs.id}; //HERE PROBLEM
widgetVariable.dosmth();
}
/* ]]> */
</script>
</cc:implementation>
thats what is wird that it works, but when i uses many istance of this component on page widgetwar sometimes get crazy and make javascript for many istance of component.
Edit: everything works fine. Anyway i have one new problem. I created in this .js file some global state variable.
var state = -1;
function checkRadio() {
var widgetVariable = widgetVariable#{cc.attrs.id}; //HERE PROBLEM
widgetVariable.dosmth(state);
}
But each state should be only for one composite istance, atm every composite use this var, some ideas?