on 11-03-2009 8:08 AM
Hello,
im new in WebDynpro and i have a (simple) question. Is it possible to call a property of an component in the code of an eventhandler?
I have a View with a button and a TextBox (input box) and a label. In the eventhandler of the Button _ Click i want to read the TextBox value and put it into the label. (I know the Context. But thats not the way I want to use / try)
An other question is: How I can set components visible/ or not visible? (in the eventhandler of my action button)
THX at all
regards Michael
Hello Micheal,
As per my understanding UI element Property can be accessed in doModifyView Method of the View as it has a IWDView view as an input parameter through which we can retrieve any UI element and Then set or get its properties.
You can do one thing that you can declare a variable of IWDView or a particular UI element and Initialize the same in the doModifyView method as it is a hook method it will be called automatically at start of the Initialization of the view. You can also the use the firstTime input parameter in the method to initialize it only once. After that the same variable can be used in any method or the event handler. Here is a same Code.
Globally declared variable
private IWDLabel label1;
In doModify Method
if(firstTime)
{
label1= (IWDLabel) view.getElement("FieldName");
}
In the Event Handler:
label1.setText(wdContext.currentContext.getInputFieldContextAttribute);
Hope this works. If any query revert back.
Regards,
Ardhendu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hy,
That was something I thought.
I was thinking of the paralle. NET programming. In the code behind directly access the UI and edit the event handlers. Maybe I just do not see the parallel.
I will try your way. How would you show or hide an view?
I have a ViewSet T - Layout. left a view, right a view and in the top a view with 2 buttons. "search" and "admin" If I want "search" click open the left view and when I click "admin" only the right view should be visible.
regards
Micha.
Yes, that works for all bindable properties the same way.
Please note that view element properties can only be bound to context attributes that have a dictionary type (binding to Java native types is not possible, at least not in earlier releases, and in newer ones only with restrictions).
That means to bind the "visible" property, you first need to define a context attribute of dictionary type "Visibility" (Dictionaries -> Local Dictionary -> com.sap.ide.webdynpro.uielementdefinitions.Visibilty). Then you can bind the "visible" property of one or many view elements to that context attribute.
To set these view elements to visible, you then set the context attribute value to WDVisibility.VISIBLE, to hide it use WDVisibility.NONE.
Armin
The normal way of making views visible or invisible is to define a suitable navigation structure between the views (using the Window modeler) and navigating along the defined navigation links.
Viewsets have certain drawbacks regarding layout flexibility, personally I don't use them. A more flexible way is to use plain views with ViewContainerUIElement instances. In that case you can also use the visibility of the ViewContainerUIElement to show/hide the contained view.
Armin
Cool... this is an very helpful tip. thx... sry for these simple questions but i will learn webdynpro for java. I only programming .NET / C# before and now I'm only a portal admin. But i want back to development. So 2 SAP boks are on my desk and the JA300. But still tehre are so many questions
Hello Armin,
I totally agree with you. I just forgot that it was a static method. Thanks again for giving a clear explanation about it.
Regards,
Ardhendu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Micheal,
First of all sorry I gave you the previous solution as I is not correct as per the Web Dynpro Programming Model.
You had said that you wanted solution other than Context so I just thought of it.
As a best practice you should always bind a property value of a UI element to a Context Attribute of the required type and then change its value using that attibute. You can Attibute value to WdVisibility type and bind the same to property value for your visibility problem.
Regards,
Ardhendu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for my somewhat rude answer, but apart from violating the Web Dynpro programming model, your solution with storing view elements in view controller references will not work because wdDoModifyView() is a static method (and that was exactly the reason to make it static as its Javadoc clearly expresses) and second, if one would use a static controller reference that would make be even worse as has been explained in this forum several times.
Armin
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.