Skip to Content
avatar image
Former Member

I want make my button visible or invisible on click of button

Hi All

I want make my button visible or invisible on click of button.

Regards

Kirankumar M

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 19, 2009 at 10:49 AM

    Hi

    Do one thing..after click on Buttion Action..it should invisivble.if you put some code in onButtonAction

    create on Value Attribute in View Context like inVisible data type should be--"com.sap.ide.webdynpro.uielementdefinitions.Visibility"

    Goto Button property---bindinding inVisible attribute into VISIBLE value at view part..as you did before

    OnButtonAction(event){

    ;;;;;;;;;;;;;;

    ;;;;;;;;;;

    wdContext.currentContextElement().setInVisible (WdVisibility.NONE);

    }

    hope it will work fine.

    thanks

    jati

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 19, 2009 at 10:39 AM

    I want make my button visible or invisible on click of button.

    Do you mean to say, you want to make a button invisible by clicking another button? Or the same button? If it is invisible, how will you click it again....(i.e, in case of same button)!

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 19, 2009 at 01:07 PM

    HI Kiran,

    Your Question:

    onclick button should be visible and on second click it should become invisible.

    Answer:

    In your View

    1.Add Two button using Apply Template--actionButton

    So two buttons will get added to the view

    2.Create an attribute in View Context say buttonset of type com.sap.ide.webdynpro.uielementdefinitions.Visibility

    Bind the visible property of second button to buttonset attribute

    This attribute is to set visibility

    Also create a booloean attribute bool in the View context

    3.In DoInit method

    wdContext.currentContextElement().setBool(true);

    So that both buttons are visible in View initially

    4.In First button event handler onActionButton()

    call second button eventhandler onActionButton_0()

    public void onActionButton(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

    {

    //@@begin onActionButton(ServerEvent)

    onActionButton_0(wdEvent);

    //@@end

    }

    Here onActionButton_0() is like one method which is actually making second button visible or invisible based on boolean value bool=true /bool=false

    5. Write the following code in onActionButton_0() to perform the actual action

    if(wdContext.currentContextElement().getBool()==true){

    wdContext.currentContextElement().setButtonset(WDVisibility.NONE);

    wdContext.currentContextElement().setBool(false);

    }

    else{

    wdContext.currentContextElement().setButtonset(WDVisibility.VISIBLE);

    wdContext.currentContextElement().setBool(true);

    }

    6.Now build and deploy ans run your application.

    It works.. 😊

    Nice Question..

    I was excited trying this...

    Hope it helps You

    Regards,

    Archana

    Edited by: Archana CTS on Mar 19, 2009 2:08 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 19, 2009 at 04:22 PM

    Hi,

    Change visiibility of button by binding the visible property of that UI element to some context attribute of type visibility (com.sap.ide.webdynpro.uielementdefinitions.Visibility). So that the visibility is changed dynamically.

    For example :

    Create 2 buttons buttonA and buttonB. For ButtonA create context attribute "ButtonAVisibility" of type . com.sap.ide.webdynpro.uielementdefinitions.Visibility and bind the visible property of button to this context attribute. Then change this property from WDVisibility.VISIBLE to WDVisibility.NONE by modifying the context attribute in any action method by using

    wdContext.currentContextElement().setButton1Visibility(WDVisibility.VISIBLE);

    In the similar manner u can change the visibility dynamically.

    Thanks

    Ritushree

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 20, 2009 at 07:03 AM

    solved

    Add comment
    10|10000 characters needed characters exceeded