8 Replies Latest reply on Jan 16, 2014 9:37 PM by Vysali_Janardhanan

    Override struts login action in Jive 6

    cwmenke Novice

      I have a plugin which I'm upgrading from Jive 4.5 to Jive 6.

       

      In the struts.xml, I specified an override to the default login action where I provide my own custom FTL:

       

      <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
      <struts>
          <package name="ehi-login-plugin-actions" namespace="/" extends="community-actions-include">
      
      
              <action name="login" class="com.ehi.plugin.LoginAction">
                  <result name="input">/plugins/ehi-login-plugin/resources/templates/login.ftl</result>
                  <result name="unauthenticated">/plugins/ehi-login-plugin/resources/templates/login.ftl</result>
                  <result name="unauthorized">/template/global/unauth.ftl</result>
                  <result name="create-profile" type="redirect">create-account.jspa?username=${username}</result>
              </action>
              
              <action name="login-custom" class="com.ehi.plugin.LoginAction">
                  <result name="input">/plugins/ehi-login-plugin/resources/templates/login.ftl</result>
                  <result name="unauthenticated">/plugins/ehi-login-plugin/resources/templates/login.ftl</result>
                  <result name="unauthorized">/template/global/unauth.ftl</result>
                  <result name="create-profile" type="redirect">create-account.jspa?username=${username}</result>
              </action>
                      
          </package>
      </struts>
      
      
      

       

      I'm having trouble with my action overriding the default action. This used to work fine in Jive 4.5 so I think something must be different in Jive 6?

       

      I can tell my freemarker template works because I can browse to http://localhost:8080/login-custom.jspa to see my changes. However, the normal login page http://localhost:8080/login.jspa does not show the changes.

       

      How can I override the login action?

        • Re: Override struts login action in Jive 6
          cwmenke Novice

          Actually, what I posted above works. I needed a mvn clean package.

           

          I found out you must include the namespace and use extends="community-actions-include". Previously, we were extending "community-custom" which no longer works.

            • Re: Override struts login action in Jive 6
              Vysali_Janardhanan Novice

              Hi Kit Menke,Ryan Rutan

               

              We are trying to override the "customize-container" action which also belongs to the "community-actions-include" package.

              We have tried giving the namespace and used extends "community-action-include" in the struts file.

              But the default action class is only being called.

               

              Upon debug, we noticed it was entering the corresponding methods of the standard action class- CustomizeContainerAction.

               

              When namespace is not given and we extend the "community-action-include", the execute and prepare methods are being called from the custom action class.

              However the publish,discard etc are again coming from the default action class.

               

              We dont understand how this is actually supposed to be configured, so that all the methods are called from the custom action class.

                • Re: Override struts login action in Jive 6
                  cwmenke Novice

                  Vysali Janardhanan,

                  I feel your pain... it took us a while to get it working ... with lots of trial and error.

                   

                  From my experience you need to override it exactly how it appears in the struts-community.xml. In your case, I think the package should be configured like:

                  <package name="my-custom-plugin-actions" namespace="/" extends="community-actions-include">

                   

                  Then, copy the <action name="customize-container" class="com.jivesoftware.community.widget.action.CustomizeContainerAction"> XML block from struts-community.xml and change the class to point to your custom class. If necessary, change the FTL templates to point to templates in your plugin.

                   

                  Hopefully that helps,

                  Kit

                    • Re: Override struts login action in Jive 6
                      Vysali_Janardhanan Novice

                      Hi Kit Menke,

                       

                      We tried copying things from the struts-community.xml as suggested:

                       

                      An excerpt from our struts file is as follows:

                       

                      <package name="abc" namespace="/" extends="community-actions-include">

                              <default-interceptor-ref name="includeStack" />

                              <action name="customize-container" class="com.abc.community.widget.action.CustomCustomizeContainerAction">

                                    <interceptor-ref name="paramsPrepareParamsStack"/>

                                  <result name="container" type="redirect">${containerURL}</result>

                                  <result name="copy">/template/global/customize-container.ftl</result>         

                                  <result name="none" type="httpheader">200</result>

                                  <result name="locked">/template/global/include/customize-locked.ftl</result>

                                  <result name="success">/template/global/customize-container.ftl</result>

                              </action>

                      </package>

                       

                      We have made no changes to the ftls.

                       

                      But this refuses to get into the custom action class for all methods -prepare,execute,publish etc

                       

                      However, when the namespace is not given. it loads the page through the custom class-prepare,execute.

                      Other methods like publish,discard,copy happen from the default class only.

                       

                      Are we missing something fundamental related to namespacing?

                        • Re: Override struts login action in Jive 6
                          cwmenke Novice

                          Vysali Janardhanan,

                          I took a look at this with my team and what you have above seems correct to us. I can't explain why you are seeing the behavior you mention above... perhaps it has to do with the implementation of your class? Maybe it would be worth trying to override a different action in community-actions-include just to prove it is working.

                           

                          Sorry I can't be of more help.

                          Kit

                            • Re: Override struts login action in Jive 6
                              Vysali_Janardhanan Novice

                              Kit Menke,

                               

                              We were not able to zero down on the problem.

                              However, found a small workaround in the way the action is being called from the customize-container.ftl.

                              instead of

                                   <form action="<@s.url action='customize-container'/>">

                              we made it:

                                   <form action="<@s.url value='customize-container.jspa'/>">

                              This solved the problem.

                              Though it still doesn't explain why the generic approach dint work.

                               

                              Thanks for taking the time.

                              Vysali.

                    • Re: Override struts login action in Jive 6
                      Ryan Rutan Guru

                      Kit,

                       

                      In Jive 6, there is no longer a struts action for the login process, but rather a  REST call to perform the actual login.  If all you are doing is a UI change, perhaps it makes sense for you to use a theme instead?