cancel
Showing results for 
Search instead for 
Did you mean: 

UI Element

Former Member
0 Kudos

Hi,

How can we catch UIElement in View code and ? how can we change the UI element properties thru code dynamically?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

In

wdDoModifyView

we have a argument called view.

This attribute gives us access to the view and the UI elements contained in it.

To access a UI element in the view,

view.getElement("the UI element Id you have given").

Typecast this to the requisite UI element. You can then use it to set its properties.

About the question in the other post, description is the UI element name and Activity.Description is the name of the attribute bound to it.

Regards

Bharathwaj

Former Member
0 Kudos

Hi

This is my code

wdDoModifyView

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

Text1.bindText("MyNode.data");

which is not working.. here MyNode is a context node and data is value attribute under MyNode and TextView1 is ID of TextView which i have created at Design time.

Former Member
0 Kudos

Hi,

2 things to note.

1. Is the node initialized.

2. Is there any value set to the data attribute.

Create a attribute directly under the root,set its value in init and bind it to the textview. If this works, there is a problem with your node . Set the node's cardinality as 1..1.

Regards

Bharathwaj

Former Member
0 Kudos

Hi

If i directly bind MyNode.data to TextView Itz working..

Former Member
0 Kudos

Hi,

But have u checked the inputs I have given. There is no reason it should not work in that case.

Can you post the whole codo u have written, plus the place where u r setting its value and the node 's cardinality .

Regards

Bharathwaj

Former Member
0 Kudos

Hi

public void wdDoInit()

{

//@@begin wdDoInit()

String value="";

for(int k=0;k<5;k++)

{

IWDNodeElement element = wdContext.nodeMyNode().createElement();

element.setAttributeValue("data", "NewYork");

wdContext.nodeMyNode().addElement(element);

}

IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();

for(int i=0;i<5;i++)

{

//wdContext.nodeMyNode().getMyNodeElementAt(i).setData("NewYork");

//msgMgr.reportException("Size: " +wdContext.nodeInput().size(), true);

}

for(int j=0;j<5;j++)

{

//value = wdContext.nodeMyNode().getMyNodeElementAt(j).getData();

msgMgr.reportException("Text: " +value, true);

}

//IWDView view;

//IWDViewElement e;

//e.getView().getElement(TextView1);

//@@end

}

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

{

//@@begin wdDoModifyView

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

Text1.bindText("MyNode.data");

//@@end

}

And the cardinality is 0..n if change it to 0..1 itz giving error...and i guess it wont allow me to create elements under that node

Former Member
0 Kudos

Hi,

You are creating 5 elements. So when u set the cardinality as 0..1 (meaning... o 0r 1 element it will give error.)

The cardinality should be 1..1 (or 0..1).

In case of 0..1 , write the code once..and not within a loop. Also make sure that the "initialize lead selection " property is set to true.

It will work now.



//write this code directly after setting the cardinality as 1:1 and take the loop out
element = wdContext.nodeMyNode().getMyNodeElementAt(0);
element.setAttributeValue("data", "NewYork");

Regards

Bharathwaj

Former Member
0 Kudos

Hi

Itz working, but it doesnt solve my problem can you help me out here.

In my application I have to create Calender for 3 months(current month and coming two months), In this calender I've to create DropDownBox in each cell to display some text with day number..?

Could you tell me how could i create UIElement for this Calender.

Thanks

Former Member
0 Kudos

Hi,

Hmm.. What you are now asking is a different question altogether.

Anyways, make use of DateNavigator UI element for your requirement.

On select of any date you can display the details related to it and populate or make selections in the dropdown accordingly.

http://help.sap.com/saphelp_nw04/helpdata/en/3b/38fd2d7a964645a5417d2a69462ae5/frameset.htm

This link gives a detailed explanation. Please go through it . In case if you have any problems , post a seperate question.

Regards

Bharathwaj

Answers (1)

Answers (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos