1 2 3 Previous Next 38 Replies Latest reply on Jul 9, 2008 6:00 PM by tikus Go to original post
      • 15. Re: how to use s:selectItems with h:selectManyCheckbox

        Tss... who uses IE7? ;-)


        Thank's for the correction though...

        • 16. Re: how to use s:selectItems with h:selectManyCheckbox
          nickarls

          how does it react to dropping the convertEntity and using


          
          <s:selectItems value="#{roleList.resultList}" var=role label="#{role.name}" itemValue="#{role.id}" />  
          
          



          BTW, shouldn't it be value="#{...}". Or do the quotes matter?

          • 17. Re: how to use s:selectItems with h:selectManyCheckbox
            nickarls

            Daniel Roth wrote on Mar 11, 2008 10:25 AM:


            Tss... who uses IE7? ;-)


            54% of the known world and 5.4% of the nerds. I must confess that I do, mostly since that is what our customers mostly have standardized on and I don't feel like running two browsers all the time.


            I haven't bothered to file a JIRA that e.g the tag box renders weird on IE8 beta :-).

            • 18. Re: how to use s:selectItems with h:selectManyCheckbox
              anatorian
              The xhtml:
              <h:selectManyCheckbox value=#{userHome.instance.roles}>  
                   <s:selectItems value=#{roleList.resultList} var=role label=#{role.name} itemValue="#{role.id}" />  
              </h:selectManyCheckbox>
              
              Error msg:
              Cannot convert 2 of type class java.lang.Long to class com.liba.link.security.entity.Role
              
              stack trace:
              java.lang.IllegalArgumentException: Cannot convert 2 of type class java.lang.Long to class com.liba.link.security.entity.Role
                   at org.jboss.el.lang.ELSupport.coerceToType(ELSupport.java:358)
                   at org.jboss.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:46)
                   at org.jboss.seam.el.SeamExpressionFactory.coerceToType(SeamExpressionFactory.java:70)
                   at com.sun.faces.renderkit.html_basic.SelectManyCheckboxListRenderer.renderOption(SelectManyCheckboxListRenderer.java:275)
                   at com.sun.faces.renderkit.html_basic.SelectManyCheckboxListRenderer.encodeEnd(SelectManyCheckboxListRenderer.java:146)
              

              • 19. Re: how to use s:selectItems with h:selectManyCheckbox
                damianharvey.damianharvey.gmail.com

                I've had problems with selectManyCheckBox and s:selectItems. Are you getting an error messages that says something like Cannot coerce to type?


                If so change your mapping to EAGER. The original forum post was this one


                Hope this helps.


                Cheers,


                Damian.

                • 20. Re: how to use s:selectItems with h:selectManyCheckbox
                  pmuir

                  You can't back a JSF <h:selectXXX /> with a Set - it must be a List or an array.

                  • 21. Re: how to use s:selectItems with h:selectManyCheckbox
                    anatorian

                    Yes, you are right! I use List instead of Set, and it works! Great!

                    • 22. Re: how to use s:selectItems with h:selectManyCheckbox
                      damianharvey.damianharvey.gmail.com

                      Even with a List you may still get intermittent coerceToType errors unless you set your mapping to EAGER. Ironically this reoccurred in my application yesterday after not seeing it for about 5 months.


                      Cheers,


                      Damian.

                      • 23. Re: how to use s:selectItems with h:selectManyCheckbox
                        damianharvey.damianharvey.gmail.com

                        Note that the coerceToType error is now fixed with the latest JSF libs (1.2_08) : JIRA


                        Cheers,


                        Damian.

                        • 24. Re: how to use s:selectItems with h:selectManyCheckbox
                          pmuir

                          Stan wrote up some quick instructions on upgrading your version of JSF to 1.2.08 - http://wiki.jboss.org/wiki/Wiki.jsp?page=UpgradeToMojarra1_2_08

                          • 25. Re: how to use s:selectItems with h:selectManyCheckbox
                            damianharvey.damianharvey.gmail.com

                            There are some little differences in how JSF 1.2_08 renders the page. For instance it seems a bit tighter on passing through 'illegal' (or just immoral?) attributes.


                            For instance border in h:graphicImage. It used to pass it through even though it's not actually a 'proper' attribute. Now it doesn't. No big deal but worth being aware of.


                            Cheers,


                            Damian.

                            • 26. Re: how to use s:selectItems with h:selectManyCheckbox
                              anatorian

                              Where can I download the jboss AS 5 CR1? The latest release in the download page is jboss AS 5 beta 4.


                              Thanks

                              • 27. Re: how to use s:selectItems with h:selectManyCheckbox
                                pmuir

                                Not yet released

                                • 28. Re: how to use s:selectItems with h:selectManyCheckbox

                                  I found a nice way to convert sets to lists using sets in jsf


                                  might seem familiar to pete :)

                                  • 29. Re: how to use s:selectItems with h:selectManyCheckbox
                                    irace

                                    Hi,


                                    I post my own question here, because it seems to me that it's the same kind of problem. I'm using Seam 2.0.0 within JBoss 4.2.2. I'm trying to set values for a many2many relationship using selectManyCheckbox component, and keep having a conversion error when doing so (via a JSF message).


                                    As a side note, I'm using a managed Hibernate session, and cannot / do not want to switch to an EJB entity manager.


                                    Here is the component declaration (xhtml):


                                    <h:selectManyCheckbox id="roles" value="{user.roles}">
                                    
                                         <s:selectItems value="{roleList}" var="role" label="#{role.rolename}" />
                                    
                                    </h:selectManyCheckbox>



                                    Here is the backing bean (having DbEntity implementing equals() and hashcode(), of course):


                                    @Entity
                                    
                                    @Name("user")
                                    
                                    @Scope(SESSION)
                                    
                                    public class User extends DbEntity
                                    
                                    {
                                    
                                        private Set<Role> _roles;
                                    
                                    
                                        (...)
                                    
                                    
                                      /**
                                    
                                       * @hibernate.many-to-many
                                    
                                       *       column="ROLE_FK"
                                    
                                       *       class="Role"
                                    
                                       * @hibernate.key
                                    
                                       *           column="UTILISATEUR_FK"
                                    
                                       *           not-null="true"
                                    
                                       * @hibernate.set
                                    
                                       *           cascade="save-update"
                                    
                                       *           access="property"
                                    
                                       *           table="ROLE_UTILISATEUR"
                                    
                                       *           lazy="false"
                                    
                                       */
                                    
                                        public Set<Role> getRoles() {
                                    
                                             return _roles;
                                    
                                        }
                                    
                                         
                                    
                                      /**
                                    
                                        */
                                    
                                        protected void setRoles(Set<Role> roles) {
                                    
                                             _roles = roles;
                                    
                                        }
                                    
                                         
                                    
                                    }




                                    At rendering time, all is ok : my checkboxes appear with adequate values selected. But when I try to save the user (having modified anything or not), I've got the following message: Conversion Error setting value '...' for '{user.roles}'


                                    I've tried the following:


                                    1. using s:convertEntity with my hibernate session, but the EntityConverter is not initialized, because it has no session attribute (as I understood it, it is designed to work with EJB entity manager only)


                                    2. define my own converter implementing javax.faces.convert.Converter for the Role entity. The getAsString method was called ok, but getAsObject was never called. I think I configured it ok in selectManyCheckbox, but maybe I made some mistake.


                                    Nothing seems to work. Could anybody help me or give me some advice on this subject ?


                                    Thanks
                                    Thom'