[CODE] finding component ids easier
Posted: 06 Sep 2012, 20:55
I'm considering ideas to make finding component ids easier. The switch from other component libraries to primefaces has caused a lot of pain due to the additional naming containers for tabView, accordionPanel, dataTable, dataGrid, dataList, subTable, etc. When we couple this with replacing a4j:regions by specific component is naming in process & update, we have a lot of issues with determining names. Using absolute names problematic due to our templating and includes, and even where we could do that, it makes page changes harder.
As a workaround up to this point, I have stored a component whose id I know I will need later using ui:param, but this has scaling issues since we now have the possibility of reusing the same name. And it forces us to take an extra step any time we use a component reference somewhere. A similar workaround might be to use css classes and jquery -style selectors, with the same disadvantages.
Ideally, the problem would be solved by supporting relative path constructs, such as update="..:someOtherNamingContainerAtSameLevelAsMyMaingContainer:someComponentId" supported by UIComponent.findComponent() itself, but that's not likely to happen any time soon.
So I've been considering EL functions to aid with this, like myFunction:findComponent('someComponentId'). At this point, we either define a specific search pattern that is more flexible than the standard findComponent, such as "search at my current level, then search at my parent level, then search my parent's parent level, etc, eventually returning the original value if nothing is found", or implement something that understands a relative path construct. The second seems more useful.
Thoughts?
As a workaround up to this point, I have stored a component whose id I know I will need later using ui:param, but this has scaling issues since we now have the possibility of reusing the same name. And it forces us to take an extra step any time we use a component reference somewhere. A similar workaround might be to use css classes and jquery -style selectors, with the same disadvantages.
Code: Select all
<some:component id="someComponentId"/>
<ui:param name="storedSomeComponentId" value=":#{p:component('someComponentId')}"/>
[... Somewhere else, possibly in a p:dataTable]
<p:ajax update="#{storedSomeComponentId}"/>
So I've been considering EL functions to aid with this, like myFunction:findComponent('someComponentId'). At this point, we either define a specific search pattern that is more flexible than the standard findComponent, such as "search at my current level, then search at my parent level, then search my parent's parent level, etc, eventually returning the original value if nothing is found", or implement something that understands a relative path construct. The second seems more useful.
Thoughts?