cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

Hi All

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

Regards

Kirankumar M

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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 ContextlikeinVisible 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

Answers (4)

Answers (4)

Former Member
0 Kudos

solved

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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)!

Former Member
0 Kudos

different button

i have two values if i pass 0 it shud be visible if 1 then invisible like that

Former Member
0 Kudos

To change the visibility of any UI element on button click, you should bind the visible property of that UI element to some context attribute of type visibility (com.sap.ide.webdynpro.uielementdefinitions.Visibility).

Say you have button1 and button2. For Button1 you create context attribute "Button1Visibility". Then change this property from WDVisibility.VISIBLE to WDVisibility.NONE by modifying the context attribute in the OnActionButton2() event handler of the button. The Button1 will become invisible.

In init() method of the view set the button1 to be visible,

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

Use this code in the OnAction() method of Button 2:

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

Edited by: Anagha Jawalekar on Mar 19, 2009 4:36 PM

Former Member
0 Kudos

From where these values 0 / 1 are coming? Is an end user entering these values in some input field?

Former Member
0 Kudos

Hi,

1.Create a value attributes of type Visibility.

2.Now bind it to the visibility property of your button.

now in the action of your first button type this.

If(value==0){

wdContext.currentContextElement().set<attr1>.NONE

}

else if (value == 1)}

wdContext.currentContextElement().set<attr1>.VISIBLE

}

Regards,

Jithin

Former Member
0 Kudos

Hi Kiran,

First of all create a value attribute of type"com.sap.ide.webdynpro.uielementdefinitions.Visibilityu201D .

Bind this context to the "visible" property of button.

Now on whichevr action u r passing 0/1 values ,put a validation there only. Like:

If (value==0).

{

wdContext.currentcontextelement.set<value attrbute>(WDVisibilty.NONE);

}

elseif(value==1)

{

wdContext.currentcontextelement.set<value attrbute>(WDVisibilty.VISIBLE);

}

Hope it solves ur problem

Regards

Khushboo

Former Member
0 Kudos

Thanks you all