Forum Stats

  • 3,767,751 Users
  • 2,252,713 Discussions
  • 7,874,327 Comments

Discussions

Disable CommandToolbarButton programmatically

User_FU6JN
User_FU6JN Member Posts: 4 Employee

Hi ,

I'm using JDeveloper 11.1.1.7.0

I have defined a button like this:

<af:commandToolbarButton id="launchButton"

                       text="#{uiBundle.LAUNCH}"

                       actionListener="#{LaunchPlanBean.planDialogSetUp}"

                       accessKey="L"

                       binding="#{KanbanPlanBean.planReadOnly}">

           <af:showPopupBehavior popupId="launchPopup"

                      triggerType="click"/>

  </af:commandToolbarButton>

In some conditions, I need to disable the button programmatically. I've tried this:

RichCommandToolbarButton readOnly;

....

....

readOnly.setdisable(true);

My issue is that, when running the page, it seems to work and button shows disabled with my right conditions.

But, if I click on the disabled button, popup appears. I have tried this with RichCommandButton and it is working fine but not with RichCommandToolbarButton.


How can I solve this?


Thanks & Regards 

Tagged:

Best Answer

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,655 Red Diamond

    Can you do a test, please?

    Set the disabled property of the button to false in the page. Now check what happens when you click on the button.

    Tell us if the popup still opens in this case, please.


    Timo

  • User_FU6JN
    User_FU6JN Member Posts: 4 Employee

    Hi Timo,

    Thanks for response !

    By default the disabled property of the button is false . In this case button is visible and pop-up is appearing after clicking of this button. Now I have set the disabled property of the button to True in the page and button shows disable in the page but still pop-up is coming up with click of this button.

  • User_FU6JN
    User_FU6JN Member Posts: 4 Employee

    Snippet code after change the disable property of this button:-

    <af:commandToolbarButton id="launchButton"

                           text="#{uiBundle.LAUNCH}"

                           actionListener="#{LaunchPlanBean.planDialogSetUp}"

                           accessKey="L" 

    disabled="true">

               <af:showPopupBehavior popupId="launchPopup"

                          triggerType="click"/>

              </af:commandToolbarButton>

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,655 Red Diamond
    Accepted Answer

    Try using tiggerType="action" on hte af:showpopupbehavior.


    Timo

  • User_FU6JN
    User_FU6JN Member Posts: 4 Employee

    Hi Timo ,

    I have used your suggested solution and it is working for me . 

    Thank you for your assistance.

    I am facing one more problem regarding the same problem but slightly different component.

    I am trying to disable the commandImageLink by programmatically. Here is the code:

      

    <af:commandImageLink 

    id="addPlanImage"

    icon="/oracle/apps/flm/ekanban/common/images/addfile_ena.png"

    actionListener="#{bindings.CreateInsert.execute}"

    disabled="#{!bindings.CreateInsert.enabled}"

    shortDesc="#{uiBundle.ADD_KANBAN_PLAN}"

    binding="#{KanbanPlanBean.commandImageLinkReadOnly}" />

    I have tried this for disabling the component programmatically:-

    RichCommandImageLink commandImageLinkReadOnly;

    ...

    ...

    ...

    commandImageLinkReadOnly.setDisabled(true);

     

    My issue is that, when running the page, it seems to work and button shows disabled with my right conditions.

    But, if I click on the disabled button, It is performing the action which is adding the row in the table. I have tried this on other commandImageLink and it is working fine but not working on this one. I am guessing that I have already bind disable property with other conditions so i am not able to disable it through binding property.

    Please help me to solve this problem as well.

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,655 Red Diamond

    Yes, that is my guess too.

    You should not bind all components to a bean and work directly on them in the bean. The way to go is to use a bean property (or a method) for this and use this for the disabled property in the UI, like

    <af:commandImageLink...disabled="#{mybean.linkdisabled}...

    where mybean should be in request scope.

    If you use a method to calculate the state, make sure the function is fast, as it'll be called multiple times.

    The advantage of this approach is that the framework handles the refreshing stuff and that the other developers know that the property is handled specially.


    Timo