on 03-08-2005 11:46 AM
Hello,
Lets say I have a label called testLabel and I would like to put it's text at the doInit() method of my view.
How do I do that?
Hi,
Also you got (technically) right answer, there is always preferred (as it emphasized by WD team on this forum) to use <b>context binding</b> over direct UI element properties manipulation.
In brief, if you declare MyAttr attribute in context, and bind it to label text, then you may just call wdContext.currentContextElement().setMyAttr("whatever-text-you-want");
So always consider context binding first.
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
follow this link
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/web dynpro tutorial and sample applications.faq#q-1
<b>How to create your first Web Dynpro application?</b>
Above application is similar to your requirement but here textview you should same steps but your case is label all that you need to create a context attribute, label UI element map this attribute (in Properties of label UI element) and set the string (Code mentioned by Subdhip Gosh) in the doinit method or if you are declaring an Action ( in this action method depending your requirement)
Hope it helped you
Regards,
RK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roy,
do you want to set the label text dynamically from the wdDoInit method? If this is the case then just create a string type value attribute in view context (say ctxTestLabel. Create a label UI element (testLabel as u mentioned), bind the 'text' proerty of this label element to the context attribute ctxTestLabel.
In the wdDoInit() method of your view write the following line
wdContext.currentContextElement().setCtxTestLabel("Your label text");
This should solve the problem if I have judged it properly. If thats not the case you want to be let us know.
Regards,
Shubhadip
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shubhadip,
What you have offered me is how to bind a text label to a context attribute. My question is different:
I have a label and I want to assign a text to it which will not be bound to an attribute from the Context Controller. Simply a "free" String.
How do I do that?
Message was edited by: Bertram Ganz
databinding: from UI-element property to context element not vice versa.
Hi Roy,
if you want to set the label directly without setting it thru context variable then its part of the dynamic programming of WD. So u can do that only in wdDoModifyView method. Obtain the reference of the label object from the view object and set the text property of it with the desired value.. like below
public static void wdDoModifyView(IPrivateImageAppView wdThis, IPrivateImageAppView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
IWDLabel myLabel = (IWDLabel)view.getElement("testLabel");
myLabel.setText("Hello this is a Label");
//@@end
}
this should solve ur problem...
regards,
Shubhadip
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.