Hello, Thanks for the help it got me in the right direction(I think:).
>Very nice! You could even contribute it to the Tapestry components >collection! I would love to contribute if it was good enough, not sure how though. >String javascript = "Event.observe($(%s), 'click', >this.simplify.bindAsEventListener(this));"; > renderSupport.addScript(String.format(javascript, >element.getClientId(), message)); I am not sure what "this.simplify.bindAsEventListener(this)" was for or the "message" in renderSupport.addScript(String.format(javascript, element.getClientId(), message));. I looked into prototype following your lead and came up with: String javascript = "Event.observe($('%s'), 'click',function(){$('%s').click();});"; renderSupport.addScript(String.format(javascript, getClientId() + "Button",getClientId())); And it works like a charm. I don't know if it is the correct way to do it or not though. It basically puts the observe in the Tapestry.onDOMLoad function at the bottom of the page. Thanks, --James -----Original Message----- From: Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com] Sent: January-22-09 10:23 PM To: Tapestry users Subject: Re: T5: Component Suggestion/Question Em Thu, 22 Jan 2009 22:12:03 -0300, James Sherwood <jsherw...@rgisolutions.com> escreveu: > Thank you, :) > However I believe I have solved it and can still just use form fragments. > > Below is my class which basically just keeps the checkbox hidden and > fires the click from the button(I believe the reason only a checkbox or > radio is used is because the element itself keeps track of the state, if > it was a > button they javascript would have to keep track of it). Very nice! You could even contribute it to the Tapestry components collection! > QUESTION: "onclick", "document.getElementById('" + getClientId() + > "').click()"); Is not proper at all I believe. Does anyone know how to > do this properly with tapestry? Would just have to figure out a way to > fire > the observe function with the clientid maybe? AFAIK this is much more of a Javascript issue than a Tapestry one. We should then use Prototype's event handling. You could use something like this (not tested): Component class: @Inject private RenderSupport renderSupport; @BeginRender void begin(MarkupWriter writer) { ... render HTML without any onclick attributes // Add a Javascript code line that will bind the click event of your // button to function String javascript = "Event.observe($(%s), 'click', this.simplify.bindAsEventListener(this));"; renderSupport.addScript(String.format(javascript, element.getClientId(), message)); } -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org