Output values using DropDownMultiple in DB template

Hi,

I am trying to output a list of values from the dropdownmultiple control in the binding section for the DB template.

I have looked at some of the threads and tried number methods like that

#foreach($foo in $sys.item.getProperty(“DDMfieldName”).getValues())
$foo.String
#end

but I am getting the error below in the debugging mode.

Problem parsing expression: #foreach($foo in $sys.item.getProperty(“rx:DDMfieldName”).getValues()) $foo.String #end reported problem: Lexical error at line 1, column 2. Encountered: “f” (102), after : “#”

Is the expression Editor won’t able to compile the # symbol? or there is a specifc way to define in the Bindings for outputting a list of values?

Cheers

F

In the bindings, you use JEXL syntax not Velocity syntax.

http://commons.apache.org/jexl/reference/syntax.html

If this case, re-write your loop as:

foreach($foo in $sys.item.getProperty("rx:DMfieldName").getValues())
{$foo.String}

This won’t do much (it will just return the last value in DMfieldName), but it should parse.

Dave

Thanks Dave

I have followed the URL and tried to use the following but the JEXL still wouldn’t output the list of values.



x; foreach($foo in $sys.item.getProperty("rx:DMfieldName").getValues())
{x = x + $foo.String;} x;


but it works ok to output a single value using the following.



foreach($foo in $sys.item.getProperty("rx:DMfieldName").getValues())
{x = $foo.String;}x;


Is it something across to you before? or Am I missing something?

Read this thread: http://forum.percussion.com/showthread.php?t=2022

Your situation is slightly different (it’s not a child table), but the same issues will occur.

Dave

Sorry, I don’t quite understand and I probably being thick. In my db template, I won’t have a slot associated with it so I won’t be able to use any methods related to the slot.

I have spent sometimes playing with it and tried quite a few methods using the $user.psoListTools.asList but I still no joy.

For both methods, I am still getting either a list or array data type returned and I need to get all the values into a string format probably with a comma separater. I just find it strange that we couldn’t use a variable with and increment symbol like a plus sign.

Is it possible if you could provide me some more information or may be a sample code?

Many thanks,

Friendy

Has anyone managed to get the values from sys_DropDownMultiple control and concatenate it into a single string within jexl binding (essentially what Friendy was going for here)? Or is it even possible?


$x = $user.psoStringTools.getStringBuilder();
foreach($foo in $sys.item.getProperty("rx:DMfieldName").getValues()) {
    $x.append(', ').append($foo);
}
$x = $x.toString();
if($x.length() > 0) {$x = $x.substring(2);}
$x

If you don’t have PSOToolkit installed, you can replace the first line with:


$x = $sys.getClass().forName('java.lang.StringBuilder').newInstance();

Thanks Sam, but unfortunately it still throws an error if I try using below code.

Could not find method append for object [, ] and arguments [com.percussion.utils.jsr170.PSStringValue@1c53259[m_value=TBD,m_strValue=]]

oops!

That line should be:


$x.append(', ').append($foo.String);

Perfect! That works. :smiley:
Appreciate your help.