You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Michael Wyraz <mi...@evermind.de> on 2013/02/06 17:37:36 UTC

Extending TriggerFragment to support "select" fields

Hi,

I'm thinking about extending "triggerfragment" to support other elements 
than checkbox or radio. First I'd like to discuss what the best way ist. 
Here is my idea:

Changes t5-formfragment.js:

- move the "observe" code to a function that distinguished between 
different element types
- add a "getValue" function that returns the actual value of the element 
depending on it's type
   - returns {value: element.checked } for radio and checkbox
   - returns {value: element.value, index: element.options.selectedIndex 
} for select boxes
- add a "evaluateValue" function that converts the value object 
described before to true or false (see below)

Changes in FragmentTrigger.java:
- add a Parameter "triggerExpression" that defaults to the javascript 
expression  "trigger.value==true"
  - other example values (e.G. for select boxes) would be:
    "trigger.index==2"
    "trigger.value=='some selectbox option value'"

It would then work the following way:

- linkTriggerToFormFragment binds to an element, potentially any element 
can be used here, in this implementation select, radio, combo
- the trigger is fired on user interaction
- var trigger=getValue(triggerelement) is called and returns an object 
that contains at least "value" (plus index for select boxes)
- the "triggerExpression" is evaluated. The result is used where 
"checked" is used in the actual implementation (including inversion if 
spec.invert==true)

The implementation is open, so any other element could be supported the 
same way. It should also be possible to add an expression for "getValue".

Let me know what you think about it. If It's fine, I'll supply patches 
to T 5.3.6

Regards,
Michael.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org