0

I can use IDs of components or a styleClass used in all of the components.

<p:ajax event="change" process="@none" listener="#{someListener()}"
        update="@(.someStyleClass)"/>

<p:ajax event="change" process="@none" listener="#{someListener()}"
        update="someId1 someId2 someId3"/>

Which approach is better and why?

EDIT: I know that CSS selector uses IDs in the background. I am not asking how it works. I am asking which is a better approach ( for maybe different cases ) and why.

kalahari
  • 895
  • 5
  • 15
  • 34

1 Answers1

0

You seem to be confused with the concept of these CSS selectors with the updating of PrimeFaces components.

Simple, if you have requirement to update just one component use ID selector. While, if you have numerous (more than one) components to be updated on certain action, use CLASS selector.

Update: Although you can set comma separated IDs of components in your update attribute, but the difference of using CLASS selector would be that those components are interrelated (similar) by any mean or you don't want to use separate ID attribute on each component.

Parkash Kumar
  • 4,710
  • 3
  • 23
  • 39
  • I don't think OP is confused... not at all . And you don't need to use class selectors, You can also use 'type' selectors (all inputs) or... – Kukeltje Aug 04 '17 at 13:23
  • 2
    @Kukeltje, Now I am sure, OP was confused! And OP didn't ask for the `type` selector. – Parkash Kumar Aug 04 '17 at 14:10