javajdeveloper

Problem with displaying "rendered" buttons


Problem with program from JDeveloper. I have a page that opens when this button is clicked.

`<af:link text="#{labels['by.compit.belpost.ot.delivery.menu.NotAssigned_LABEL']}"
id="l3" inlineStyle="font-size:larger; font-weight:bold; color:Black;"
action="#{pageFlowScope.DeliveryMainPageBean.showNotAssignedTop}"/>`

I have two buttons in the menu bar on this page, the code is below.

`<af:commandMenuItem text="First mail" id="cmi13"
action="#{pageFlowScope.NotificationsBean.printUnsentMainNotifications}"
rendered="#{pageFlowScope.DeliveryMainPageBean.show}"/>
<af:commandMenuItem text="Second mail" id="cmi14"
action="#{pageFlowScope.NotificationsBean.printUnsentSecondaryNotifications}"
rendered="#{pageFlowScope.DeliveryMainPageBean.showTwo}"/>`

These two buttons will be displayed if the condition from the method below is met

`public boolean isShow() {
return showPS22primary == 1;
}

public boolean isShowTwo() {
return showPS22second == 1;
}`

variables showPS22primary and showPS22second are initialized and evaluated in the method that opens this page:

`public String showNotAssignedTop() {
showPS22primary=0;
showPS22second=0;
topNodeSelected(DeliveryNotAssignedItem.class);
if(showPS22primary == 0){
showPS22primary = (Integer) ADFBindingsUtil.executeOperationBinding("isShow");
if(showPS22primary >0){
showPS22primary=1;
}else{
showPS22primary=2;
}
showPS22second=(Integer) ADFBindingsUtil.executeOperationBinding("isShowTwo");
if(showPS22second >0){
showPS22second=1;
}else{
showPS22second=2;
}
}
return null;
}`

The problem is that these two buttons appear and disappear even when the page is refreshed. Although in the database the value does not change. But there is no button. How to fix it?

I haven't tried anything because I don't know what's going on. Is it possible that the request is processed for a long time and the program code goes further?


Solution

  • You should debug the method showNotAssignedTop() and look at the outcome in the variables showPS22primary and showPS22second. The first if statement in the method if(showPS22primary == 0){... is not needed as the variable is always 0.

    If you are sure the method outcome is ok you should add an af:outputText and set the value to

    "#{pageFlowScope.DeliveryMainPageBean.show - pageFlowScope.DeliveryMainPageBean.showTwo}"

    This will show you the values seen in the UI. They should be the same as you saw in the method.

    Finally you better use the visible property. Once the rendered property is set to false, the UI component will be removed from the chrome and you need a full page refresh to get the component back. Just seeing the rendered property to true is not enough.