How to set Rendered parameter via JSF bean 2

Asked

Viewed 363 times

1

am facing a small challenge where I need to create a Dashboard dynamically from a drop down.

It is functional but there is a button in each Panel that the rendering of it depends on the existence of another panel.

Logic:

If Panelcity exists Panelled cannot render the button.

In my Bean I did as follows:

CommandButton excluirBtn = new CommandButton();
excluirBtn.setIcon("fa fa-trash");
excluirBtn.setTitle("Remover");
excluirBtn.setActionExpression(methodExpression);
excluirBtn.processUpdates(FacesContext.getCurrentInstance());
excluirBtn.setUpdate("dashboard");
excluirBtn.setRendered(!hasComponentOnDashbaord("panel_3")); //<-Linha que impede renderização do componente se o painel existir.

It works correctly when creating but it does not check after it has been rendered if Panel has been deleted.

How to Do It Dynamically by the Bean ?

  • Thought and create a boleano attribute to inform whether or not the panelCidade should be displayed and deny it to render the button ?

1 answer

0

Friend,

Try using an f:ajax with the Event=attribute to trigger the event and a Listener or action to execute call the Managedbean method and render attribute to update the other panel. Wouldn’t it be the best and less laborious solution? I never created used otherwise. I hope it helps.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.