5

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

Ralph
  • 118,862
  • 56
  • 287
  • 383
  • 1
    I unfortunately don't use `ui:component` tag so I don't know much about it; I typically use Composite Components which you can reference from an EL expression the parent naming container like `#{cc.parent.id}`. I think however that `parent` is a reserved variable in EL expression language so it should be as simple as `#{parent.id}` to retreive the parent naming container id. – maple_shaft Aug 23 '12 at 12:08
  • @maple_shaft: `` is implicitly used by composite components. It is therefore cleaner to declare it directly instead of ``. – BalusC Aug 23 '12 at 12:12
  • Which JSF impl/version and PF version exactly are you using? – BalusC Aug 23 '12 at 13:04
  • @BalusC: I use an unmodified Glassfish 3.1.2 (I can update to 3.1.2.2 if it is a bug) so it is Mojarra 2.1.6; Primeface is version 3.2. – Ralph Aug 23 '12 at 13:11
  • did you resolve this problem ? – JamesN May 28 '13 at 09:38
  • @JamesN: no - I quitted – Ralph May 28 '13 at 09:54

1 Answers1

1

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..

maciek
  • 416
  • 3
  • 5