Re: [xwiki-users] Macro Parameter as Array

2016-04-03 Thread Vincent Massol

> On 03 Apr 2016, at 02:02, Personal  wrote:
> 
> Is it possible to pass an array as a macro parameter? So far my attempts have 
> failed.

no, it’s not really possible to pass typed parameters to macros in wiki syntax.

However, if the macro is written in Java and it expects a List, and you 
pass a comma-separated list, XWiki will convert the string to List 
automatically. Example:

{{someMacro listParam=“val1, val2, val3”/}}

This is not possible in a wiki macro though.

Thanks
-Vincent

> Macro code:
> #set( $a = $xcontext.macro.params.array)
> $a
> 
> #foreach($i in $a)
>  $i
> #end
> 
> 
> Page code:
> #set( $array = ['Chapter 1', 'Chapter 2', 'Chapter 3'])
> $array
> 
> #foreach($i in $array)
>  $i
> #end
> 
> {{test array=$array/}}
> 
> 
> The array processed in the page works as expected. The array passed to the 
> macro only prints up to the first space between Chapter and 1. I have also 
> tried to enter the array as a string which passes the string but the macro 
> does not treat it as an array, which doesn’t surprise me. The comments from 
> Stefan and Vincent on 
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/WikiMacroTutorial seem to 
> touch on this issue but I do not understand the answer provided. Thank you 
> for any clarification to this issue you can provide.
> 
> Regards,
> 
> Jesse Bright
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] DBLists and Relational Storage

2016-04-03 Thread Peter Huisman
Hi,

A few short questions:

What is the storage limit when NOT using Relational Storage for each selected 
item? - I assume this is 255 but I’m not sure.
What is the storage limit when NOT using Relational Storage for all selected 
items in total? - I do not know what to make of this.

The only reference I could find is a quote in an XWiki-devs mail in 2011:

> Make sure you select the Multiple Select and Relational Storage
> checkboxes. Multiple Select allows you to select and store multiple
> values from the list, while Relational Storage makes it easier to
> integrate that property into other queries by storing each selected item
> in its own entry in the database (without it all the selected values are
> stored in one row, concatenated into a VARCHAR column), and to store
> more than a few selected values (since the column allows at most 255
> characters in total).
With kind regards,

Peter
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Macro Parameter as Array

2016-04-03 Thread Thomas Mortagne
On Sun, Apr 3, 2016 at 11:20 AM, Thomas Mortagne
 wrote:
> What you need to keep in mind is that {{test}} is wiki syntax, it's
> not a Velocity/Java API. You print it with Velocity, you don't call
> it. So this is all text until the wiki parser parses it, to pass an
> array you need to serialize it with the right syntax.
>
> A good way to understand and debug that is to disable wiki parsing in
> your Velocity macro as in {{velocity wiki="false"}}. This will gives
> you exactly what the wiki parser gets in input.
>
> The problem you have in your example is that you end up with something like:
>
> {{test array=[Chapter 1, Chapter 2, Chapter 3]/}}
>
> and indeed without "" the parser will start at first white space it hits.

s/start/stop/

>
> All that is mostly for Java based macros (1). One limitation of wiki
> based macros is that they don't have any automatic parameters
> conversion and they just get all parameters as String, then you parse
> it in your macro content (see
> http://jira.xwiki.org/browse/XWIKI-13282).
>
> 1: http://rendering.xwiki.org/xwiki/bin/view/Main/ExtendingMacro
>
> On Sun, Apr 3, 2016 at 2:02 AM, Personal  wrote:
>> Is it possible to pass an array as a macro parameter? So far my attempts 
>> have failed.
>>
>> Macro code:
>> #set( $a = $xcontext.macro.params.array)
>> $a
>>
>> #foreach($i in $a)
>>   $i
>> #end
>>
>>
>> Page code:
>> #set( $array = ['Chapter 1', 'Chapter 2', 'Chapter 3'])
>> $array
>>
>> #foreach($i in $array)
>>   $i
>> #end
>>
>> {{test array=$array/}}
>>
>>
>> The array processed in the page works as expected. The array passed to the 
>> macro only prints up to the first space between Chapter and 1. I have also 
>> tried to enter the array as a string which passes the string but the macro 
>> does not treat it as an array, which doesn’t surprise me. The comments from 
>> Stefan and Vincent on 
>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/WikiMacroTutorial seem to 
>> touch on this issue but I do not understand the answer provided. Thank you 
>> for any clarification to this issue you can provide.
>>
>> Regards,
>>
>> Jesse Bright
>> ___
>> users mailing list
>> users@xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/users
>
>
>
> --
> Thomas Mortagne



-- 
Thomas Mortagne
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Macro Parameter as Array

2016-04-03 Thread Thomas Mortagne
What you need to keep in mind is that {{test}} is wiki syntax, it's
not a Velocity/Java API. You print it with Velocity, you don't call
it. So this is all text until the wiki parser parses it, to pass an
array you need to serialize it with the right syntax.

A good way to understand and debug that is to disable wiki parsing in
your Velocity macro as in {{velocity wiki="false"}}. This will gives
you exactly what the wiki parser gets in input.

The problem you have in your example is that you end up with something like:

{{test array=[Chapter 1, Chapter 2, Chapter 3]/}}

and indeed without "" the parser will start at first white space it hits.

All that is mostly for Java based macros (1). One limitation of wiki
based macros is that they don't have any automatic parameters
conversion and they just get all parameters as String, then you parse
it in your macro content (see
http://jira.xwiki.org/browse/XWIKI-13282).

1: http://rendering.xwiki.org/xwiki/bin/view/Main/ExtendingMacro

On Sun, Apr 3, 2016 at 2:02 AM, Personal  wrote:
> Is it possible to pass an array as a macro parameter? So far my attempts have 
> failed.
>
> Macro code:
> #set( $a = $xcontext.macro.params.array)
> $a
>
> #foreach($i in $a)
>   $i
> #end
>
>
> Page code:
> #set( $array = ['Chapter 1', 'Chapter 2', 'Chapter 3'])
> $array
>
> #foreach($i in $array)
>   $i
> #end
>
> {{test array=$array/}}
>
>
> The array processed in the page works as expected. The array passed to the 
> macro only prints up to the first space between Chapter and 1. I have also 
> tried to enter the array as a string which passes the string but the macro 
> does not treat it as an array, which doesn’t surprise me. The comments from 
> Stefan and Vincent on 
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/WikiMacroTutorial seem to 
> touch on this issue but I do not understand the answer provided. Thank you 
> for any clarification to this issue you can provide.
>
> Regards,
>
> Jesse Bright
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users



-- 
Thomas Mortagne
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users