Two approaches:
(1) protected String getOnclick(FacesBean bean) { return null; } protected String getOnclick(FacesContext context, UIComponent component, FacesBean bean) { String onclick = super.getOnclick(bean); ... perform extra manipulation ... return onclick; } ... and call this new method from elsewhere in your renderer. (2) protected void encodeBegin( FacesContext context, RenderingContext arc, UIComponent comp, FacesBean bean) throws IOException { ... etc ... String clientId = comp.getClientId(context); // Make sure we don't have anything to save assert(arc.getCurrentClientId() == null); arc.setCurrentClientId(clientId); ... etc... arc.setCurrentClientId(null); } protected String getOnclick(FacesBean bean) { String onclick = super.getOnclick(bean); String clientId = RenderingContext.getCurrentInstance ().getCurrentClientId(); etc... } -- Adam On 2/28/07, Martin Marinschek <[EMAIL PROTECTED]> wrote:
Well, if the component is not passed in, you can't. The question is if the method signature should be changed. regards, Martin On 2/28/07, Danny Robinson <[EMAIL PROTECTED]> wrote: > Sorry, I should have been clearer. In the renderer code on the server-side > my component overrides the XhtmlRenderer.getOnclick() to insert some custom > javascript. Within this method I'd like to be able to call getClientId() on > the component to grab the id. > > Currently I'm having to use eval combined with this.id to workaround this > issue, but it's not very clean. > > Danny > > On 2/27/07, Mike Kienenberger <[EMAIL PROTECTED]> wrote: > > > > Keeping in mind that I have barely a day's worth of practical > > javascript experience, maybe this.id or something along those lines? > > > > On 2/27/07, Danny Robinson <[EMAIL PROTECTED]> wrote: > > > anyone ;-) > > > > > > On 2/23/07, Danny Robinson <[EMAIL PROTECTED]> wrote: > > > > > > > > Guys, > > > > > > > > Any advice on how to easily retrieve the component ID from within an > > > > overridden method such as XhtmlRenderer.getOnclick(). The only > > parameter > > > > to this is FacesBean.Type, and not the component itself. > > > > > > > > Thanks, > > > > > > > > Danny > > > > > > > > -- > > > > Chordiant Software Inc. > > > > www.chordiant.com > > > > > > > > > > > > > > > -- > > > Chordiant Software Inc. > > > www.chordiant.com > > > > > > > > > -- > Chordiant Software Inc. > www.chordiant.com > -- http://www.irian.at Your JSF powerhouse - JSF Consulting, Development and Courses in English and German Professional Support for Apache MyFaces