-
1. Re: problem determine component id to attach effect to
massep Mar 11, 2008 2:37 PM (in response to alllle)"alllle" wrote:
I noticed that the actual ID assigned to a component usually is not the same as what I specified. For example, if I have a form with id "form1" and a component inside the form with id "field1", the final id for the component is automatically changed to "form1:field1". Why does it behave this way?
The problem is, sometimes, the prefix is not as predictable as above example. I have a field that got a id like "j_id39:j_id40:0:field1" and I have no idea where the j_id40 part comes from. Therefore, I can't predict its final id value and can't refer to it reliably in order to apply effect.
That's the way JSF works. If you do not put an id on a control yourself, JSF will. If you have a control in a control, like a field on a form, JSF will id the field as "form:field". As for finding out what the final id is, looks like richFaces will figure it out by itself.
Just use "field1" and richFaces will add "j_id39:j_id40:0:" automatically.
I never tried this in a dataTable but, I know that's what happens with a straight field on a page.
Hope this help.
P.S.: Look at your html source. It will help you figure out what richFaces generates for you. -
2. Re: problem determine component id to attach effect to
alllle Mar 11, 2008 2:57 PM (in response to alllle)Thank you for the explanation. It seems that even if I don't need to worry about the dynamic prefix part of the ID, I am still facing a very specific problem:
I am using a facelet <ui:repeat varStatus="varStatus" ...> tag to iterate through several items. For each item I create a <rich:panel id=...> to display the item properties. I then need to refer to one of the items to display a richfaces effect, such like a highlight.
The problem is that since it is in a loop, I can't get the ID of the <rich:panel> to be dynamic. I used id="item_#{varStatus.index}", I also tried id="item_#{item。id}", both of them end up showing as "item_". In other words, I can't seem to be able to mix in a dynamic index or id into the "id" attribute of the <rich:panel>.
Because of this problem, I can refer to the control to display the effect.
Do you have any idea how to solve this?
Thanks for the help! -
3. Re: problem determine component id to attach effect to
massep Mar 12, 2008 1:19 PM (in response to alllle)Hmmmm...
We do not use Facelets. Would Facelets's "jsfc" feature help?
Would this work :
<ui:repeat varStatus="varStatus" jsfc="h:panelGrid">
Cheers -
4. Re: problem determine component id to attach effect to
alllle Mar 12, 2008 7:55 PM (in response to alllle)That wouldn't apply to this case.
However, I did discover that, it is not the Facelet causing the problem. It's the <rich:panel> tag not resolving the variables properly. I add a regular block in the Facelet <ui:repeat> and it was getting the dynamic ID properly, while the <rich:panel> in the same loop does not resolving the dynamic ID.
It seem like a bug in the RichFaces library. I'll do a search in the bug db and probably file a new bug report.
Another thing I discovered is that although the "varStatus" is a valid tag attribute of the Facelet <ui:repeat> tag, it is not implemented in the code and there is feature request already created for it.
Thanks for the help!