Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to add a string after a data binding feed?.

Avatar

Level 3

Hi, let say I got a field that is data driven, and I want to add something, for example, a - character after.

So, instead of showing "Field Value", it should show "Field Value -".

How can I add the "-" after the data driven value?.

(I've tried + "-" and some stuff like that without success)

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Is there a relationship between the element bound to the rawValue and the element you want bound to the caption.  Something like;

<accountDetail>

<productName>Test</productName>

<productQty>3</productQty>

</accountDetail>

So if the rawValue is bound to productQty then the following code in the initialise event will set the caption value;

this.caption.value.text.value = this.dataNode.parent.productName.value + "-";

this.dataNode refers to the element the rawValue is bound to, so this.dataNode.parent refers to accountDetail, etc.

Regards

Bruce

View solution in original post

13 Replies

Avatar

Level 10

on what event are you trying to do this? the exit event?

Avatar

Level 10

mhmmm, you are using javascript?? cuz using the operator '+' should be working if you are using it this way:

var strField = textField15.rawValue + "-";

if you are trying to change the value directly, use the operator '+='

TextField15.rawValue += "-";

Avatar

Level 3

I've tried that in the caption property of the text field, but it's not working (it works in the rawValue though)

I've tried this:

this.caption.value += " -";

or this:

this.caption.value = caption.value + " -";

Neither worked.

Avatar

Level 8

How about in the initialize event of your field:

this.rawValue = this.dataNode.value + " - ";

Kyle

Avatar

Level 3

But, rawValue always is related with the value of the text field, not with the caption. I need to alter the caption.

Avatar

Level 8

To alter a caption you would use this.caption.value.text.value.

Kyle

Avatar

Level 3

That works, but it copies the same value into the field .

Avatar

Level 8

So, let's clear some things up. You want a value from a data binding to go into your caption with some added hard coded text?

If so, what's the data binding string itself ($.MyData.CaptionCollection.Caption)? Do you use dynamic properties?

Kyle

Avatar

Level 3

Yes, I want the caption of the text field to contain a text from my data source + a hardcoded string, in this case, a "-".

The binding is something like accountDetail.productName.

Not sure what you mean by dynamic properties, I set this value clicking in the gree caption text link thingy and then I searched for my source of data.

Avatar

Correct answer by
Level 10

Hi,

Is there a relationship between the element bound to the rawValue and the element you want bound to the caption.  Something like;

<accountDetail>

<productName>Test</productName>

<productQty>3</productQty>

</accountDetail>

So if the rawValue is bound to productQty then the following code in the initialise event will set the caption value;

this.caption.value.text.value = this.dataNode.parent.productName.value + "-";

this.dataNode refers to the element the rawValue is bound to, so this.dataNode.parent refers to accountDetail, etc.

Regards

Bruce

Avatar

Level 3

Bruce, hi, that works, but I'm having the same problem as before, it changes also the dataField rawValue also.

So, instead of having:

"My product name": value

I end up having

"My product name": "My product name"

It is like the caption value is copied to the field value.

Avatar

Level 3

Nevermind, it worked if I put that code in the initialize event.. weird, I wonder why.

I guess I have to long way still ahead to learn how Designer works .

Thanks Bruce!.