I'm refactoring an XPage which mimics the Notes Client discussion database. (Don't ask)
I've created a Managed Bean which loads all the navigation information into a tree, and created a set of nested repeat controls that access the managed bean.
I'm having issues with the collapse and expand functions. The original authors use Client Side JavaScript by accessing the panel containing the entries which are one level under. They did this by hardcoding everything. 1000 lines of XML, that was.
<xp:this.script><![CDATA[collapse("#{id:repeatcontrolpanel3}]}")]]></xp:this.script>
I'm trying to make this generic; I've set up a property NameNestedRepeatControl in the custom control which contains the name of the nested repeatcontrol which I want to collapse/expand, and I was hoping that this would work:
<xp:this.script><![CDATA[collapse("#{id:#{compositeData.NameNestedRepeatControl}}")]]></xp:this.script>
but I'm getting a
javax.faces.el.MethodNotFoundException: NameNestedRepeatControl: com.ibm.xsp.binding.PropertyMap.NameNestedRepeatControl()
error.
Is there a special syntax for this, i.e. get a string value from the custom control's properties, then let that string be evaluated with #{id:}, or is there an even more elegant method that I'm missing?
thanks for the help.
I finally solved this issue by constructing the necessary script outside. Here I have a Navigation Entry Custom Control which has two String properties of script_expand and script_collapse.
And the script function gets called from outside; I'm alleviating the problem of calculating the relevant ID by just doing it manually.
Not quite as elegant as I had hoped, but a lot better than the unfactored code.
It's Sven's answer Pass javascript code to Custom Control which really helped so this should really go to him!