cancel
Showing results for 
Search instead for 
Did you mean: 

getting a layout element

Former Member
0 Kudos

Hi all,

I have a text view in my layout with the ID "TextView1".

I need to change some properties of this element by coding.

How can i get this element in my editor..?

IWDTextView tv = -


???????????

tv.bindText("Test Data")

tv.setSemanticColor(WDTextViewSemanticColor.NEGATIVE);

tv.setVisible(WDVisibility.VISIBLE);

How can i get my element in editor. Please help.

Thanks in advance,

Jithin

Accepted Solutions (0)

Answers (9)

Answers (9)

Former Member
0 Kudos

Hi,

Only solution is

create attributes say

TextViewData of type String

TextViewSemanticColor of type com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor

TextViewVisibilty of type com.sap.ide.webdynpro.uielementdefinitions.Visibility

Assign all these properties to TextView

During an Action set these properties....

Regards

Akshaya

Former Member
0 Kudos

Hi,

For your requirement the best approach would be to create a context attribute , which is similar to the one where you need to change the property at runtime.

bind this attribute to the UI element property.

Assign the default value in wdDoinit

As you mentioned when the action is fired change the value accordingly.

Hope its clear.

Regards

Ayyapparaj

Former Member
0 Kudos

solved

Former Member
0 Kudos

you have to define a reference to TextView. Do this in "others":

//@@begin others

IWDTextView textView;

//@@end

you have to initialize this reference in wdDoModifyView:

if(firstTime){

textView = (IWDTextView) view.getElement("TextView1");

}

use this reference in actions or methods defined in view controller by calling its methods.

textView.setText("hello war");

Former Member
0 Kudos

No, don't do that (and especially don't create a static reference).

Either

- bind the properties to context attributes and change the value of the context attribute, or

- set a flag (boolean context attribute) in the action handler, check and reset the flag inside wdDoModifyView() and access the UI element in wdDoModifyView() as described above

Armin

Former Member
0 Kudos

Dear all,

IWDTextView textview = (IWDTextView)view.getElement(IWDTextView.class , "textview");

This code which u guys have mentioed can only be used in DomodifyView.

i need my code to be written un an action.If i am correct, i need to create an object of my view here.can u please help me with that as i dont know how create an object of the view.

I need an object of my view only then i can write view.getElement(IWDTextView.class , "textview");

IWDView view = -


??????

thanks,

Jithin

Former Member
0 Kudos

Hi Jithin,

FYI..

You are not allowed to do any modifications to the view-layout anywhere other than the wdDoModifyView(). You can find the alias to your view only in the wdDoModifyView() and not anywhere else.

And, you will not be able to create an alias to the view, i.e,

IWDView view =..---???? is not possible!

Regards

Kishan

Former Member
0 Kudos

hi kishan,

thanks for your reply.

Former Member
0 Kudos

Hi Jithin,

Why don't you change the properties of your TextView in the wdDoModifyView() dynamically?

I don't understand why you aren't doing what I mentioned. wdDoModifyView() will be called everytime the view is modified. i.e, it would be called even when an action is performed.

Can you elaborate on your requirement?

Regards

Kishan

Former Member
0 Kudos

Hi

to get text view:

IWDTextView textview = (IWDTextView)view.getElement(IWDTextView.class , "textview");

and say you want to set the visibility then take a boolean type attribute bind it with the visibility property of text view. And manipulate this attribute at runtime.

Former Member
0 Kudos

try this in view controller:

//@@begin others

IWDTextView textView;

//@@end

in wdDoModifyView type this:

if(firstTime){

textView = (IWDTextView) view.getElement("TextView1");

}

Former Member
0 Kudos

Hi,

As you said you need to change the properties in action then you need to have IWDview object to access that UI element. I am not sure if that'll work.

You can bind the property to an attribute and manipulate its value in action method.

Former Member
0 Kudos

hi Aishwarya,

Can u please give a piece of code ..

IWDView view =..---????

Thanks,

Jithin

Former Member
0 Kudos

Hi,

try this


IWDTransparentContainer rootContainer = (IWDTransparentContainer)view.getElement("RootUIElementContainer");
//create the text view
IWDTextView textview = (IWDTextView)view.createElement(IWDTextView.class , "textview");
textview.bindText("somethingText");
textview.setWrapping(true);
//Add textview to the root container
rootContainer.addChild(textview);

Former Member
0 Kudos

hi,

i have already created the Text View in my layout.

my requirement is to change the properties of that Text View.

former_member197348
Active Contributor
0 Kudos

Hi Jithin,

Try like this:

IWDTextView tv =  (IWDTextView ) view.getElement("TextView1");

you can set properties dynamically to your textview element like

tv.setXXX(xxx);

Regards,

Siva

Former Member
0 Kudos

view.getElement("TextView1"); can be done only in domodifyview.

i need to code in an action.

Edited by: jithin james on Feb 9, 2009 12:37 PM

former_member201361
Active Contributor
0 Kudos

Hi jithin,

Create a Action say "Create" bound to the UI Element with an Parameter say "view" of type "com.sap.tc.webdynpro.progmodel.api.IWDView" and do the parameter mapping.right click on UI (in the outline view)Element -- > parameter Mapping..

using this view parameter , u will be able to create elements and get the elements .

Thanks and Regards