-1

i wanted to know if there is a way to update a jsf commandlink bounded attribute after the user clicks on it.

<p:commandLink resetValues="true" value= "#{NotificationManagedBean.countUnreadNotification}" actionListener="#{NotificationManagedBean.showUnreadNotification()}" />

In this case, countUnreadNotification is a number, i would like to reset the value after the user clicks on showunreadnotification...

I've tried resetting countUnreadNotification to 0 at the backing bean and refreshing the page, but to no avail. Scope for the backing bean is requestscoped.

Is there a way to do this?

CodeGuru
  • 9
  • 4

1 Answers1

0

The resetValues attribute is used to reset all input html element on the client before the ajax request is sent, which isn't what you want here.

And since your backing bean is requestscoped, the countUnreadNotification attribute will always be 0 since this bean will allocated from scratch for each request.

But what you aren't doing is marking the commandLink component to be updated when the ajax request returns:

<p:commandLink value="#{NotificationManagedBean.countUnreadNotification}"
  actionListener="#{NotificationManagedBean.showUnreadNotification()}"
  update="@this" />
codeturner
  • 993
  • 1
  • 8
  • 20