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

Reply via email to