Duplicate Id across my Views? How come?

1 resposta
M

Pessoal, estou disponibilizando aqui a minha dúvida que postei há pouco em um fórum em Inglês. Podem responder em Português…


Hello folks!

I’d like you please to look at the attachment, an image that displays the Search Results tab of the Netbeans IDE, informing all occurrences of the Id “pnlAgendaUsuario”.

I’m getting the error message

java.lang.IllegalStateException: duplicate Id for a component pnlAgendaUsuario

from my View, but there’s something that makes no sense at all to me:

As the attached picture displays, the Id “pnlAgendaUsuario” is declared only once in the whole project. If that’s the case, how can I receive an error message informing that such an Id is duplicated???

All the other references to “pnlAgendaUsuario” are just requests for its use, not declarations.

Has anyone ever undergone the same experience or have something in mind to suggest?

Thanks in advance!


Agradecido!


1 Resposta

M

Com a ajuda do fórum em Inglês, mas o desenvolvedor sênior que trabalha comigo, conseguimos resolver o problema, e coloco aqui a descrição para que possivelmente outros possam consultar:


[i]I’ve talked to a senior co-worker and the explained something that definitely solved the problem. As you said, it had to do with it, though not declaring the Id more than once, the same was being used twice in my environment.

Through the use of Facelets, our pages are a composite of minor ones through the use of tags include (ui:include). One of my Views were being included twice, once globally, viewable by all Views, and again, within a particular View. By removing the latter, the system worked smoothly.

In the end, it had no apparent direct relation with that Id “pnlAgendaUsuario”, though that could be implied and not immediately noticeable.

In sum, if any of you run against a similar problem, check to see if there are multiple references to the same Views through the tag include (ui:include). This a possible solution!

Another possible solution would be isolating Ids within (a4j:form) tags, so that their names are transformed into a composite of the type “formName:Id” instead of “Id” only, defining a kind of namespace for the Ids. Without it, at run-rime only, it could be possible that the same “Id” could be called more than once when assembling the page, then the duplication happens, what would not happen by defining composite names by placing those Ids within form tags.

That’s all from me, thanks!!![/i][i]


É isso aí pessoal, aquele abraço!

Criado 31 de outubro de 2011
Ultima resposta 31 de out. de 2011
Respostas 1
Participantes 1