Validate order of items inside ui:repeat

There’s physically only one UIInput component whose state changes depending on the current iteration round of UIRepeat. It’s available by just its client ID without the UIRepeat index: findComponent(“formId:inputId”) (the UIRepeat index is only of significance in the client side). However, when the component is programmatically been accessed outside the context of UIRepeat this way, … Read more

JSF 2 dataTable row index without dataModel

Just bind the table to the view itself instead of to a bean. <h:dataTable binding=”#{table}” …> Then you can use #{table.rowIndex} where necessary. E.g. <h:column>#{table.rowIndex + 1}</h:column> Note that the code is as-is and that the EL variable name table is fully to your choice. See also: How does the ‘binding’ attribute work in JSF? … Read more

Collection of selectManyCheckbox inside a ui:repeat knows which element of the repeater it belongs to

Simplest way would be to just bind the value of the checkbox group to the currently iterated object instead of all checkbox groups to one and same parent bean property. In code, just replace value=”#{gridPopUpBean.oneQuestionUserAnswerList}” by value=”#{p.oneQuestionUserAnswerList}” and make changes in the model accordingly. Alternatively, you can also provide a Map of all answers by … Read more

within not entirely working, only the last is processed

This is a bug in state saving of <ui:repeat> in Mojarra. There are several similar issue reports at http://java.net/jira/browse/JAVASERVERFACES, among others issue 2243. You have basically 2 options: use another iterating component (e.g. <c:forEach>, <h:dataTable>, <t:dataList>, <p:dataList>, etc), or replace Mojarra by MyFaces (the <ui:repeat> in this construct works properly in there).

Using validator with a variable attribute in ui:repeat

This is indeed specified/expected behavior. The attributes of taghandlers like <f:validateXxx> are evaluated during view build time. So they can’t refer a variable which is only available during view render time like the currently iterated variable of <ui:repeat>. It would indeed work when you use an iterator which runs during view build time like JSTL … Read more

How to use to iterate over a nested list?

What you need is to nest another <ui:repeat> tag in your outer iteration: <ui:repeat value=”#{bean.listOfA}” var=”a”> … <ui:repeat value=”#{a.listOfB}” var=”b”> … </ui:repeat> </ui:repeat> The only thing left that is worth noting is that nested <ui:repeat> tags used to have problems with state management until Mojarra 2.1.15 version (details in jsf listener not called inside nested … Read more

How can I set id of a component/tag inside ui:repeat

This is not possible with a render-time tag such as <ui:repeat>. The <ui:repeat> will however by itself already ensure the uniqueness of the generated client ID by prepending it with the row index. So just remove the EL part from the ID attribute of the component. <ui:repeat value=”#{bean.columns}” var=”column”> <h:panelGroup layout=”block” id=”column”> With a view … Read more

How to use with DefaultStreamedContent in an ui:repeat?

It is not possible to use <p:graphicImage> this way. You should rather iterate over a collection of unique image identifiers, not over a collection of StreamedContent. Those unique image identifiers have then to be passed as a <f:param> to <p:graphicImage> which in turn will generate the right URLs for the browser. <ui:repeat value=”#{data.imageIds}” var=”imageId”> <p:graphicImage … Read more