You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Stavrinides <P....@albourne.com> on 2010/07/23 12:40:18 UTC
Zoneupdater mixin best practice
Hi all,
I am trying out the Zoneupdater mixin on a dropdown. What I want to do is as follows:
When the user selects an option from the dropdown I want to trigger an event that filters a list, which is then used on an autocomplete textfield. Sounds simple enough but I don't quite understanding how to use the Zoneupdater to target only specific fields in my form without changing the other fields.
To be more specific, I am using the Zoneupdater (code below) with a zone that encloses a form, and the form encloses several textfields. For my use case I only want to target one specific form element but don't know how to avoid the zone refreshing everything. I.e.: As it stands now, any input in other fields in the form is lost whenever I make a selection from the drop down menu due to the zone update, is there another way?
.tml:
<div t:type="zone" t:id="siteZone">
<t:form >
<!-- Textfield to autocomplete-->
<t:textfield t:id="site" value="site"/>
<t:select t:id="country" value="country" model="countriesModel"
t:mixins="zoneUpdater" t:clientEvent="change" t:event="changeOfCountry" t:zone="siteZone"/>
<!-- The rest of the form elements below -->
....
</t:form>
</div>
.java:
Object onChangeOfCountry() {
country = request_.getParameter("param");
return siteZone_.getBody();
}
Thanks in advance,
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Zoneupdater mixin best practice
Posted by Stefan Hagström <st...@iserv.se>.
Hi, i just recently implemented a similar solution with Jquery
jQuery(document).ready(function() {
jQuery("#county").change(function(){
var county = jQuery(this).val();
// Send the request and update sub category dropdown
jQuery.ajax({
type: "GET",
data: post_string,
dataType: "json",
cache: false,
url: '/kalender/servlet/data?action=municipality&county='
+county,
timeout: 20000,
error: function() {
alert("An error occured: "+county);
},
success: function(data) {
// Clear all options from sub category select
jQuery("select#municipality option").remove();
// Fill sub category select
jQuery.each(data, function(i, j){
var row = "<option value=\"" + j.value + "\">" + j.text
+ "</option>";
jQuery(row).appendTo("select#municipality");
});
}
});
});
});
Whenever the select box with id=county is changed, the select box with id
#municipality is populated.
Not a full solution to your problem, but you get the idea.
/Stefan
2010/7/23 Peter Stavrinides <P....@albourne.com>
> > To not lose the field values, submit the form.
> Well thats kind of what I hoped to avoid
>
> > To update just one field, you can create an event and trigger and handle
> > it with a little bit of custom JavaScript and the JSON classes in
> Tapestry.
> If this is the best approach then can someone suggest an example please
>
> Cheers,
> Peter
>
>
> ----- Original Message -----
> From: "Thiago H. de Paula Figueiredo" <th...@gmail.com>
> To: "Tapestry users" <us...@tapestry.apache.org>
> Sent: Friday, 23 July, 2010 15:49:03 GMT +02:00 Athens, Beirut, Bucharest,
> Istanbul
> Subject: Re: Zoneupdater mixin best practice
>
> On Fri, 23 Jul 2010 07:40:18 -0300, Peter Stavrinides
> <P....@albourne.com> wrote:
>
> > Hi all,
>
> Hi!
>
> > To be more specific, I am using the Zoneupdater (code below) with a zone
> > that encloses a form, and the form encloses several textfields. For my
> > use case I only want to target one specific form element but don't know
> > how to avoid the zone refreshing everything. I.e.: As it stands now, any
> > input in other fields in the form is lost whenever I make a selection
> > from the drop down menu due to the zone update, is there another way?
>
> To not lose the field values, submit the form.
>
> To update just one field, you can create an event and trigger and handle
> it with a little bit of custom JavaScript and the JSON classes in Tapestry.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Zoneupdater mixin best practice
Posted by Peter Stavrinides <P....@albourne.com>.
> To not lose the field values, submit the form.
Well thats kind of what I hoped to avoid
> To update just one field, you can create an event and trigger and handle
> it with a little bit of custom JavaScript and the JSON classes in Tapestry.
If this is the best approach then can someone suggest an example please
Cheers,
Peter
----- Original Message -----
From: "Thiago H. de Paula Figueiredo" <th...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Friday, 23 July, 2010 15:49:03 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: Zoneupdater mixin best practice
On Fri, 23 Jul 2010 07:40:18 -0300, Peter Stavrinides
<P....@albourne.com> wrote:
> Hi all,
Hi!
> To be more specific, I am using the Zoneupdater (code below) with a zone
> that encloses a form, and the form encloses several textfields. For my
> use case I only want to target one specific form element but don't know
> how to avoid the zone refreshing everything. I.e.: As it stands now, any
> input in other fields in the form is lost whenever I make a selection
> from the drop down menu due to the zone update, is there another way?
To not lose the field values, submit the form.
To update just one field, you can create an event and trigger and handle
it with a little bit of custom JavaScript and the JSON classes in Tapestry.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Zoneupdater mixin best practice
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 23 Jul 2010 07:40:18 -0300, Peter Stavrinides
<P....@albourne.com> wrote:
> Hi all,
Hi!
> To be more specific, I am using the Zoneupdater (code below) with a zone
> that encloses a form, and the form encloses several textfields. For my
> use case I only want to target one specific form element but don't know
> how to avoid the zone refreshing everything. I.e.: As it stands now, any
> input in other fields in the form is lost whenever I make a selection
> from the drop down menu due to the zone update, is there another way?
To not lose the field values, submit the form.
To update just one field, you can create an event and trigger and handle
it with a little bit of custom JavaScript and the JSON classes in Tapestry.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org