You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@freemarker.apache.org by Woonsan Ko <wo...@apache.org> on 2018/01/29 22:20:02 UTC

[FM3] Question on CallPlace#executeNestedContent(...)

Hi,

While implementing @form.errors directive (migrated from spring
form:errors taglib), I ended up adding 'messages' nested parameter
like the following example:

<@form.errors '*'; messages>
  <#list messages as message>
    ${message}
  </#list>
</...@form.errors>

As spring's form:errors jsp tag allows default rendering when there's
no nested body content, I found the following example doesn't look
very convenient. With 'messages' omitted, I got a template exception.

<@form.errors 'firstName'; messages /> # rendering the default error
info markups..

So, I wonder if there's a way to omit the 'messages' nested parameter.
The javadocs of CallPlace#getNestedContentParameterCount() and
#executeNestedContent() say about the possibility with less nested
parameters somehow, but I can't figure out how to make it flexible in
the directive.

Please let me know if you have any hints.

Regards,

Woonsan

Re: [FM3] Question on CallPlace#executeNestedContent(...)

Posted by Woonsan Ko <wo...@apache.org>.
On Tue, Jan 30, 2018 at 3:45 PM, Daniel Dekany <dd...@apache.org> wrote:
> Tuesday, January 30, 2018, 3:42:28 PM, Woonsan Ko wrote:
>
>> On Tue, Jan 30, 2018 at 3:45 AM, Daniel Dekany <dd...@apache.org> wrote:
>>> Monday, January 29, 2018, 11:20:02 PM, Woonsan Ko wrote:
>>>
>>>> Hi,
>>>>
>>>> While implementing @form.errors directive (migrated from spring
>>>> form:errors taglib), I ended up adding 'messages' nested parameter
>>>> like the following example:
>>>>
>>>> <@form.errors '*'; messages>
>>>>   <#list messages as message>
>>>>     ${message}
>>>>   </#list>
>>>> </...@form.errors>
>>>>
>>>> As spring's form:errors jsp tag allows default rendering when there's
>>>> no nested body content, I found the following example doesn't look
>>>> very convenient. With 'messages' omitted, I got a template exception.
>>>>
>>>> <@form.errors 'firstName'; messages /> # rendering the default error
>>>> info markups..
>>>>
>>>> So, I wonder if there's a way to omit the 'messages' nested parameter.
>>>> The javadocs of CallPlace#getNestedContentParameterCount() and
>>>> #executeNestedContent() say about the possibility with less nested
>>>> parameters somehow, but I can't figure out how to make it flexible in
>>>> the directive.
>>>>
>>>> Please let me know if you have any hints.
>>>
>>> I suppose nested content is allowed exactly if there's a nested
>>> content argument (like `; message`). So you can decide if there's a
>>> nested content argument with
>>> CallPlace.getNestedContentParameterCount(), and if there isn't, then
>>> you don't call CallPlace.executeNestedContent (but check if
>>> CallPlace.hasNestedContent() returns `true`, in which case throw a
>>> TemplateException that explains the problem), otherwise you call
>>> CallPlace.executeNestedContent with 1 nested content argument.
>>
>> Thank you so much! Now, it's very clear to me. :-)
>>
>>>
>>> Not sure if I'm missing something here. If not, what was the missing
>>> piece? That information should be added to the API docs.
>>
>> I didn't understand this quite well yesterday: "If, however, you want
>> to allow the caller to declare less parameters..."
>> In my example, the 'caller' seems to mean the directive user (who is
>> writing the directive in the template), and 'you' is I as a directive
>> implementer. I read 'caller' as the directive code itself yesterday.
>
> I don't follow this. You can call a directive. The caller is the FTL
> tag that calls it, like <@foo />. (It's entered by some user,
> obviously.) The directive itself is the called.

It's probably my problem. I was thinking too much last night. ;-)

>
>> That was my confusion. ;-)
>> Perhaps would it be okay if I change the 'caller' to 'directive/function user'?
>
> Perhaps this: "allow the directive/function call to declare less
> nested content parameters".

Thanks. I've replaced that.

Cheers,

Woonsan

>
>> Regards,
>>
>> Woonsan
>>
>>>
>>>> Regards,
>>>>
>>>> Woonsan
>>>
>>> --
>>> Thanks,
>>>  Daniel Dekany
>>>
>>
>
> --
> Thanks,
>  Daniel Dekany
>

Re: [FM3] Question on CallPlace#executeNestedContent(...)

Posted by Daniel Dekany <dd...@apache.org>.
Tuesday, January 30, 2018, 3:42:28 PM, Woonsan Ko wrote:

> On Tue, Jan 30, 2018 at 3:45 AM, Daniel Dekany <dd...@apache.org> wrote:
>> Monday, January 29, 2018, 11:20:02 PM, Woonsan Ko wrote:
>>
>>> Hi,
>>>
>>> While implementing @form.errors directive (migrated from spring
>>> form:errors taglib), I ended up adding 'messages' nested parameter
>>> like the following example:
>>>
>>> <@form.errors '*'; messages>
>>>   <#list messages as message>
>>>     ${message}
>>>   </#list>
>>> </...@form.errors>
>>>
>>> As spring's form:errors jsp tag allows default rendering when there's
>>> no nested body content, I found the following example doesn't look
>>> very convenient. With 'messages' omitted, I got a template exception.
>>>
>>> <@form.errors 'firstName'; messages /> # rendering the default error
>>> info markups..
>>>
>>> So, I wonder if there's a way to omit the 'messages' nested parameter.
>>> The javadocs of CallPlace#getNestedContentParameterCount() and
>>> #executeNestedContent() say about the possibility with less nested
>>> parameters somehow, but I can't figure out how to make it flexible in
>>> the directive.
>>>
>>> Please let me know if you have any hints.
>>
>> I suppose nested content is allowed exactly if there's a nested
>> content argument (like `; message`). So you can decide if there's a
>> nested content argument with
>> CallPlace.getNestedContentParameterCount(), and if there isn't, then
>> you don't call CallPlace.executeNestedContent (but check if
>> CallPlace.hasNestedContent() returns `true`, in which case throw a
>> TemplateException that explains the problem), otherwise you call
>> CallPlace.executeNestedContent with 1 nested content argument.
>
> Thank you so much! Now, it's very clear to me. :-)
>
>>
>> Not sure if I'm missing something here. If not, what was the missing
>> piece? That information should be added to the API docs.
>
> I didn't understand this quite well yesterday: "If, however, you want
> to allow the caller to declare less parameters..."
> In my example, the 'caller' seems to mean the directive user (who is
> writing the directive in the template), and 'you' is I as a directive
> implementer. I read 'caller' as the directive code itself yesterday.

