on 09-11-2006 11:16 AM
Hello,
I was wondering if the solution i implemented might cause problems with a multi-user environment.
The situation is that i want to dynamically create some UI elements when a certain button is pushed for example. I have to lookup the container to which the buttons have to be added. For this i use the following line:
Group buttonContainer = (Group) currentView.getElement("topicsButtonGroup");
As u can see, i need an instance of IWDView to use the getElement method. I couldnt find it anywhere so i saved it from the
public static void wdDoModifyView(IPrivateTaskListView wdThis, IPrivateTaskListView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
method like this:
if (firstTime) {
//keep a reference to the current view
currentView = view;
}
This is done in a static method so the variable is gonna be
private static IWDView currentView
.
Now i can use the view from non-static methods to lookup UI elements.
My only question is then...is this gonna cause any problems or is there another way to solve this?
Much thanks,
Hugo Hendriks
Hi Hugo,
I have another approach of doing the same thing.
1) Create a attribute in the View context of type: IWDView.
2) In the wdDoModifyView, set this attribute value to the view value of the wdDoModifyView function.
Use this code:
if(firstTime)
{
wdContext.currentContextElement().setView(view);
..
..
}
now where ever you require the view object just use this value from the context attribute. It is present there globally for all methods of this view.
Code to get the value of this view:
IWDView view = wdContext.currentContextElement().getView();
I hope this will help you. This will also solve your problem of this view object being static and private to wdDoModifyView function.
Regards
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the fast reply,
Armin, that kinda looks like a strange way to handle this, in my humble opion. You create nice and clean eventhandlers for buttons and then still put all of the functionality into the wdDoModifyView method.
I like Pravesh method more then but doesnt this also create problems? Im just startign with WD so i apologize for asking so much questions but im trying to figure how it all works.
regards,
Hugo Hendriks
Hi Hugo,
I think this will not create any problem for Non static methods as well. In my project I am creating all my UI elements Dynamically and I am able to use this approach efficienly.
As far as I think, you will not not encounter any probelm using this code. I hope this helps you!!
Regards
Pravesh
PS: Kindly consider rewarding points if helpful or solved.
Don't do this, it will definitely lead to problems.
Instead you can set a context attribute in the button's action handler, say "UpdateView", and query and reset it inside method wdDoModifyView().
void wdDoModifyView(...)
{
if (wdContext.currentContextElement().getUpdateView())
{
/* modify view as needed */
wdContext.currentContextElement().setUpdateView(false);
}
}
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.