cancel
Showing results for 
Search instead for 
Did you mean: 

Redraw action bar item to display different icons based on conditions

thamizharasan
Advisor
Advisor
0 Kudos
339

Hi Experts,

We have a scenario to show the notification icon in ActionBar. We have a rule that fetches the status whether new notification is available or not. Based on that we will return different icons to show. We read doing a redraw on control will retrigger the rules. But we couldn't find any target path for ActionBar/ActionBartItems to redraw.

Could you guys suggest an approach to solve this problem.

Thanks,

Thamizharasan.

Accepted Solutions (1)

Accepted Solutions (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

You have two choices for this.

  1. Use multiple buttons and toggle the visibility of the buttons based on state using setActionBarItemVisible()
  2. Use a rule for the Action Bar Image and trigger a page redraw which will then re-evaluate the image rule and change the image.

In terms of if one is better than the other, it will depend on your use case. Option 1 of toggling the visibility would be my choice for most use case since it is cleaner from a metadata standpoint and I can have my OnPress rule specific to the one action versus having a switch statement based on which state is currently being shown. It also has the advantage of not doing a full page redraw but you should evaluate both based on your use case.

Keep in mind that you need to use the index of the button when calling setActionBarItemVisible. We will be adding support for names in a future release.

fjcarrasco
Active Participant
0 Kudos

Great! Thanks bill.froelich

Answers (1)

Answers (1)

fjcarrasco
Active Participant
0 Kudos

Hello thamizharasan

I have the same requirement. Did you manage?

Thanks

Regards