0

I'm trying to use a code which looks like :

<ice:dataTable id="revisionDocuments" value="#{agendaBean.agenda.revisionsDocuments}" var="revision">
    <ice:column>
        <ice:inputText value="#{revision.sequenceAdresse}" id="revisionSequenceAdresse#{revision.index}" />
    </ice:column>

I'd like to have a different id for my form fields. The revision object do contains an "index" field, representing the index of the object in the List. I want to see it appears in the id. However, nothing happens. The #{revision.index} expression is never interpreted (getIndex() on the revision object is never called).

You'll tell me JSF already make something that looks like :

revisionDocuments:0:revisionSequenceAdresse
revisionDocuments:1:revisionSequenceAdresse
revisionDocuments:2:revisionSequenceAdresse

True, but this affect only the clientId generated in the HTML. The UIComponent representing the form fields (in the ViewRoot from FacesContext) have all the same "id" AND "clientId" (yes, event if the HTML contains "revisionDocuments:0:revisionSequenceAdresse", the "clientId" you will find in ViewRoot is revisionDocuments:revisionSequenceAdresse).

Someone can help with my try ?

Thank you very much, any help will be greatly appreciated.

Wis
  • 705
  • 1
  • 11
  • 34

1 Answers1

0

The component IDs are to be determined during view build time, not during view render time. The #{revision} is not available during view build time, so it always evaluates empty. Basically, you need to bind it to #{agendaBean} or something else which is already in the scope during the view build time. The component ID is specific to the component itself, not to its generated HTML output. You can't assign multiple different IDs to physically the one and same component.

But you actually don't need to fiddle around this approach. Your concrete problem for which you thought that this is the solution is already answered in your previous question: JSF2 + IceFaces 2 - Retrieve UIComponent from ViewRoot.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Little confusing as I did something really close to this code on another project on JSF1.2 and IceFaces 1.8.2. The case must be slighthly different (from a lifecycle perspective). I'll see if it works when I do migrate from 1.8.2 to 2.0.2 on this project. Thanks for the answer and precisions on lifecycle. You're helping much ! – Wis Dec 09 '11 at 14:36
  • It is possible if the value of the EL expression is available during view build time. Your concrete problem is that you're in the `id` attribute trying to evaluate an EL expression whose value is only available during view render time. Try something like `id="foo#{agendaBean.someId}"` and you'll see that it's correctly evaluated. But, with a big BUT, this will end up in all generated HTML elements having the same ID suffix value during view render time. – BalusC Dec 09 '11 at 14:40