You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ken Weiner <kw...@gmail.com> on 2005/09/01 22:19:36 UTC

changing the rendering behavior of HtmlSelectManyCheckbox

I need to find a way to render the checkboxes in HtmlSelectManyCheckbox in a 
format other than a single horizontal or vertical row. My first thought was 
to extend HtmlSelectManyCheckbox and make a new attribute called "width" and 
use this in conjunction with the "layout" attribute as follows:

<h:selectManyCheckbox value="#{backingBean.someArray}" 
layout="pageDirection" width="3">
<f:selectItems value="#{backingBean.someSelectItems}"/>
</h:selectManyCheckbox>

would produce

[x] [x] [x]
[x] [x] [x]
[x] [x] [x]
[x] [x] [x]
[x] [x] [x]
[x] [x] [x]
etc.

and 

<h:selectManyCheckbox value="#{backingBean.someArray}" 
layout="lineDirection" width="3">
<f:selectItems value="#{backingBean.someSelectItems}"/>
</h:selectManyCheckbox>

would produce

[x] [x] [x] [x] [x] [x] etc.
[x] [x] [x] [x] [x] [x]
[x] [x] [x] [x] [x] [x]

Is there better way to accomplish this? Should I be thinking about using 
SelectItemGroups? I'm ultimately trying to create a 2 X 2 set of checkboxes. 
Thanks!

-Ken

Re: changing the rendering behavior of HtmlSelectManyCheckbox

Posted by Jan Bols <ja...@ivpv.ugent.be>.
No the "spread" value is used to put SelectItem objects in another part of  
your jsf page. I think there's an example of this behaviour in the  
examples.tar.

Jan

On Fri, 02 Sep 2005 00:17:19 +0200, Ken Weiner <kw...@gmail.com> wrote:

> I just came across the mention of an attribute called "spread" when  
> reading
> the tomahawk.tld file. Is this what I'm looking for? Is this "spread"
> feature implemented yet? I couldn't find any use of it within the code.
> Could someone describe what it is for? Thanks.
>
> Extends standard selectManyCheckbox by user role support.
> Additionally this extended selectManyCheckbox accepts a layout attribute
> of value "spread" (see custom checkbox tag).
>
> -Ken
>
> On 9/1/05, Ken Weiner <kw...@gmail.com> wrote:
>>
>> I need to find a way to render the checkboxes in HtmlSelectManyCheckbox  
>> in
>> a format other than a single horizontal or vertical row. My first  
>> thought
>> was to extend HtmlSelectManyCheckbox and make a new attribute called  
>> "width"
>> and use this in conjunction with the "layout" attribute as follows:
>>
>> <h:selectManyCheckbox value="#{backingBean.someArray}"
>> layout="pageDirection" width="3">
>> <f:selectItems value="#{backingBean.someSelectItems}"/>
>> </h:selectManyCheckbox>
>>
>> would produce
>>
>> [x] [x] [x]
>> [x] [x] [x]
>> [x] [x] [x]
>> [x] [x] [x]
>> [x] [x] [x]
>> [x] [x] [x]
>> etc.
>>
>> and
>>
>> <h:selectManyCheckbox value="#{backingBean.someArray}"
>> layout="lineDirection" width="3">
>> <f:selectItems value="#{backingBean.someSelectItems}"/>
>> </h:selectManyCheckbox>
>>
>> would produce
>>
>> [x] [x] [x] [x] [x] [x] etc.
>> [x] [x] [x] [x] [x] [x]
>> [x] [x] [x] [x] [x] [x]
>>
>> Is there better way to accomplish this? Should I be thinking about using
>> SelectItemGroups? I'm ultimately trying to create a 2 X 2 set of  
>> checkboxes.
>> Thanks!
>>
>> -Ken
>>

Re: changing the rendering behavior of HtmlSelectManyCheckbox

