on 03-12-2009 12:55 AM
Hello,
I am trying to retrieve the names of all the user elements in a view at runtime within the wdDoModifyView method of that view. Does anyone have suggestions on how to accomplish this?
Thanks
Josh
Hi...
if want to retrieve element name from view then you have to some piece of code has to follow..
view==it is available in your doModifyview as parameter
public static void wdDoModifyView(IPrivateChildView wdThis, IPrivateChildView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
IWDViewElement ele=(IWDViewElement)view.getElement("id");
IWDInputField elin=(IWDInputField)view.getElement("id of i put");
IWDDropDownByKey dr=(IWDDropDownByKey)view.getElement("id of drop down");
//if get element any othe method...
view=view;
}
if you want to declare any other method you have to asign view parameter to gobal declarartion
like--- static IWDview view=null
just start search with IWD....(elementname)//you will get element name...
Thanks
Sjati
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Thank you for your answers. Here is what I am trying to do. I need to look through a view and enable and disable elements based upon permissions I have from a backend source. Rather than binding each elements enabled property to a context on everyview and setting it that way, it would be more effecient to do it programmatically and bind this property at run time. Does anyone have any sample code on how do to the reflection? Unfortunatly I do not have the book readily available.
Josh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Josh,
If you have to do it dynamically at runtime, then you have to anyways access the UI element object.
There is no other alternative. And if you are accessing the Ui element then you can use this code:
//For Input field
((IWDInputField)view.getElement("InputField_ID")).setEnabled(true);
// For Table
((IWDTable)view.getElement("Table_ID")).setEnabled(true);
// For CheckBoxes
((IWDCheckBox)view.getElement("CheckBox_ID")).setEnabled(true);
// For TextView
((IWDTextView)view.getElement("TextView_ID")).setEnabled(true);
Similarly you can do it for otehr UI elements. If you want any other help please let me know.
Thanks and Regards
Pravesh
What is the use case?
In Chris Whealy's book "Inside Web Dynpro for Java" you can find an algorithm to traverse any UI element hierarchy using reflection.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Josh
Please clear it what u want to retrieve : UI Element or All Logged in User ?
As definition of the weDoModify Hook Method
This method conceptually belongs to the view itself, not to the
* controller (cf. MVC pattern). The Web Dynpro programming model recommends that UI elements can only be accessed by code executed within the call to this hook method.
*
* @param view
* The view's generic API, as provided by Web Dynpro. Provides
* access to UI elements.
* @param firstTime
* Indicates whether the hook is called for the first time during
* the lifetime of the view.
*/
So this method is good for Dynamic generation of the UI Element and binding of the class to the context which is there for complete life cycle like TableSorter and TableFilter.
What u want to achieve? Explain the scenario .
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Josh,
You can use following code for getting the arraylist of all Ui elements under the parent UI container.
IWDUIElement[] uiElementList = ((IWDTransparentContainer)view.getElement("RootElement")).getChildren();
Please note that I have used "RootElement". Here by default the Root UI element will have this name.
However If you change the name of the root UI element then you have to use that particular name of Root UI Transparent container in this code snippet.
I hope this will solve your issue. Please revert back if you have any issues.
Thanks and Regards,
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
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.