on 09-19-2008 11:49 AM
Hi Colleagues,
I am new to WebDynpro.
I am facing an issue with "DropDownByKey" UI Element.
The scnario is:
1) There are 15 number of "DropDownByKey" UI Elements to be displayed on a page with the same data (time intervals).
One approach to achieve this would be:
1) Create a 15 attributes of simple data type and enter options in
enumerations.
2) Now bind each of these simple data types to all the 15 DropdownByKey elements.
The second approach could be:
1) Create a node with attribute type string.
2) Write functionality to add values to this attribute.
3) Create instances of Node.Attribute.
4) Bind these instances to individual 15 DropdownBykeys elements.
Please tell me which one of the two approaches would be better or if there is any other better approach.
In case, if the second appraoch is better, how to achieve this?
Thanks & Regards,
Ankit.
Hi,
Create one SimpleType in Dictionaries with time data .
Then use Dynamic programming to achieve your need
in wdDomodifyView() method, write following code
wdContext.getContext().reset(false);
IWDTransparentContainer tc= (IWDTransparentContainer)view.getElement("RootUIElementContainer");
tc.destroyAllChildren();
for(int i=0;i<15;i++)
{
wdContext.getNodeInfo.addAttribute("attr"+i,"<SimpleTypePackage>.<SimpleTypeName> ");
}
for(int k=0;k<15;k++)
{
IWDDropDownByKey ddk=(IWDDropDownByKey)view.createElement(IWDDropDownByKey.class,"ddk");
ddk.bindSelectedKey("attr"+k);
tc.addChild(ddk);
}
Regards
LN
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you all.
Your replies were really helpful in resolving the issue.
The question has been answered now.
Best Regards,
Ankit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
follow below steps,
1.create one simple type which holds required values
2.create 15 value attributes of type simple type.
3.bind with DropDownByKey.
it is easy way to achieve your requirement.
Regards,
ramesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suggest first option because we may select different value in each dropdown.
If we maintain only one attribute to all dropdown elements selected value will be same for all dropdowns
Let me know if you need more clarifications
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Below way you can set values to a dropdown by key without using enumaration(your 2nd approcah) .
/*Setting the Dropdown/
IWDAttributeInfo info_propno =wdContext.nodeVn_From1NoOfPropsDropDown().getNodeInfo().getAttribute("Va_F1noOfProps");
ISimpleTypeModifiable mod_propno =
info_propno.getModifiableSimpleType();
IModifiableSimpleValueSet svs_propno =
mod_propno.getSVServices().getModifiableSimpleValueSet();
String strcount=null;
for (int count = 0;count<
form1List.size();//wdContext.currentVn_FormDetailsElement().getVa_Form1List().size();
count++) {
strcount=""(count1);
svs_propno.put(strcount,strcount);
strcount="";
}
/** End of Setting the Dropdown*/
Note : If you use a dropdown element and if you dont assign a context variable to it, you will get a null pointer exception.
Regards,
Srinivas.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can achieve it.
if you can see the code, in the for loop for setting the key value pair,
we are doing a
svs.put(key,vlaue);
Now make this dynamic like
String reqKey=null;
String reqVal=null;
If(requirement1)
{
reqKey="requirement1 keys";
reqVal="requirement1 values";
}
If(requirement2)
{
reqKey="requirement2 keys";
reqVal="requirement2 values";
}
Now
svs.put(reqKey,reqVal);
Regards,
Srinivas.
Hi Srinivas,
Thanks for your valuable suggestions.
The requirement over here is to:
1) Create 15 instances of attributes containing the same values.
2) And then assign one by one each of these instances to each of the 15 UI Elements.
Please let me know how to do it (Dynamically binding the attribute instances to the DropdownByKey UI Elements)?
Thanks & Regards,
Ankit.
Ankit,
Here is how you can achieve what you want to do.
public static void wdDoModifyView(IPrivateMulti_DropDownCompView wdThis, IPrivateMulti_DropDownCompView.IContextNode wdContext,
com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if(firstTime)
{
for(int i=1; i<=15; i++)
{
IWDDropDownByKey theDropDown = (IWDDropDownByKey) view.getElement("DropDownByKey"+i);
IWDAttributeInfo att1 = wdContext.nodeDDNode().getNodeInfo().addAttribute("DD"+i+"Data",
"ddic:com.sap.demo.multi_dropdowns.DataValue");
theDropDown.bindSelectedKey(att1);
}
}
//@@end
}
The assumption here are
1. Your DropDownByKey element ids are DropDownByKey1 through DropDownByKey15.
2. You have an independent node DDNode with cardinality 0..n
3. You have one simple type DataValue with required enumeration created under path com.sap.demo.multi_dropdowns
This works fine and different values can be selected for separate DropDownByKey elements.
Having said this, I am not sure why you want to do this dynamically when this can be achieved easily by creating 15 attributes of a simple type 'DataValue' and binding them to your DropDownByKey elements at design time. I hope you are not getting confused among 15 attributes and 15 elements as binding an element to DropDownByKey is not possible (as far as I know).
It is better to construct as much of the view layout as possible at design time to keep things simple for you and later for people supporting the application.
Anyway, you have both the options now :-). Take your pick.
Hope this helps.
Vishwas.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.