Posted by Ken Weiner <kw...@gmail.com>.
I just came across the mention of an attribute called "spread" when reading 
the tomahawk.tld file. Is this what I'm looking for? Is this "spread" 
feature implemented yet? I couldn't find any use of it within the code. 
Could someone describe what it is for? Thanks.

Extends standard selectManyCheckbox by user role support.
Additionally this extended selectManyCheckbox accepts a layout attribute
of value "spread" (see custom checkbox tag).

-Ken

On 9/1/05, Ken Weiner <kw...@gmail.com> wrote:
> 
> I need to find a way to render the checkboxes in HtmlSelectManyCheckbox in 
> a format other than a single horizontal or vertical row. My first thought 
> was to extend HtmlSelectManyCheckbox and make a new attribute called "width" 
> and use this in conjunction with the "layout" attribute as follows:
> 
> <h:selectManyCheckbox value="#{backingBean.someArray}" 
> layout="pageDirection" width="3">
> <f:selectItems value="#{backingBean.someSelectItems}"/>
> </h:selectManyCheckbox>
> 
> would produce
> 
> [x] [x] [x]
> [x] [x] [x]
> [x] [x] [x]
> [x] [x] [x]
> [x] [x] [x]
> [x] [x] [x]
> etc.
> 
> and 
> 
> <h:selectManyCheckbox value="#{backingBean.someArray}" 
> layout="lineDirection" width="3">
> <f:selectItems value="#{backingBean.someSelectItems}"/>
> </h:selectManyCheckbox>
> 
> would produce
> 
> [x] [x] [x] [x] [x] [x] etc.
> [x] [x] [x] [x] [x] [x]
> [x] [x] [x] [x] [x] [x]
> 
> Is there better way to accomplish this? Should I be thinking about using 
> SelectItemGroups? I'm ultimately trying to create a 2 X 2 set of checkboxes. 
> Thanks!
> 
> -Ken
>

Re: changing the rendering behavior of HtmlSelectManyCheckbox

Posted by Jan Bols <ja...@ivpv.ugent.be>.
It's similar but not quite the same.

The added columns attributes defines the number of columns the renderer is  
going to use. So this is fixed while the number of rows depends on the  
number of selectItem objects inside.

Setting layout=pageDirection and columns=3 gives:

[A] [E] [I]
[B] [F] [J]
[C] [G]
[D] [H]

Setting the layout=lineDirection with columns=3 gives:

[A] [B] [C]
[D] [E] [F]
[G] [H] [I]
[J]

Ignoring the columns attribute or setting it to 0 produces the default  
behaviour.

Greetings
Jan

On Fri, 09 Sep 2005 17:37:39 +0200, Ken Weiner <kw...@gmail.com> wrote:

