guidewire

Use ToolbarFlags in PCFs to determine buttons visibility instead of availability


I have a usecase in which I have a ListView with checkboxes and a screen referencing that ListView and containing 4 CheckedValuesToolbarButtons that need to perform an action on all the selected rows. This action could be different depending on some information in the checked rows (i.e.: the entity represented in the ListView). EntityA is the one displayed in the ListView and has PropertyA, which if it evaluates to true, the button should perform Action1 and if it's false Action2. This is easy to achieve, but customer wants the label of the buttons to change dynamically to indicate if the action to be performed is Action1 or Action2.

I didn't manage to implement this and my next idea was to duplicate the buttons and use ToolbarFlags to expose the value of PropertyA from the ListView to the buttons. With this I could achieve what I needed, but the issue is the flag property in CheckedValuesToolbarButton determines whether the button is available, and I need it to determine the visibility of the button. I cannot use the value of the flag outside the flags property, so I cannot create a condition for the visible property based on the flags. So now I see 8 buttons every time, some of them greyed out based on the selected checkboxes. Is there any other way to achieve this? An alternative would be to hide the button every time it is not available (or when its opposite button is available), but I'm not sure this is possible either. I think for this I would need some kind of reflection mechanism and reference the button by their ID. If anyone could guide me with this it would be much appreciated. Thank you in advance.


Solution

    1. I think you should go back to the business with a better suggestion of how to solve their use case.

    2. The reason that the available property works is because it can respond to a user selecting checkboxes in the LV without posting back to the server (the greying out of the buttons based on the checkboxes selected in the LV is a client-side behavior). The visible property is evaluated on the server-side and requires a full post back to the server to redraw the UI. It would be inadvisable to implement a post back to the server every time a user selected/deselected a checkbox in an LV. Therefore, instead of trying to implement this requirement as is, I would suggest experimenting with a different (hopefully simpler and more intuitive) solution to the use case.