I don't follow this. You can call a directive. The caller is the FTL
tag that calls it, like <@foo />. (It's entered by some user,
obviously.) The directive itself is the called.

> That was my confusion. ;-)
> Perhaps would it be okay if I change the 'caller' to 'directive/function user'?

Perhaps this: "allow the directive/function call to declare less
nested content parameters".

> Regards,
>
> Woonsan
>
>>
>>> Regards,
>>>
>>> Woonsan
>>
>> --
>> Thanks,
>>  Daniel Dekany
>>
>

-- 
Thanks,
 Daniel Dekany


Re: [FM3] Question on CallPlace#executeNestedContent(...)

Posted by Woonsan Ko <wo...@apache.org>.
On Tue, Jan 30, 2018 at 3:45 AM, Daniel Dekany <dd...@apache.org> wrote:
> Monday, January 29, 2018, 11:20:02 PM, Woonsan Ko wrote:
>
>> Hi,
>>
>> While implementing @form.errors directive (migrated from spring
>> form:errors taglib), I ended up adding 'messages' nested parameter
>> like the following example:
>>
>> <@form.errors '*'; messages>
>>   <#list messages as message>
>>     ${message}
>>   </#list>
>> </...@form.errors>
>>
>> As spring's form:errors jsp tag allows default rendering when there's
>> no nested body content, I found the following example doesn't look
>> very convenient. With 'messages' omitted, I got a template exception.
>>
>> <@form.errors 'firstName'; messages /> # rendering the default error
>> info markups..
>>
>> So, I wonder if there's a way to omit the 'messages' nested parameter.
>> The javadocs of CallPlace#getNestedContentParameterCount() and
>> #executeNestedContent() say about the possibility with less nested
>> parameters somehow, but I can't figure out how to make it flexible in
>> the directive.
>>
>> Please let me know if you have any hints.
>
> I suppose nested content is allowed exactly if there's a nested
> content argument (like `; message`). So you can decide if there's a
> nested content argument with
> CallPlace.getNestedContentParameterCount(), and if there isn't, then
> you don't call CallPlace.executeNestedContent (but check if
> CallPlace.hasNestedContent() returns `true`, in which case throw a
> TemplateException that explains the problem), otherwise you call
> CallPlace.executeNestedContent with 1 nested content argument.

Thank you so much! Now, it's very clear to me. :-)

>
> Not sure if I'm missing something here. If not, what was the missing
> piece? That information should be added to the API docs.

I didn't understand this quite well yesterday: "If, however, you want
to allow the caller to declare less parameters..."
In my example, the 'caller' seems to mean the directive user (who is
writing the directive in the template), and 'you' is I as a directive
implementer. I read 'caller' as the directive code itself yesterday.
That was my confusion. ;-)
Perhaps would it be okay if I change the 'caller' to 'directive/function user'?

Regards,

Woonsan

>
>> Regards,
>>
>> Woonsan
>
> --
> Thanks,
>  Daniel Dekany
>

Re: [FM3] Question on CallPlace#executeNestedContent(...)

Posted by Daniel Dekany <dd...@apache.org>.
Monday, January 29, 2018, 11:20:02 PM, Woonsan Ko wrote:

> Hi,
>
> While implementing @form.errors directive (migrated from spring
> form:errors taglib), I ended up adding 'messages' nested parameter
> like the following example:
>
> <@form.errors '*'; messages>
>   <#list messages as message>
>     ${message}
>   </#list>
> </...@form.errors>
>
> As spring's form:errors jsp tag allows default rendering when there's
> no nested body content, I found the following example doesn't look
> very convenient. With 'messages' omitted, I got a template exception.
>
> <@form.errors 'firstName'; messages /> # rendering the default error
> info markups..
>
> So, I wonder if there's a way to omit the 'messages' nested parameter.
> The javadocs of CallPlace#getNestedContentParameterCount() and
> #executeNestedContent() say about the possibility with less nested
> parameters somehow, but I can't figure out how to make it flexible in
> the directive.
>
> Please let me know if you have any hints.

I suppose nested content is allowed exactly if there's a nested
content argument (like `; message`). So you can decide if there's a
nested content argument with
CallPlace.getNestedContentParameterCount(), and if there isn't, then
you don't call CallPlace.executeNestedContent (but check if
CallPlace.hasNestedContent() returns `true`, in which case throw a
TemplateException that explains the problem), otherwise you call
CallPlace.executeNestedContent with 1 nested content argument.

Not sure if I'm missing something here. If not, what was the missing
piece? That information should be added to the API docs.

> Regards,
>
> Woonsan

-- 
Thanks,
 Daniel Dekany