0

I have this piece of code:

<composite:interface componentType="nestedGridCellEditor">
<composite:attribute name="componentName" required="false" shortDescription="Name of the attribute to display in the id"/>
<composite:attribute name="action" required="false" targets="#{cc.attrs.componentName}button" shortDescription="A method expression or a string outcome to process when command is executed"/>
</composite:interface>


<composite:implementation>
<span id="#{cc.clientId}" style="display: flex;">
        <p:commandButton id="#{cc.attrs.componentName}button"/>
</composite:implementation>
</span>

And I use it that way (I'm using it several of times, with a different componentName):

    <sm:nestedGridCellEditor id="DateNGCE" componentName="Foo2101" 
      action="#{contractTermsBudgetController.updateRow('Date', budget)}"/>

What I want it to do is to use componentName inside the id of the component, and to put it inside the targets as well.

Right now it giving me an error about the targets and about the action method.

(i.e - "Unable to re-target MethodExpression as inner component referenced by target id 'button' cannot be found")

How can I do this?


EDIT

The purpose of this is because I'm using this composite inside several tables and I want to identify each button by its table's ID which should include the table name and not the clientId. That's why I need to pass the name through the componentName.

Dvir
  • 301
  • 1
  • 2
  • 16
  • _"What I want it to do is to use componentName inside the id of the component,"_ Why? a composite is already a naming container, so if you use an ID instead of componentName this will be included already in the full clientID. And also read https://stackoverflow.com/questions/15660969/set-id-of-a-component-within-jsf-datatable-to-value-from-current-item-in-the-arr so it won't work anyway I think to set the id this way – Kukeltje Jan 21 '18 at 08:27
  • @Kukeltje Thanks! please see my edit above. – Dvir Jan 21 '18 at 12:16
  • Several things: A composite always is a naming container, so is the datatable, see https://stackoverflow.com/questions/13543510/naming-container-in-jsf2-primefaces. So if you use it inside a datatable, the client-side id always contains the (client)id of the datatable, an index, the id of the composite and its own id. So no need to explicitly add it. Secondly, it is not good practice to need to address/target individual components in a composite See https://stackoverflow.com/questions/6822000/when-to-use-uiinclude-tag-files-composite-components-and-or-custom-componen/6822269#6822269 – Kukeltje Jan 21 '18 at 13:47

0 Answers0