cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenating context value and non-context value

Former Member
0 Kudos

Hi,

I have a context binding to one of the input field(lets say field-X) and also I have another dropdown list UI element(lets say field-Y) which is not bound to any context. When a user enters values in field-X and selects a item from field-Y hits the save button, I need to concat "Field-X - Field-Y" and assign this concatenated value to field-X context. So in a road-map (next screen) when I retrieve field-X context value it should have concatenated value of dropdown UI element as well.

Where do I do this concat (I mean which method e.g. WDModify) and how do I do it?

Thanks

Praveen.

Accepted Solutions (1)

Accepted Solutions (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Praveen,

What do you mean by field-Y is not bound to any context?? I am sure you would have atleast bound the selectedKey property of the dropdown list with some attribute of the context.

For concatinating the fileds you have to write the code on the onAction function of Save button which is taking you to the next screen of the road map. On the onActionSave() you have to get the values of the currently selected input field and the dropdown value. Then you have to concatenate the values and set it in some attribute from where you can pick it in the next screen.

Please use this code in onActionSave() method:


// Get the value of the currently entered value of the input field from the attribute which is bound to the input field. I am assuming the name of the attribute as InputFiledValue
String inpValue = wdContext.currentContextElement().getInputFiledValue();
// Get the value of the currently selected value of the drop down field from the attribute which is bound to the drop down field. I am assuming the name of the attribute as DropDownValue
String dropDpwnValue = wdContext.currentContextElement().getDropDownValue();
	  
// Concatenate with "-" in between
String concatenatedValue = inpValue+ " - " + dropDpwnValue;
	  
// Set the concatenated value to a temporary attribute. This will be accessed in next view of road map. 
wdContext.currentContextElement().setConcatenatedValue(concatenatedValue);

// OR if you want to save in same inputfield Attribute then also you can do that.
// use the similar code as above. see this:
// wdContext.currentContextElement().setInputFiledValue(concatenatedValue);

Here I am assuming that the attribute which have bound to the inputfield and dropdown field are directly under the context node. If not then you have to get the values from a specific node. Do it like this:


// Get the value of the currently entered value of the input field from the attribute which is bound to the input field. 
String inpValue = wdContext.current<NODE_NAME>Element().getInputFiledValue();
// Get the value of the currently selected value of the drop down field from the attribute which is bound to the drop down field.
String dropDpwnValue = wdContext.current<NODE_NAME>Element().getDropDownValue();

In the next view you can get this concatenated value and can use whereever you want. Use following code:


// To get the value of the concatenated string.
String value = wdContext.currentContextElement().getConcatenatedValue();

I hope this solves the issue. Please revert back in case you need any furtehr help on this.

Thanks and Regards,

Pravesh

Former Member
0 Kudos

Hi Pravesh,

Thanks for your coding and explanation. When I mean no context binding for dropdownlist, I have a scenario to customise one of the XSS package, where I need to introduce dropdown list which is not bound to any infotype in the backend but I have to concat this dropdown list selected value to one of the existing inputfield UI element.

The dropdown list is going to have a list of simple data type (enumeration) defined on the WebDynpro.

You are saying I can also bind it to the context controller so I can use the dropdown selected value anywhere in the roadmap.

Thanks

Praveen.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

For example if you have the context and UI elements as below:

ValueX (Context Attribute under Root node) -- Binded to InputField UI element.

ValueY(Context Attribute under TestDropDownNode) -- Binded to DropDownByIndex UI element.

Now in onActionSave() write the below code:


String valuex=wdContext.currentContextElement().getValueX();
valuex+=wdContext.currentTestDropDownNodeElement().getValueY();
wdContext.currentContextElement().setValueX(valuex);

Note for example if the DropDown is DropDownByKey and Cotnext type of SimpleType(enumeration) is binded to that: For example that context attribute is ValueY(Directly under Root node).

Then change the above code as below:


String valuex=wdContext.currentContextElement().getValueX();
valuex+=wdContext.currentContextElement().getValueY();
wdContext.currentContextElement().setValueX(valuex);

Regards,

Charan

Former Member
0 Kudos

Hi,

You can do this concatenation & assignment of this to Field-X context attribute in the Action method created for SAVE Button.

Regards

Shruti