You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Mike Kienenberger (JIRA)" <de...@myfaces.apache.org> on 2007/04/10 22:54:33 UTC

[jira] Commented: (TOMAHAWK-939) t:radio should support standard pass-through attributes

    [ https://issues.apache.org/jira/browse/TOMAHAWK-939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12487915 ] 

Mike Kienenberger commented on TOMAHAWK-939:
--------------------------------------------

Here's a temporary workaround that doesn't involve modifying Tomahawk.   Tested against 1.1.5 MyFaces Core/Tomahawk/Sandbox.

Add to faces-config.xml:
=============================
<render-kit>
        <render-kit-id>HTML_BASIC</render-kit-id>

        <renderer>
            <component-family>org.apache.myfaces.Radio</component-family>
            <renderer-type>org.apache.myfaces.Radio</renderer-type>
            <renderer-class>com.xyz.jsf.component.ExtendedHtmlRadioRenderer</renderer-class>
        </renderer>

</render-kit>
=============================

Create com.xyz.jsf.component.ExtendedHtmlRadioRenderer:
------------------------------------------------------------------------------------------
package com.xyz.jsf.component;

import java.io.IOException;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;

import org.apache.myfaces.custom.radio.HtmlRadio;
import org.apache.myfaces.renderkit.html.ext.HtmlRadioRenderer;
import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;

public class ExtendedHtmlRadioRenderer extends HtmlRadioRenderer {

    private HtmlRadio radio;
    
    public void encodeEnd(FacesContext context, UIComponent component) throws IOException
    {
        this.radio = null;
        if (component instanceof HtmlRadio)
        {
            this.radio = (HtmlRadio)component;
        }
        
        super.encodeEnd(context, component);
    }
    
    protected void renderRadio(FacesContext facesContext,
                               UIComponent uiComponent,
                               String value,
                               String label,
                               boolean disabled,
                               boolean checked,
                               boolean renderId)
            throws IOException
    {
        uiComponent.getAttributes().put(HTML.ONCLICK_ATTR, radio.getAttributes().get(HTML.ONCLICK_ATTR));
        super.renderRadio(facesContext, uiComponent, value, label, disabled, checked, renderId);
    }

}
------------------------------------------------------------------------------------------


> t:radio should support standard pass-through attributes
> -------------------------------------------------------
>
>                 Key: TOMAHAWK-939
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-939
>             Project: MyFaces Tomahawk
>          Issue Type: Improvement
>          Components: selectOneRadio / radio
>            Reporter: Mike Kienenberger
>
> t:radio should support the standard passthrough attributes (and probably some others like id) in order to customize the generated <input>.  For example, onclick, onchange, etc.
> A temporary fix to this problem looks like the following (for facelets).   However, this is not the right long-term solution.
> Index: tomahawk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlRadioRenderer.java
> ===================================================================
> --- tomahawk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlRadioRenderer.java
> (revision
> 431891)
> +++ tomahawk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlRadioRenderer.java
> (working
> copy)
> @@ -131,7 +131,9 @@
>          writer.startElement(HTML.LABEL_ELEM, uiSelectOne);
> -        renderRadio(facesContext,
> +    	uiSelectOne.getAttributes().put(HTML.ONCLICK_ATTR,
> radio.getAttributes().get(HTML.ONCLICK_ATTR));
> +
> +    	renderRadio(facesContext,
>                      uiSelectOne,
>                      itemStrValue,
>                      selectItem.getLabel(),

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.