Dear Rich I tried to implement what you desired ( to the best of my understanding)
this is it import org.apache.tapestry5.ClientElement; import org.apache.tapestry5.ComponentResources; import org.apache.tapestry5.Link; import org.apache.tapestry5.annotations.Environmental; import org.apache.tapestry5.annotations.Import; import org.apache.tapestry5.annotations.InjectContainer; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.json.JSONObject; import org.apache.tapestry5.services.javascript.JavaScriptSupport; @Import(library = "show-hide.js") public class ShowHide { @Parameter(required = true) private boolean state; @InjectContainer private ClientElement element; @Inject private ComponentResources resources; @Environmental private JavaScriptSupport javaScriptSupport; void afterRender(){ Link link = resources.createEventLink("showHide"); JSONObject spec = new JSONObject(); spec.put("url", link.toAbsoluteURI()); spec.put("id", element.getClientId()); spec.put("status", state); javaScriptSupport.addScript("new ShowHide(%s);", spec); } void onShowHide(boolean state){ System.out.println("Old state = " + this.state + " new state = " + state); this.state = state; } } The javascript... (it is not doing anything fancy, just basic implementation) ShowHide = Class.create( { initialize : function(spec) { $(spec.id).status = spec.status; Event.observe(spec.id, "click", function() { if (!this.status) { this.status = true; } else { this.status = !this.status; } Tapestry.ajaxRequest(spec.url + "/" + this.status, function() { if($(spec.id).status){ $(spec.id).show(); }else { $(spec.id).hide(); } }); }); } }); This is the component using this mixin as implementation mixin import net.jkbank.dc.ticket.mixins.ShowHide; import org.apache.tapestry5.BindingConstants; import org.apache.tapestry5.ClientElement; import org.apache.tapestry5.MarkupWriter; import org.apache.tapestry5.annotations.Environmental; import org.apache.tapestry5.annotations.Mixin; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.services.javascript.JavaScriptSupport; public class Div implements ClientElement { @Parameter(value = "prop:componentResources.id", defaultPrefix = BindingConstants.LITERAL) private String clientId; @SuppressWarnings("unused") @Mixin private ShowHide showHide; private String assignedClientId; @Environmental private JavaScriptSupport javaScriptSupport; void setupRender(){ assignedClientId = javaScriptSupport.allocateClientId(clientId); } void beginRender(MarkupWriter writer){ writer.element("div", "id", getClientId()); } void afterRender(MarkupWriter writer){ writer.end(); } public String getClientId() { return assignedClientId; } } This is the usage in a template file <html xmlns:t='http://tapestry.apache.org/schema/tapestry_5_1_0.xsd'> <body> <t:div t:state='state' > This is some text </t:div> </body> </html> public class TestPage { @Persist @Property private boolean state; } regards Taha On Wed, Apr 6, 2011 at 10:35 PM, LLTYK <ll...@mailinator.com> wrote: > Last time I did this I used a javascript cookie api. > > -- > View this message in context: > http://tapestry-users.832.n2.nabble.com/Implementation-mixin-and-persistence-tp6243796p6246820.html > Sent from the Tapestry Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >