I have a JSP 2.0 <ui:component>
, within that is a <p:dataTable>
with a column that uses a Composite to render a special border about some content. Now I need to identify the <p:dataTabe>
in a ajax rendered attribute that is located in the content.
<ui:component>
<p:dataTable id="dataTable" var="userItem" ... />
<p:column>
<my:borderBox id="borderBox">
<p:commandButton
action="#{userController.doDelete(userItem.id)}"
value="delete"
update="?????"/> <!-- How to address the dateTable? -->
</my:borderBox>
</p:column>
</p:dataTable>
<ui:component>
My BorderBox:
<html xmlns:composite="http://java.sun.com/jsf/composite" ...>
<composite:interface>
<composite:attribute name="styleClass" default="" type="java.lang.String"/>
</composite:interface>
<composite:implementation>
<h:panelGroup ...>
...
<composite:insertChildren/>
</h:panelGroup>
</composite:implementation>
My idea was to use something like
update=":#{component.namingContainer.parent.namingContainer.clientId}:dateTable
But component.namingContainer.parent
seams to be null.
When I replace the <p:commandButton>
with this statements:
Parent ClientId 1: #{component}
Parent ClientId 2: #{component.namingContainer}
Parent ClientId 3: #{component.namingContainer.clientId}
Parent ClientId 4: #{component.namingContainer.parent}
Parent ClientId 5: #{component.namingContainer.parent.namingContainer}
I get this output:
Parent ClientId 1: javax.faces.component.html.HtmlPanelGroup@3d957419
Parent ClientId 2: javax.faces.component.UINamingContainer@23db9e8f
Parent ClientId 3: main_form:profilTabView:dataTable:0:borderBox
Parent ClientId 4:
Parent ClientId 5:
I have no idea what the problem it: mybey my idea to identify the list is complete wrong or there some mistake or there is a better way? (But I can not use fix absolute identifyer for the dateTable!)
Versions: Primeface 3.2, Mojarra 2.1.6 on Glassfish 3.1.2
I have a workaround for this Problem. If you can not find another solution, you can use it as an alternative. The Solution is a mix between jsf and javascript. For your table you define a widget (e.g. "myTable").
<p:dataTable id="dataTable" var="userItem" ... widgetVar="myTable"/>
It is a global javascript variable named "myTable" is created. this widget object contains an id. For you command button (h:commandButton not p:commandButton) you define onklick event:
<h:commandButton id="deleteItem" action="#{userController.doDelete(userItem.id)}"
value="delete" onclick="PrimeFaces.ab({formId:$(this).closest('form').attr('id'),source:this.id,process:'@all',update:myTable.id});return false;" />
formId - you enter the form ID explicitly or use my Jquery function
update - myTable.id is a Table ID (exactly div wrapper)
process - @all, @this, @form etc..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With