on 12-19-2008 3:15 PM
Hi All,
I am having a string value that is generated after I do some validations.I want to add this string value in my drop down by key.Can anyone help me on this.
Thankx,
Naaz
Hi Gayatri,
This is the code I am writing:
List list = new ArrayList();
IWDAttributeInfo a1=wdContext.getNodeInfo().getAttribute(IPrivateWDSampleView.ISumElement.Sum);
ISimpleTypeModifiable stm1=a1.getModifiableSimpleType();
IModifiableSimpleValueSet svs1=stm1.getSVServices().getModifiableSimpleValueSet();
for(int i =0;i<10;i++)
{
list.add(i,sum);----
>Adding the value of sum here in the first index but again if I change the input field values and try to add it this value sum is getting overridden.
}
for(int i =0;i<list.size();i++)
{
svs1.put(""+i,list.get(i));
}
Thankx,
Naaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I was able to add sum of two inputfield values in DropDownByKey element without overwriting anything. I did not populate the 3rd inputfield but that should be easy. My setup was:
DropDownByKey UI Element
id----
DropDownByKey1
selectedKey----
DDNode.Datavalue
Context:
Root
-
DDNode (Independent Node)
-
Datavalue(Attribute of type DataValue(Dictionary SimpleType) having String Values )
-
Value (Independent Attribute of String type to contain first entered value)
-
Value2 (Independent Attribute of String type to contain second entered value)
View
View had 2 inputField UI elements bound to Value and Value2 attributes in context. It also had a button which fired action onActionAddValue.
public void onActionAddValue(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionAddValue(ServerEvent)
IWDAttributeInfo infoShare_property = wdContext.nodeDDNode().getNodeInfo().getAttribute("Datavalue");
ISimpleTypeModifiable modShare_property = infoShare_property.getModifiableSimpleType();
IModifiableSimpleValueSet svsShare_property = modShare_property.getSVServices().getModifiableSimpleValueSet();
//We need to put value and Description in Dictionary Simple Type enumeration.
//Moreover, description part is visible in DropDownByKey UI Element so we made sure that
//value and description are same.
svsShare_property.put((Integer.toString(Integer.parseInt(wdContext.currentContextElement().getValue()) + Integer.parseInt(wdContext.currentContextElement().getValue2()))),(Integer.toString(Integer.parseInt(wdContext.currentContextElement().getValue()) + Integer.parseInt(wdContext.currentContextElement().getValue2()))));
//@@end
}
It worked well for me and should work for you too.
Vishwas.
Hi All,
Thankx a lot for the help.My issue has been resolved.
Thankx,
Naaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Hi All,
>
> I am having a string value that is generated after I do some validations.I want to add this string value in my drop down by key.Can anyone help me on this.
>
> Thankx,
> Naaz
Hi Naaz,
This is the code I am writing:
List list = new ArrayList(); Place this line after //@@begin others
IWDAttributeInfo a1=wdContext.getNodeInfo().getAttribute(IPrivateWDSampleView.ISumElement.Sum);
ISimpleTypeModifiable stm1=a1.getModifiableSimpleType();
IModifiableSimpleValueSet svs1=stm1.getSVServices().getModifiableSimpleValueSet();
for(int i =0;i<10;i++)
{
list.add(i,sum);----
>Adding the value of sum here in the first index but again if I change the input field values and try to add it this value sum is getting overridden.
}
for(int i =0;i<list.size();i++)
{
svs1.put(""+i,list.get(i));
}
Thankx,
Naaz
That is what Iam mentioning in the last two threads dont declare the list in the method.
If you declare the list in the method it will get overloaded.
Declare it globally.(Place it at the end of view.java class)
i.e. //@@begin others
List list1 = new ArrayList();
//@@end
Regards,
Gayathri.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you tell me where you have declared the list.
declare the list here:
//@@begin others
List list1 = new ArrayList();
//@@end
Regards,
Gayathri.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gayatri,
Ya now I am able to add it in the list but now if i change the "c" value i mean now if i add new a and b values.I am not able to add it in the list its getting overridden.Can u please help me in this.
Thankx,
Naaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Declare the list globally.
i.e at @begin others.
List ddList = new ArrayList();
In the populateVaules method i think you will be getting the values.
For Eg.
int a=10;
int b=10;
int c= a+b;
ddList.add(c);
Like this you can add the reult value to the list.
Regards,
Gayathri.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gayatri,
Thankx for the reply.You told in the first step that:
"Add those two input parameters and place the result value in the list."
I am not able to add it in the list.Can you help me on that.
Thankx,
Naaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think already you have populateValues method to display the values to the dropdown. In that method do the following modifications.
First check the inpu parameters are integers and are not null.
Create an ArrayList and add the elements to that list.
List list = new ArrayList();
Add the elements that are present in the drop down to the list.
1. Add those two input parameters and place the result value in the list.
2. IWDAttributeInfo a1=wdContext.getNodeInfo().getAttribute(IPublicNewTestComp.IContextElement.DDBYKEY);
ISimpleTypeModifiable stm1=a1.getModifiableSimpleType();
IModifiableSimpleValueSet svs1=stm1.getSVServices().getModifiableSimpleValueSet();
// Insert a for loop that will iterate till the lastIndex of the arrayList.
svs1.put(""+i,list.get(i)); // Since key is String converting integer to string.
3. Call this method when ever you are adding the input parameters.
Regards,
Gayathri.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swathi,
Yes I want to set the sum value to it.Again if I enter new values to the inputfields I need to get the new result value and also the old value should also be populated in the dropdown.
Thankx,
Naaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swathi,
They are inputfields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Thankx for the quick replies.I am getting the value of the string at runtime thats the reason why I am not using enumeration.I have created a simple type and binded it to my attribute but I didnt add any values in the enumeration.
In my case I have to get the string value each time it changes and populate the values to the drop down.
This is the scenerio:
I have created two atrributes say attr1 and attr2.In attr3 attribute I binded it with my simple type.Now if I add attr1 and attr2 I am setting their sum value to attr3 value to it and populating this to my drop down.Now again i give different values to my attr1 and attr2 and again when i add them i will set the new value to attr3 and I want to populate this value to my drop down without overridding the previous value.Is this possible??
Thankx,
Naaz
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 do that by creating a Context Node which has your Context Attribute bound to the simple type created. And write this piece of code inside wdModifyView(),
public static void wdDoModifyView(IPrivateAdminView wdThis, IPrivateAdminView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if (firstTime) {
}
IModifiableSimpleValueSet dropdownvalues =
wdContext
.node<Node_Name>()
.getNodeInfo()
.getAttribute("attribute_name")
.getModifiableSimpleType()
.getSVServices()
.getModifiableSimpleValueSet(); // get modifiable simple type
//Set the value of attr3 before you actually do the following
attrValue = wdContext.current<Node_Name>element().get<attribute_name>();
dropdownvalues.put( str1 , attrValue ); // ( KEY, VALUE) set values
//@@end
}
Regards
Kishan
Edited by: kishan chandranna on Dec 22, 2008 8:18 AM
Hi Ghousia,
Follow the below steps,
Creation of a Simple-Type
1) Create a simple-type (choose the name according to your application) - Dictionaries -> Local Dictionary -> Data Types->Create simple type.
2) Choose the Enumeration tab page.
3) To add a new enumeration, choose New.
4) Under Enumeration Value, enter a value. Under Enumeration Text, enter some appropriate text.
Choose Finish to confirm.
5) Repeat steps 3 and 4 to create more enumerations.
6) Switch to the Representation tab page.
7) Under Field Label, enter an appropriate name.
😎 Under Quick info, you can give a tool-tip if needed.
Creation of a Context Attribute
1) Create a context attribute under the context-menu for your view where you need the drop-down.
2) On the Properties Page of the created attribute, choose the box at the end to open the
dialog for selecting the simple type for the type property.
3) Then, select Dictionary Simple Type and choose Dictionaries -> Local Dictionary ->
<package_name>.simpletypes. Choose the name of the simple type you just created and confirm
by choosing OK.
Completion of the View Layout
1) In the Outline tab of your view layout, select the drop-down that you have created. Switch to the Properties tab of the drop-down UI element
2) Set the selectedKey property to the Context attribute you just created.
If you have followed the above 3 steps, you will be getting a drop-down list which has as many values as the Simple Type created.
Regards
Kishan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Create a method in Component controller called populate value
write code like this in side that
public void populateValues( )
{
//@@begin populateValues()
try
{
/*****POPULATING DROPDOWN BY KEY**********/
IWDAttributeInfo a1=wdContext.getNodeInfo().getAttribute(IPublicNewTestComp.IContextElement.DDBYKEY);
ISimpleTypeModifiable stm1=a1.getModifiableSimpleType();
IModifiableSimpleValueSet svs1=stm1.getSVServices().getModifiableSimpleValueSet();
svs1.put("1","One");
svs1.put("2","Two");
/**************************************/
catch(Exception e)
{
msgMngr.reportException("In populateValues "+e,false);
}
//@@end
}
Call that method in the view init method like this
wdThis.wdGetNewTestCompController().populateValues();
This code may help u a bit.
Regards,
H.V.Swathi
at design time:
create dictionary simple Data type and fill enumeration (key - value) pair
or
at runtime:
IModifiableSimpleValueSet dropdownvalues =
wdContext
.node<Node_Name>()
.getNodeInfo()
.getAttribute("attribute_name")
.getModifiableSimpleType()
.getSVServices()
.getModifiableSimpleValueSet(); // get modifiable simple type
dropdownvalues.put( str1 , str1 ); // ( KEY, VALUE) set values
nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gopi,
I am able to set the value to the dropdown but if i change the value of my string I need to get it as the second value in the drop down but my first value is getting lost each time i change my string value.Can you help me on this.
Thankx,
Naaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, I suppose you have a string attribute binded to the dropdownlist. You should have populated the attribute with some values (to show in the dropdown list) using SV services adding values to the value set associated to the attribute. If you want to add new values to the list (so you can enlarge your dropdown at runtime) you can add values to the value set. I suppose adding values will not change current selection (attribute value).
Hi,
Please check this thread.
and
Thanks,
Gopi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
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.