0

I've got dynamic columns. Some have Inputfields others don't. Why do I have to set the Id of an Inputfield if I don't want to render it?

<rich:columns value="#{columnBean.columns}" var="column" index="ind" id="#{column.id}">                     
            <f:facet name="header">
                <h:inputText  id="#{column.inputFilterId}" value="#{otherBean.filterValue[column.filterBy]}" onkeyup="filterKeyUp(event)" onclick="Event.stop(event);" />
            </f:facet>
            <h:outputText value="#{columnBean.lineItemHandler[line]}" rendered="#{columnBean.curCol[column.id]}"/>
</rich:columns>

I'm using JSF 1.2 and Richfaces 3.3.3 Final

MadMax
  • 68
  • 6
  • Why don't you just use a fixed value as usual? – BalusC Jul 30 '15 at 13:06
  • I've got a Datatable and I want to give my users the option to change column order. I don't understand why I need an ID in the Textfiled which is not rendered. Does the interpreter need this for finding the right element which is then not rendered in HTML? – MadMax Jul 30 '15 at 13:13
  • It isn't needed for HTML DOM tree. It's needed for JSF component tree. Right now it will evaluate to null which is indeed invalid. Again, why don't you just use a fixed value as usual? Perhaps food for read: http://stackoverflow.com/questions/18358604/how-to-use-el-with-uirepeat-var-in-id-attribute-of-a-jsf-component – BalusC Jul 30 '15 at 13:18
  • Ah ok, you mean I can use a fixed id, which is unique for each column? I think I've to try this. – MadMax Jul 30 '15 at 13:37
  • Hm? There's only one component. Just set a fixed ID as usual. E.g. `id="foo"`. JSF will worry about uniqueness in generated HTML output by e.g. prefixing with current iteration index. Again, read that link (and the "See also" link therein). – BalusC Jul 30 '15 at 13:46
  • ok, now i got it. So when i put in an id = "foo" it will build in the HTML-View columns:0:foo , columns:1:foo and so on – MadMax Jul 30 '15 at 14:02
  • Hmm, i tried to set the Id fixed. But I get an dublicate id error. Maybe it's not working with rich:Columns. In fact there are more then one components inside columns but i wanted to keep the code snippet short. – MadMax Jul 30 '15 at 14:38

1 Answers1

0

I fixed it, just put a unique Id-Value from my Column Bean.

The better solution is to do this: https://stackoverflow.com/a/18358949/5146922

THX BalusC

Community
  • 1
  • 1
MadMax
  • 68
  • 6