user9309329
user9309329

Reputation: 323

JSF PrimeFaces ajax update excluding one component

I got a form, that includes outputPanel that I need to update, excluding one of its component (it containts calendar, that resets after I call update, I want to prevent that)

<p:ajax update=":form1:outputPanel1 :not(form1:outputPanel1:nestedOutputPanel)"/>

But I have no idea how can I achieve something like this (above example is not working)?

Upvotes: 0

Views: 2587

Answers (1)

Jasper de Vries
Jasper de Vries

Reputation: 20158

The PrimeFaces update attribute takes one or more expressions separated by a space (or comma). Normally (in plain JSF) those expressions are client IDs, but in PrimeFaces you can also use selectors. A selector is executed and results in a list of client IDs to update. You could use a selector to select all the components that need to be updated and exclude the component you don't want to update.

You could add a style class to the component you want to exclude and use something like:

update="@(.parent :not(.exclude))"

As you can read in the top answer on the linked question, the @(...) selector will be used as a jQuery selector. So you can easily test selectors in your browser's JavaScript console as $("...").

See also:

Upvotes: 4

Related Questions