1

I'm using Richfaces 4.3.3.

I'm having a composite widget. I pass a parameter/attribute, which is prints correctly within that widget. If I want to add this variable (integer) to a <rich:popupPanel>, the value resolves to 0 (default value for integers).

<rich:popupPanel id="popupEditor_#{cc.attrs.pubId}">
    #{cc.attrs.pubId}
</rich:popupPanel>

Intresting enough, the value within the tag, resolves correct. Is that a phase listener issue? If yes, how do I overcome this problem - stil using rich faces components?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
feder
  • 1,775
  • 5
  • 25
  • 36
  • Have you tried putting it inside ``? (Or , something that is supposed to contain text) – Makhiel Aug 19 '13 at 16:00
  • In the future, before you make some strong statements pointing to a specific suspect based on hastily made observations ("this does not work in RichFaces components"), please exclude it first from being the cause by replacing `` by e.g. ``. The statement in your title is namely utterly wrong. – BalusC Aug 19 '13 at 16:09

1 Answers1

1

First of all, carefully read this: JSTL in JSF2 Facelets... makes sense?

Summarized, EL expressions in id attributes are evaluated during view build time. In your particular case, based on the symptoms, the #{cc.attrs.pubId} seems to be available during view render time only, for example because it's definied by var of an iterating JSF UI component, or because it's definied as a bean property which is set after view build time only, etc.

You need to head to a different solution. I can't tell that in detail as you didn't tell anything about the concrete functional requirement for which you thought that this would be the solution. But, to the point, you've 2 options:

  1. Make sure that any EL variables in id (and binding) attribute are available during view build time. For example, use <c:forEach> instead of <ui:repeat>.

  2. Put it on a plain HTML element. It's evaluated during view render time.

    <rich:popupPanel id="popupEditor">
        <div id="#{cc.attrs.pubId}">
            ...
        </div>
    </rich:popupPanel>
    

Or perhaps you don't need it at all and you simply overthought a solution without actually having a concrete problem. When your composites are designed properly, you should have no need for a dynamic ID inside the composite.

<rich:popupPanel id="popupEditor">
    ...
</rich:popupPanel>

JSF already takes care of it automatically as composite components inherently extend from NamingContainer. You just have to give the <my:composite> itself a fixed ID instead.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Once again, you are assuming right. This code snippet is from a composite, which is iterated by a ui:repeat. So, as you said, the ID is not available at view render time. Thanks for enlightening this situation. – feder Aug 19 '13 at 18:15