This discussion is archived
5 Replies Latest reply: Aug 19, 2013 7:30 AM by 1001638 RSS

displaying a command button when we select another command button using EL

1001638 Newbie
Currently Being Moderated

hi,

 

JDev version 11.1.2.1.0

 

I have 1 pages (A) and two command buttons(a and b)

 

requirement : when the page is loaded for the first time 'a' command button should be present on the page. Only if i click on 'a' then 'b' command button should be displayed. I am trying to use rendered property on 'b'.

But i am not able to find exactly how rendered property needs to be set. how to set in EL that 'a' is selected.

  • 1. Re: displaying a command button when we select another command button using EL
    vinaykumar2 Expert
    Currently Being Moderated

    you need to bind button a. Because you want to display button b on click of button A. u need to handle event of clicking.this link will be helpful for u..

     

    in this example i am using checkbox to display table .you have to implement button.And make autosubmit to true of button A, and put partial trigger on button B.

     

    using EL you should use render property. like this   #{binding.commandButtonA.rendered}

    but i dnt thnk u shld use render property..either use above example or use managed bean

  • 2. Re: displaying a command button when we select another command button using EL
    Timo Hahn Oracle ACE
    Currently Being Moderated

    You can do this without binding anything to a bean by just using EL and PPR.

    Look at the code

                            <af:panelGroupLayout id="pgl2" layout="vertical">

                                <af:button text="A" id="b1">

                                    <af:setPropertyListener from="#{'1'}" to="#{viewScope.ButtonAPressed}" type="action"/>

                                </af:button>

                                <af:button text="B" id="b2" visible="#{viewScope.ButtonAPressed eq '1'}" partialTriggers="b1"/>

                                <af:button text="Page 2" id="b3" action="gotoPage2"/>

                            </af:panelGroupLayout>

    The trick is to use the visible property as the rendered can't be use for your use case. Once a component has set the rendered property set to false you can only see it on the page after a full page refresh where the rendered property is set to true. The visible property hides the component and you can show it again using ppr (like it's done on button B).

    The button gotoPage2 is added to reset the viewScope parameter which controls the visible status of the button B. As this is in viewScope, it's reset once you navigate away from the page. Once you come back the button B isn't visible until you click button A again.

     

    Timo

  • 3. Re: displaying a command button when we select another command button using EL
    1001638 Newbie
    Currently Being Moderated

    Timo,

     

    I am not clear how to create viewscope variable.

    If i try the above thing the button 'b2' does not get displayed in clicking 'b1'

  • 4. Re: displaying a command button when we select another command button using EL
    Timo Hahn Oracle ACE
    Currently Being Moderated

    I forgot to set the partialSubmit on the button A. Try this

                            <af:panelGroupLayout id="pgl2" layout="vertical">

                                <af:button text="A" id="b1" partialSubmit="true">

                                    <af:setPropertyListener from="#{'1'}" to="#{viewScope.ButtonAPressed}" type="action"/>

                                </af:button>

                                <af:button text="B" id="b2" visible="#{viewScope.ButtonAPressed eq '1'}" partialTriggers="b1"/>

                                <af:button text="Page 2" id="b3" action="gotoPage2"/>

                            </af:panelGroupLayout>

    You don't have to do anything to create the variable. It's created automatically when you hit the button A.

     

    Timo

  • 5. Re: displaying a command button when we select another command button using EL
    1001638 Newbie
    Currently Being Moderated

    Thanks Timo. It is working now.

     

    After making the above changes , when i click on the button it doesnot display the page progress symbol(circle rotating in the browser window), so the user wont be able to check if the button is actually working or not.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points