12 Replies Latest reply on Aug 31, 2007 6:51 AM by amitev

    Problems with scopes

    amitev

      Hi all! I have defined ajax4jsf skin to point to a seam component

      <context-param>
       <param-name>org.ajax4jsf.SKIN</param-name>
       <param-value>#{user.skinName}</param-value>
       </context-param>
      


      But i got a strange error - if the scope of "user" is not "session" ajax4jsf throws an exception that the skin value is null, with session scope it works. Idea what's the problem here?

        • 1. Re: Problems with scopes
          wise_guybg

          Zdravei,

          It's reasonable to think that the skin initialization takes place at application start up.

          Besides, setting a context-param with a bean (user) in a scope other than application or session looks strange to me. This is an initialization parameter after all.

          I suppose that org.ajax4jsf.framework.skin.SkinBean stays in the session/application scope and is responsible for managing the skin. You can try to use that bean to change the skin according to what the user has selected after the login takes place. I think this is what you're trying to do in your code. Here is an example I found with Google:

          <h:selectOneRadio binding="#{skinBean.component}" />
          <h:commandLink action="#{skinBean.change}" value="set skin" />


          You can also spend some time on loading a skin for the login page using the browser cookie.

          For start, I would suggest checking out how to programatically change the skin after login (web.xml is not the place).

          • 2. Re: Problems with scopes
            amitev

            Hi dude! The a4j skinability is dymanic, the skin is initialized at the beginning of each request and the skin name is taken from the expression you specify in web.xml. I saw this on this tutorial from exadel [1].

            [1] http://www.exadel.com/EVCPTutorial/EVCPGSskinability.pdf

            • 3. Re: Problems with scopes
              wise_guybg

              The bean they specify in the pdf is session scoped:

              <managed-bean>
               <managed-bean-name>infoBean</managed-bean-name>
               <managed-bean-class>sample.InfoBean</managed-bean-class>
               <managed-bean-scope>session</managed-bean-scope>
               <managed-property>
               <property-name>skin</property-name>
               <value>classic</value>
               </managed-property>
              </managed-bean>


              The expression you specify in web.xml must point to a session bean. Your user bean will not be initialized at login I suppose.

              You can create a session bean and store the skin name there. As I suggested before the SkinBean can be used for that purpose too. When your user logs in, you simply set the skin name of that bean. Then you will have that:
              the skin is initialized at the beginning of each request and the skin name is taken from the expression you specify in web.xml


              • 4. Re: Problems with scopes
                amitev

                Right. Thank you!

                • 5. Re: Problems with scopes
                  wise_guybg

                  Thanks for sharing:
                  EVCPGSskinability.pdf - "Modifying the Skin Dynamically"

                  I didn't know about this feature until now.

                  • 6. Re: Problems with scopes
                    amitev

                    I guess that seam should integrate richfaces skinability

                    • 7. Re: Problems with scopes
                      wise_guybg

                      Did the SkinBean do the job? If you can use it, there is no need for Seam to get involved.

                      • 8. Re: Problems with scopes
                        amitev

                        The purpose of SkinBean (#{a4jSkin}) is quite different. I just need a skin changer with cookie support :)

                        • 9. Re: Problems with scopes
                          wise_guybg

                          This really sound like a SkinSelector similar to the ThemeSelector :)

                          • 10. Re: Problems with scopes
                            amitev

                            Will be good :)

                            • 11. Re: Problems with scopes
                              wise_guybg

                              btw I was not talking about

                              org.ajax4jsf.framework.skin.SkinBean

                              but
                              org.richfaces.SkinBean

                              Here is the code:
                              http://www.koders.com/java/fidF65263F05876F2FFF880E94E1796E5FAD6058E33.aspx

                              • 12. Re: Problems with scopes
                                amitev

                                nice one