0 Replies Latest reply on Sep 29, 2009 4:27 PM by Rudi Adianto

    Marking input component inside a table as invalid

    Rudi Adianto Newbie

      Hello,

      This is not exactly a richfaces question, but I'll try my luck anyway.

      My standard way of doing application level validation is to bind the components in a request scoped bean, and upon failed validation do comp.setValid(false) and associate a message with the component (using something like facesContext.addMessage(clientId,message)).

      Now the problem comes when the input components are inside a table and may be rendered repeatedly depending on the table data, and I want to invalidate the input component at the first row only.
      My usual method would fail since the bound component would logically refer to multiple UIInput at once (all of that input component instance inside the data table). At least thats what I'm assuming, so correct me if I'm wrong.

      I also tried to walk the component tree and get the first instance of the particular UIInput. But the message association would fail because when the validation occurs ("invoke action" phase) the component's client id was "j_id16:j_id42:firstDataFieldContainer:firstField", but when its actually rendered the same component client id was "j_id16:j_id42:0:firstDataFieldContainer:firstField" (notice the number '0' between j_id42 and firstDataFieldContainer).

      So how do I do this correctly?
      Can someone shed me a light here? How would the other do these kind of stuff?
      Thanks.

      Regards,
      Rudi A.