> Thanks. Does your columns attribute work with page direction and line
> direction? I ended up extending the component as well to handle a  
> "width" of
> checkboxes in both directions. I'll take a look at your code next week to
> see if it is similar and if I can enhance it with both drawing  
> directions if
> it isn't already done.
>
> On 9/7/05, Jan Bols <ja...@ivpv.ugent.be> wrote:
>>
>> I had the same problem and ended up extending the HtmlSelectManyCheckbox
>> component. I added a "columns" attribute where you can specify the  
>> number
>> of columns you want the selectManyCheckbox to use. Like this:
>>
>> <cc:selectManyCheckbox
>> layout="pageDirection"
>> columns="2">
>> <f:selectItems value="#{mySelectItems}"/>
>> </cc:selectManyCheckbox>
>>
>> You can find the sourcecode on http://sourceforge.net/projects/jsf-comp
>> but there's also a jar that you can add to WEB-INF/lib directory. The  
>> jar
>> file is found on http://www.ivpv.ugent.be/~jan/myfacessandbox.jar. The  
>> jar
>> file is for use with the nightly version (so not the 1.0.9 version) of
>> myfaces dating from 2005-08-15 but with a bit of luck it should also  
>> work
>> with the current nightly version of myfaces.
>>
>> You can find a working example of this on
>> https://www.ivpv.ugent.be/contact/new.faces?lang=en . Also on
>> http://www.ivpv.ugent.be/~jan/selectTest.jsp you can find a jsf file to
>> get you started...
>>
>> Hope this helps.
>>
>> Jan
>>
>>
>> On Thu, 01 Sep 2005 22:19:36 +0200, Ken Weiner <kw...@gmail.com>  
>> wrote:
>>
>> > I need to find a way to render the checkboxes in  
>> HtmlSelectManyCheckbox
>> > in a
>> > format other than a single horizontal or vertical row. My first  
>> thought
>> > was
>> > to extend HtmlSelectManyCheckbox and make a new attribute called  
>> "width"
>> > and
>> > use this in conjunction with the "layout" attribute as follows:
>> >
>> > <h:selectManyCheckbox value="#{backingBean.someArray}"
>> > layout="pageDirection" width="3">
>> > <f:selectItems value="#{backingBean.someSelectItems}"/>
>> > </h:selectManyCheckbox>
>> >
>> > would produce
>> >
>> > [x] [x] [x]
>> > [x] [x] [x]
>> > [x] [x] [x]
>> > [x] [x] [x]
>> > [x] [x] [x]
>> > [x] [x] [x]
>> > etc.
>> >
>> > and
>> >
>> > <h:selectManyCheckbox value="#{backingBean.someArray}"
>> > layout="lineDirection" width="3">
>> > <f:selectItems value="#{backingBean.someSelectItems}"/>
>> > </h:selectManyCheckbox>
>> >
>> > would produce
>> >
>> > [x] [x] [x] [x] [x] [x] etc.
>> > [x] [x] [x] [x] [x] [x]
>> > [x] [x] [x] [x] [x] [x]
>> >
>> > Is there better way to accomplish this? Should I be thinking about  
>> using
>> > SelectItemGroups? I'm ultimately trying to create a 2 X 2 set of
>> > checkboxes.
>> > Thanks!
>> >
>> > -Ken
>>
>>
>>


Re: changing the rendering behavior of HtmlSelectManyCheckbox

Posted by Ken Weiner <kw...@gmail.com>.
Thanks. Does your columns attribute work with page direction and line 
direction? I ended up extending the component as well to handle a "width" of 
checkboxes in both directions. I'll take a look at your code next week to 
see if it is similar and if I can enhance it with both drawing directions if 
it isn't already done.

On 9/7/05, Jan Bols <ja...@ivpv.ugent.be> wrote:
> 
> I had the same problem and ended up extending the HtmlSelectManyCheckbox
> component. I added a "columns" attribute where you can specify the number
> of columns you want the selectManyCheckbox to use. Like this:
> 
> <cc:selectManyCheckbox
> layout="pageDirection"
> columns="2">
> <f:selectItems value="#{mySelectItems}"/>
> </cc:selectManyCheckbox>
> 
> You can find the sourcecode on http://sourceforge.net/projects/jsf-comp
> but there's also a jar that you can add to WEB-INF/lib directory. The jar
> file is found on http://www.ivpv.ugent.be/~jan/myfacessandbox.jar. The jar
> file is for use with the nightly version (so not the 1.0.9 version) of
> myfaces dating from 2005-08-15 but with a bit of luck it should also work
> with the current nightly version of myfaces.
> 
> You can find a working example of this on
> https://www.ivpv.ugent.be/contact/new.faces?lang=en . Also on
> http://www.ivpv.ugent.be/~jan/selectTest.jsp you can find a jsf file to
> get you started...
> 
> Hope this helps.
> 
> Jan
> 
> 
> On Thu, 01 Sep 2005 22:19:36 +0200, Ken Weiner <kw...@gmail.com> wrote:
> 
> > I need to find a way to render the checkboxes in HtmlSelectManyCheckbox
> > in a
> > format other than a single horizontal or vertical row. My first thought
> > was
> > to extend HtmlSelectManyCheckbox and make a new attribute called "width"
> > and
> > use this in conjunction with the "layout" attribute as follows:
> >
> > <h:selectManyCheckbox value="#{backingBean.someArray}"
> > layout="pageDirection" width="3">
> > <f:selectItems value="#{backingBean.someSelectItems}"/>
> > </h:selectManyCheckbox>
> >
> > would produce
> >
> > [x] [x] [x]
> > [x] [x] [x]
> > [x] [x] [x]
> > [x] [x] [x]
> > [x] [x] [x]
> > [x] [x] [x]
> > etc.
> >
> > and
> >
> > <h:selectManyCheckbox value="#{backingBean.someArray}"
> > layout="lineDirection" width="3">
> > <f:selectItems value="#{backingBean.someSelectItems}"/>
> > </h:selectManyCheckbox>
> >
> > would produce
> >
> > [x] [x] [x] [x] [x] [x] etc.
> > [x] [x] [x] [x] [x] [x]
> > [x] [x] [x] [x] [x] [x]
> >
> > Is there better way to accomplish this? Should I be thinking about using
> > SelectItemGroups? I'm ultimately trying to create a 2 X 2 set of
> > checkboxes.
> > Thanks!
> >
> > -Ken
> 
> 
>

