Dataform attributes in FlexFormPlugin RENDERFOREDIT

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dataform attributes in FlexFormPlugin RENDERFOREDIT

BramVanOosterhout
Hi all,

I found something curious whilst experimenting with the FlexFormPlugin
RENDERFOREDIT macro to do with attributes.


System.DataForms says under Attributes
------------------------------------------
Multiple attributes can be entered, separated by spaces:

| TopicTitle | text | 100 | | | H M |
------------------------------------------

When I enter
| TopicTitle | text | 100 | | | M c |

And use
%RENDERFOREDIT{ ...
  includeattr="\bc\b"
}%
the TopicTitle is not rendered.

Adding a print statement in
lib/Foswiki/Plugins/FlexFormPlugin/RenderForEdit.pm line 253:
print "253:\n IncludeAttr=$theIncludeAttr\n fieldAttrs=$fieldAttrs\n";

shows:
253:
 IncludeAttr=\bc\b
 fieldAttrs=Mc

The space separator is removed. As a consequence the match with "\bc\b" fails
and the field is not included in the render.

The workaround is simple. Use "c" as the inclusion criterium instead of "\bc\b".

But why insist on the space as separator between the attributes on the form if
the processing deliberately removes the separation in lib/Foswiki/Form.pm line
342?
--------------------------------------------------------------
    342             $field{attributes} =~ s/\s*//g if ( exists(
$field{attributes} ) );
--------------------------------------------------------------
Should the documentation say that attributes are single character values,
optionally separated by one or more spaces?

Or does Foswiki/Form.pm line 342 mistakenly remove all spaces where it only
intended to remove leading and trailing spaces?

Curious...
--
Bram van Oosterhout


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Foswiki-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/foswiki-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Dataform attributes in FlexFormPlugin RENDERFOREDIT

Michael Daum-2
Hi Bram,

good catch. For pragmatical reasons I'd simply use a comma separated list
wherever the documentation speaks of "lists" ... or rewrite the attribute check
as you proposed. In the core, those attributes have only been used to check
for a single char "h" or "m". Having multiple in there or even custom ones
like "c" as it is being used in the WikiWorkbenchContrib is rather exotic.
I also agree with your findings with regards to Foswiki/Form.pm line 342
removing _all_ spaces. Overall those attributes should be properly parsed into
an appropriate perl structure such as an %attr hash keyed by list items for
increased correctness and robustness.

Michael.

On Saturday, April 23, 2016 19:45:34 Bram van Oosterhout wrote:

> Hi all,
>
> I found something curious whilst experimenting with the FlexFormPlugin
> RENDERFOREDIT macro to do with attributes.
>
>
> System.DataForms says under Attributes
> ------------------------------------------
> Multiple attributes can be entered, separated by spaces:
>
> | TopicTitle | text | 100 | | | H M |
> ------------------------------------------
>
> When I enter
> | TopicTitle | text | 100 | | | M c |
>
> And use
> %RENDERFOREDIT{ ...
>   includeattr="\bc\b"
> }%
> the TopicTitle is not rendered.
>
> Adding a print statement in
> lib/Foswiki/Plugins/FlexFormPlugin/RenderForEdit.pm line 253:
> print "253:\n IncludeAttr=$theIncludeAttr\n fieldAttrs=$fieldAttrs\n";
>
> shows:
> 253:
>  IncludeAttr=\bc\b
>  fieldAttrs=Mc
>
> The space separator is removed. As a consequence the match with "\bc\b" fails
> and the field is not included in the render.
>
> The workaround is simple. Use "c" as the inclusion criterium instead of "\bc\b".
>
> But why insist on the space as separator between the attributes on the form if
> the processing deliberately removes the separation in lib/Foswiki/Form.pm line
> 342?
> --------------------------------------------------------------
>     342             $field{attributes} =~ s/\s*//g if ( exists(
> $field{attributes} ) );
> --------------------------------------------------------------
> Should the documentation say that attributes are single character values,
> optionally separated by one or more spaces?
>
> Or does Foswiki/Form.pm line 342 mistakenly remove all spaces where it only
> intended to remove leading and trailing spaces?
>
> Curious...
> --
> Bram van Oosterhout
>
>
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications Manager
> Applications Manager provides deep performance insights into multiple tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> _______________________________________________
> Foswiki-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/foswiki-discuss

--
-- Michael Daum Consulting
-- Wissensmanagement und Intranet-Technologie
-- https://michaeldaumconsulting.com
-- Tel: +49 (0)40 21 99 27 51

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Foswiki-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/foswiki-discuss