13 Replies Latest reply on Nov 9, 2006 12:02 PM by aahamlin

    s:actionLink and JAAS

    lcoetzee

      Hi all,

      I have seen the inclusion of the seam ui stuff in CVS. Great stuff!!! The provision of the s:actionLink that works without JavaScript solves one of my biggest headaches! A lot of people use console mode browsers (links, lynx) that does not have good support for Javascript which meant that the usage of stuff like commandLink was problematic. However, with the way it is now it works perfectly from these browsers ! Excellent !

      I also see that it has an option to continue a conversation or start a new conversation (if I understand it correctly). Again this provision partially solves my other head ache (the killing of all conversations and then starting a new one). With this it does start a new conversation every time a link is selected (leaving the other stale conversation behind which will ulitimately time out and be cleaned up). Good !

      One addition that I would really like is support for the JAAS roles (similar to the way that tomahawk provides support in the form of enabledOnUserRole="ServiceManager" and visibleOnUserRole, http://myfaces.apache.org/tomahawk/tlddoc/t/commandLink.html). Would that be possible ?

      Anyway, great stuff with the addition of this new functionality!

      Regads

      Louis

        • 1. Re: s:actionLink and JAAS
          lcoetzee

          I have added a jira feature request for extending the actionLink component.

          http://jira.jboss.com/jira/browse/JBSEAM-191

          • 2. Re: s:actionLink and JAAS
            gavin.king

            Note one thing about <s:link> (I renamed it yesterday): it does NOT do form submissions. It is purely for things like search screens and master-detail views. What it *does* support is:

            Calling Actions:

            <s:link action="#{my.actionMethod}"/>


            Or Navigation Rules:

            <s:link action="success"/>


            Linking to a view by JSF view id:

            <s:link view="/myView.xhtml"/>


            Both at Once:

            <s:link action="#{before.myView}" view="/myView.xhtml"/>


            Specifying the conversation propagation type:

            <s:link action="#{childEditor.selectChild}" propagation="nest"/>


            <s:link action="#{childEditor.selectChild}" propagation="begin"/>


            <s:link action="#{childEditor.selectChild}" propagation="end"/>


            <s:link action="#{childEditor.selectChild}" propagation="join"/>


            <s:link action="#{childEditor.selectChild}" propagation="none"/>


            Finally, if you use <s:link> inside a <h:dataTable> that is pointed to a @DataModel, the @DataModelSelection is populated.

            ---

            I don't see how it is helpful to have <s:link> support the JAAS stuff if other stuff like <h:commandLink> and <h:inputText> do not ... or are you assuming that users will be using this stuff together with a library like tomahawk that *does* support it?

            • 3. Re: s:actionLink and JAAS
              lcoetzee

               

              I don't see how it is helpful to have <s:link> support the JAAS stuff if other stuff like <h:commandLink> and <h:inputText> do not ... or are you assuming that users will be using this stuff together with a library like tomahawk that *does* support it?


              For my specific environment it would be helpful as I use the tomahawk components combined with JAAS quite a lot (most of the tomahawk stuff just seems to add user role support). I don't know how much JAAS itself is really used which might just over complicate stuff on the Seam side. I am sure I can play around with the rendered attribute based on user's roles that I expose to achieve the same effect.

              As an aside: to use the ui stuff with the latest myfaces snapshot one has to change the imports in HTML.java (seems the myfaces guys have moved things around a bit). Also replace the myfaces-api.jar and myfaces-impl.jar in seam-src/lib with myfaces-api-1.1.3-SNAPSHOT.jar and
              myfaces-impl-1.1.3-SNAPSHOT.jar




              org.jboss.seam.ui.HTML.java
              //import org.apache.myfaces.renderkit.RendererUtils;
              //this for myfaces snapshot 1.1.3
              import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
              //import org.apache.myfaces.util.ArrayUtils;
              //this for myfaces snapshot 1.1.3
              import org.apache.myfaces.shared_impl.util.ArrayUtils;
              
              


              Regards

              Louis


              • 4. Re: s:actionLink and JAAS
                gavin.king

                 

                For my specific environment it would be helpful as I use the tomahawk components combined with JAAS quite a lot


                It would be better if there was a more generic solution.

                I wonder if it is possible to create an <s:secure> tag and then do, eg:

                <s:secure role="Admin">
                 <h:commandLink ... />
                </s:secure>


                I have not yet investigated whether stuff like this is easy in JSF.

                I am sure I can play around with the rendered attribute based on user's roles that I expose to achieve the same effect


                The problem I see here is that you need a way to pass the name of the role you need, and JSF-EL does not support parameters (this is silly, btw).

                I guess you could use:

                <s:link rendered="#{not empty user.roles['Admin']}"/>


                or something. But that is kinda ugly.

                to use the ui stuff with the latest myfaces snapshot one has to change the imports in HTML.java


                Eeeek! Very careless of me, I was NOT supposed to have a MyFaces dependency there! Fixed in CVS.

                • 5. Re: s:actionLink and JAAS
                  lcoetzee

                   

                  The problem I see here is that you need a way to pass the name of the role you need, and JSF-EL does not support parameters (this is silly, btw).


                  Agreed. What I have done to simulate the JAAS roles stuff is expose stuff in my PortalUser object (this required for each role that I have.. clumsy but works):

                  @Transient
                  public Boolean getServiceManager() {
                  //userHasRole is a hashmap containing all the user roles
                   return userHasRole(PortalRole.serviceManagerLiteral);
                  }
                  


                  in my view page I then do something like:
                  <f:subview rendered="#{portalUser.serviceManager}">
                  <li><s:link action="#{serviceManagementBean.loadAllServices}"
                   propagation="end" id="serviceManagement">
                   <h:outputText value="#{msgs.serviceManagement}" />
                  </s:link></li>
                  </f:subview>




                  Fixed in CVS.

                  Excellent.

                  L


                  • 6. Re: s:actionLink and JAAS
                    gavin.king

                    Yes, perhaps what we need is an <s:subview/>

                    • 7. Re: s:actionLink and JAAS
                      gavin.king

                      OK, actually, Jacob convinced me of something easier.

                      Now we have:

                      <h:commandLink action="..." rendered="#{isUserInRole['Admin']}"/>


                      In CVS. Please test it and see if it works for you...

                      • 8. Re: s:actionLink and JAAS
                        lcoetzee

                        Jip it works !

                        I did something like this below:

                        <f:subview rendered="#{isUserInRole['ServiceManager']}">
                         <li><s:link action="#{serviceManagementBean.loadAllServices}"
                         propagation="end" id="serviceManagement">
                         <h:outputText value="#{msgs.serviceManagement}" />
                         </s:link></li>
                        </f:subview>
                        


                        Great stuff. I love the speed at which things happen !

                        L


                        • 9. Re: s:actionLink and JAAS
                          gavin.king

                          Didn't you have some other custom-written stuff for JAAS integration? Exactly what pieces are there, and do any of them make sense to belong in the Seam core?

                          • 10. Re: s:actionLink and JAAS
                            lcoetzee

                            If memory serves: 3 main parts regarding JAAS:

                            1. The user management, assignment or roles etc. which I assume would be application specific. However, associated with that is the need to flush the JAAS cache (which I haven't been able to get going in JBoss 4.0.x)

                            http://www.jboss.com/index.html?module=bb&op=viewtopic&t=80155

                            2. The initialization of the user after the JAAS login (injection of PortalUser). I used a factory method to explicitely load the user as extracted from the user principal

                            Principal principal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
                            


                            3. I also extended the ViewHandler to force the users locale and view options (as loaded from the database for that principal) to the correct values. The factory I used (in 2 above) didn't get initiated for the first showing of the admin pages. Again this will be application specific as not all implementations will have a choice regarding languages and view options. We are doing some weird things with CSS to provide larger fonts and different for and background colors

                            I think a combination of these three elements (if 3 is required is doubtful) would be good.


                            I can extract the appropriate pieces and place them somewhere to give you a better idea.

                            L

                            • 11. Re: s:actionLink and JAAS
                              gavin.king

                              I think (2) would make sense, the others probably not.

                              At some stage, the various groups in JBoss (jBPM, AS, Seam, Portal) need to get together to develop and unified identity management solution that will plug in everywhere. But this is too big of a job to do today.

                              • 12. Re: s:actionLink and JAAS
                                aahamlin

                                I hope I'm not missing something obvious, but I have been trying to piece together the steps to perform a JAAS login to a webapp and then instantiate my User entity bean and have it outjected into a Seam app.

                                I've found many breadcrumbs but many are 6 months to a year old... I recall seeing a post recently about the Seam CVS containing some JAAS examples that are not included in 1.0.1.GA. Of course, I can't find that post now. :(

                                I've search via google, the Jboss forums and Jboss wiki for "Seam JAAS login" but have not found a comprehensive guide to doing - what I think - should be a fairly common place function.

                                Could you point me to the location of such examples and documentation on Seam's current JAAS capabilities?

                                • 13. Re: s:actionLink and JAAS
                                  aahamlin

                                  Hmm, may have answered my own question. I found the "post" I was referring to, having just realized that the forums page width caused the Next Page links to scroll off to the right - and I was too careless to notice, sorry.

                                  The later pages appear to answer my question a bit more fully.
                                  http://www.jboss.com/index.html?module=bb&op=viewtopic&t=74300

                                  Still I hope that the examples and documentation get all this info rolled into them at some point, so other don't need to search for far to find the answers.

                                  BTW - the Fisheye and CVS views of the JbossSeam project don't seem to be working, so I couldn't follow up on what "examples" may be posted there.