[ 
https://issues.apache.org/jira/browse/PIVOT-573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12888539#action_12888539
 ] 

Michael Allman commented on PIVOT-573:
--------------------------------------

First, the latter two alternatives require a ZipCodeValidator class, no?  I'm 
avoiding that intentionally, but generally speaking I don't think it's a fair 
assumption that the user is working with a named class.

With that out of the way, let me get to the meat of my argument.  First, I like 
the following alternative even better:

<TextInput validator="$validator">
  <wtkx:script>
    var validator = Packages.ms.allman.pivot.Validators.getZipCodeValidator();
  </wtkx:script>
</TextInput>

So I'm going to go with that as the best alternative.  My primary motivation in 
promoting this feature was succinctness.  I think it's undeniable that the 
proposed syntax is more succinct than the alternative—not just in terms of 
characters but in the sense that no intermediate variable need be defined.  I 
also think it's a valuable and natural feature in its own right.  Why should 
"$" expressions be limited to variable references when it's easy to support 
general expressions?  Also, this is a backwards compatible feature—no harm done 
there.  In fact, I don't see how this feature does any harm to the status quo.  
The only thing I can think of is that this requires more CPU cycles, but first 
I'm not sure that's really significant given the usage of WTKX and second does 
that really outweigh the benefits of this feature?

If we keep the status quo, then all expressions used in an attribute have to be 
assigned to a variable first.  The only reason for that variable's existence is 
due to a limitation in the status quo.  I think this obfuscates the true intent 
of the user here—to assign the value of a property to the value of a script 
expression.

Finally, as regards the patch issue, I didn't mean to suggest this should go 
into 1.5.x.  That's just what I'm working from and I wanted to get the ball 
rolling on a discussion of this feature.  If you want to include it, I can work 
on a patch for trunk.

Hmmm... now I feel like I'm forgetting something else I wanted to say but it's 
not coming to me.  Oh well.  Maybe in a future comment.

> Execute script expressions in WTKX component attributes
> -------------------------------------------------------
>
>                 Key: PIVOT-573
>                 URL: https://issues.apache.org/jira/browse/PIVOT-573
>             Project: Pivot
>          Issue Type: New Feature
>          Components: wtk-wtkx
>    Affects Versions: 1.5
>         Environment: Using patched Pivot 1.5
>            Reporter: Michael Allman
>         Attachments: script_expressions_in_attributes.patch
>
>
> The attached patch allows users to put arbitrary script expressions in wtkx 
> component attributes.  This provides a superset of existing functionality, 
> which allows the user to reference an object by its wtkx:id.
> For example, I have a Java class ms.allman.pivot.Validators with a static 
> method getZipCodeValidator() that returns a Validator.  Then the following 
> WTKX fragment sets a zip code validator on the given TextInput:
> <TextInput 
> validator="$Packages.ms.allman.pivot.Validators.getZipCodeValidator()"/>
> (This example assumes the use of the JavaScript engine for scripting.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to