-1

I need to mark inputText field generated using ui:repeat as invalid. I am able to do it for normal input fields by using following code in bean:

 UIComponent root = context.getViewRoot();
 UIInput inputFieldObj = obj.findComponent(root, id);
 inputFieldObj .setValid(false);

The above code is working, however when I try to get the components that are generated using ui:repeat. Its not marking the textfield as invalid.

So for below code its working:

<p:inputText id="txtEmpId12" /> 

But for this its not:

<ui:repeat>
    <p:inputText id="txtEmpId" />   
</ui:repeat>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Alok
  • 184
  • 2
  • 18

1 Answers1

0

This is because in your scenario component tree contains only one input. Ui:repeat renders inputs on render phase. As a workaround you could use c:forEach. In this case component tree will contain all inputs. But I don't like this approach.

A.Panzer
  • 391
  • 3
  • 15
  • I still don't get how it contains single input. iSs it internal property of ui:repeat? When I have a list size of 3, using ui:repeat, its generating 3 input fields with unique id's like id = '0:txtEmpId, id='1:txtEmpId, id='2:txtEmpId. so, hows its a one input? I just want to understand. Please clarify. – Alok Sep 11 '15 at 06:46
  • Take a look at this link: [Validate order of items inside ui:repeat](http://stackoverflow.com/questions/18469551/validate-order-of-items-inside-uirepeat) – A.Panzer Sep 11 '15 at 13:16