cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the text of a view using a button?

Former Member
0 Kudos

HI,

Experts,

I am new to web dynpro for java i was able to create a project and component and my intention is to change the text value of a view(default view) when ever i press a button.

Thank u,

Shabeer ahmed.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi sabeer,

if you want to change your default view when you click on button..so you need to some code written in WddoModify

in

public static void wdDoModifyView(IPrivateCheckView wdThis, IPrivateCheckView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

urView=view;

}

declare in view..at

//<@other begin

static IWDView urView=null;

//<@end

crate one action for button like

public void onActionShowChange(event){

//TextView1--id of textview Ui element

IWDTextView text=(IWDTextView) urView.getElement("TextView");

text.setText("you choice massage");

}

this action assign your button..

hope this will work

thanks

jati

Edited by: sudhir kumar on Apr 7, 2009 12:22 PM

Former Member
0 Kudos

STOP! This is very very bad advice.

Armin

Former Member
0 Kudos

Hi ,

Armin,

Which advise i didn't understand

Former Member
0 Kudos

ok,

I understand

Answers (4)

Answers (4)

Former Member
0 Kudos

Thank u

Former Member
0 Kudos

I hope you didn't use the proposal with the static view reference (this will not work). Use the solution with data binding to context attribute.

Armin

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi Shabbir

You have hard coded the "Hello world" in the text property of your "TEXT VIEW" UI element.

Thats not the procedure to change the text of above UI element when user is pressed a button.

Create a context attr in the context and bind with the text property of the UI element.

Create an action and bind with the onAction event of a button

In the action property change the value like

wdContext.currentContextElement().set<ATTRIBUTE NAME>("Your Custom Value");

Regards

Kalyan

Former Member
0 Kudos

Hello Shabeer,

Hope you have created an Action and bind it to the button.

Create an attribute in your context and bind that to the text UI element of the default view.

In onAction<action> method change the text of the context attribute. It will get reflected in your view when you press the button.

Hope this helps.

Sathya

Former Member
0 Kudos

Hi Shabeer,

Bind you TextView UI element to the context attribute and change the value on the action of Button by setting the value to a context attribute.

Thanks,

Jhansi

Former Member
0 Kudos

HI,

By default i am viewing 'Hello World!' text that text i want to replace by pressing a button.If i use context this Hello world!' will be removed then no data will be displayed before pressing the button.Can't we achieve this with out context.

Thank u,

Shabeer Ahmed.

Former Member
0 Kudos

Hi Shabeer.

Did U bind Ur button with an action?

If yes, write the below code in Ur onAction<buttonAction> method.

wdContext.currentContextElement.set<attributeName> ("New text");

Hope this helps,

Sathya

Former Member
0 Kudos

Hi Sabir...

can you try my Thread...this is use full to you..try to my above thread...

thanks

jati

Edited by: sudhir kumar on Apr 7, 2009 1:04 PM