Hi Mike,

I faced the same task, I solved it using the onEvent mixin from
Tapestry 5 components -
http://87.193.218.134:8080/t5components/t5c-commons/ref/org/apache/tapestry/commons/mixins/OnEvent.html

In more detail - say you have two selects, sel1 and sel2, and you want
sel2 to be updated when sel1 changes.

Add the mixin to sel1:

...
<select t:id="sel1" t:mixins="t5components/OnEvent" event="change"
onCompleteCallback="populateSel2" />
<select t:id="sel2" />
...

In your component class, implement a method that returns the options
all in one string, seperated by some characters not otherwise used in
your labels or options. For example, you could use ";" between labels
and options, and "||" between the label - option pairs.

 @OnEvent(component = "sel1", value = "change")
    public StreamResponse selectionChanged(final YourClass parameter) {
   ... do something with parameter..
  ... build list of label - option pairs..
        for (i...) {
          pair[i] = label + ";" + option;
        }
        return new TextStreamResponse("text/html",
StringUtils.join(pairs, "||"));
   }

Tapestry type coercion works for your parameter, but the return string
you have to build yourself.

Finally, the callback function in Javascript looks like this:

function populateSel2(response) {
        document.getElementById('sel2').options.length = 0;
        // Split the response
        returnElements = response.split("||")
        // Process each of the elements
        for ( var i = 0; i < returnElements.length; i++) {
                valueLabelPair = returnElements[i].split(";")
                document.getElementById('sel2').options[i] = new Option(
                                valueLabelPair[0], valueLabelPair[1]);
        }
}

I should mention that I picked that function up somewhere on the
internet, i didn't write it myself.

Anyway, hope this helps,

Lutz

On Thu, Aug 7, 2008 at 10:06 PM, Mike Leonardo <[EMAIL PROTECTED]> wrote:
> Hey All,
>
> I have a form where I want to be able to change one value and have the other 
> values in the form update. I have a zone around the whole form, and I'd like 
> to use the onchange event to reload the Zone, but what javascript I use to 
> trigger the reloading?
>
> Thanks for any help!
> - Mike
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to