You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by fischman_98 <mf...@powerconsultantsinc.com> on 2006/05/04 01:28:50 UTC

t:selectManyCheckbox - Make Checkbox label a link

Anyone know how to make the itemLabel of a SelectItem a href?

I'd like to produce a checkbox that looks like this:




  	
    

      	
        
         COLUMBIA RIVER (WASHINGTON) 

        

        	
         SUN 

        

        	
         CLOUDS 


--
View this message in context: http://www.nabble.com/t%3AselectManyCheckbox---Make-Checkbox-label-a-link-t1553488.html#a4220404
Sent from the MyFaces - Users forum at Nabble.com.

Re: t:selectManyCheckbox - Make Checkbox label a link

Posted by Andrew Robinson <an...@gmail.com>.
Here is one solution:

Write a custom renderer. In that renderer, make a parent component with two
temporal child components. First child: select one checkbox. Second child:
output link.

On the rendering of the checkbox, record it's client ID in a variable. On
rendering of the output link, add a "javascript:
getElementById('"+checkboxId +"').value = !getElementById('"+checkboxId
+"').value;" as the URL of the link. This will toggle the value of the
checkbox.

Doing it as a custom component and a renderer you will have access to the
client ID of the checkbox. Another alternative is to use forceId and just
hand-code the output:

<script>
function toggleCheckbox(elemId)
{
var elem = document.getElementById(elemId)
elem.value = !elem.value
}
</script>
<t:selectBooleanCheckBox id="mycheckbox" forceId="true" .../>
<t:outputLink url="javascript: toggleCheckbox('mycheckbox')" />

There are other solutions and variations, but this should work for you.
Depends on how much work you want to do to make it nice. Sounds like a good
idea for a sandbox component to me (if only I had the time...)

-Andrew

On 5/3/06, fischman_98 <mf...@powerconsultantsinc.com> wrote:
>
>
> Anyone know how to make the itemLabel of a SelectItem a href?
>
> I'd like to produce a checkbox that looks like this:
>
>
>  COLUMBIA RIVER (WASHINGTON) <http://COLUMBIA+RIVER+%28WASHINGTON%29>
>  SUN  CLOUDS
> ------------------------------
> View this message in context: t:selectManyCheckbox - Make Checkbox label a
> link<http://www.nabble.com/t%3AselectManyCheckbox---Make-Checkbox-label-a-link-t1553488.html#a4220404>
> Sent from the MyFaces - Users<http://www.nabble.com/MyFaces---Users-f181.html>forum at
> Nabble.com.
>

Re: t:selectManyCheckbox - Make Checkbox label a link

Posted by Mike Kienenberger <mk...@gmail.com>.
Maybe you could work with Yasushi on this.

---------- Forwarded message ----------
From: Mike Kienenberger <mk...@gmail.com>
Date: May 4, 2006 11:31 AM
Subject: Re: question for t:selectOneRadio : how to add other components
besides f:selectItem
To: MyFaces Discussion <us...@myfaces.apache.org>


On 5/3/06, Yasushi Okubo <ya...@cabm.rutgers.edu> wrote:
> I would like to add other components like outputtext, panelGrid etc
> inside t:selectOneRadio besides f:selectItem, but it seems it does not
work.
> Is there any way to achieve this ?

There have been a number of people asking how to do various things
(images, outputLinks, etc) inside f:selectItem.

Perhaps you could submit a patch to t:select* components that supports
a t:selectItem which could contain a component to use as a renderer?
Maybe as a facet or simply anything enclosed by t:selectItem?