Re: changing the rendering behavior of HtmlSelectManyCheckbox

Posted by Jan Bols <ja...@ivpv.ugent.be>.
I had the same problem and ended up extending the HtmlSelectManyCheckbox  
component. I added a "columns" attribute where you can specify the number  
of columns you want the selectManyCheckbox to use. Like this:

			<cc:selectManyCheckbox
			layout="pageDirection"
			columns="2">
				<f:selectItems value="#{mySelectItems}"/>
			</cc:selectManyCheckbox>	

You can find the sourcecode on http://sourceforge.net/projects/jsf-comp  
but there's also a jar that you can add to WEB-INF/lib directory. The jar  
file is found on http://www.ivpv.ugent.be/~jan/myfacessandbox.jar. The jar  
file is for use with the nightly version (so not the 1.0.9 version) of  
myfaces dating from 2005-08-15 but with a bit of luck it should also work  
with the current nightly version of myfaces.

You can find a working example of this on  
https://www.ivpv.ugent.be/contact/new.faces?lang=en . Also on  
http://www.ivpv.ugent.be/~jan/selectTest.jsp you can find a jsf file to  
get you started...

Hope this helps.

Jan


On Thu, 01 Sep 2005 22:19:36 +0200, Ken Weiner <kw...@gmail.com> wrote:

> I need to find a way to render the checkboxes in HtmlSelectManyCheckbox  
> in a
> format other than a single horizontal or vertical row. My first thought  
> was
> to extend HtmlSelectManyCheckbox and make a new attribute called "width"  
> and
> use this in conjunction with the "layout" attribute as follows:
>
> <h:selectManyCheckbox value="#{backingBean.someArray}"
> layout="pageDirection" width="3">
> <f:selectItems value="#{backingBean.someSelectItems}"/>
> </h:selectManyCheckbox>
>
> would produce
>
> [x] [x] [x]
> [x] [x] [x]
> [x] [x] [x]
> [x] [x] [x]
> [x] [x] [x]
> [x] [x] [x]
> etc.
>
> and
>
> <h:selectManyCheckbox value="#{backingBean.someArray}"
> layout="lineDirection" width="3">
> <f:selectItems value="#{backingBean.someSelectItems}"/>
> </h:selectManyCheckbox>
>
> would produce
>
> [x] [x] [x] [x] [x] [x] etc.
> [x] [x] [x] [x] [x] [x]
> [x] [x] [x] [x] [x] [x]
>
> Is there better way to accomplish this? Should I be thinking about using
> SelectItemGroups? I'm ultimately trying to create a 2 X 2 set of  
> checkboxes.
> Thanks!
>
> -Ken