You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ManiKanta G <go...@gmail.com> on 2009/08/21 09:36:30 UTC

Problem with result returning from interceptor

Hi,

In my application actions are distributed into several namespaces using
Conventions plugin.
When a request come for an action in a namespace (other than default one,
say, myapp/admin/action-name), and when there is no user session found, I m
returning 'login', which is configured as global-result in the default
namespace. But I m getting exception saying 'No result found with name...'.

Result config:

<global-results> <result name="login" type="redirectAction">login</result>
</global-results>


Intercept() of interceptor:

 public String intercept(ActionInvocation invocation) throws Exception {


Map<String, Object> session =
invocation.getInvocationContext().getSession();

      User user = (User) session.get(Constants.USER_HANDLE);

   if(user == null) {

return "login";

  }else{

 invocation.invoke();

  }


}


Action is in other namespace (package) and so jsp. But the result is
configured in default namespace, as login result should be accessible from
any namespace.


I m not getting what is the mistake I m doing. Is there any this kind of
problem with conventions plugin?

Some one please help.

Regards,
ManiKanta G
twitter.com/manikantag

Re: Problem with result returning from interceptor

Posted by jcllings <jl...@gmail.com>.

jcllings wrote:
> 
> OK, I was able to get the config-browser to display the result. Is it OK
> to use chain, as I have below?  All I'm really trying to do is force the
> user to a specific page but I have to call an action to populate tables
> and list boxes and stuff on that page. 
> 
>         <global-results>
>             <result type="chain"
> name="login">/admin/funkycool.action</result>
>         </global-results>
> 
> 

I have some new and interesting behavior to report. Now that I have a global
result that shows up in the config browser, I can clear out my cookies and
perform an action using the config browser and the behavior is as expected.
I get routed to the /admin/funkycool.action which then sets up my page and
loads it. 

Problem is that it doesn't work if I try it from the web.  I should be able
to clear out the cookies and click on a link to an action in the page and it
would do the same thing, right?  This is not the case.  Any ideas?
-- 
View this message in context: http://www.nabble.com/Problem-with-result-returning-from-interceptor-tp25075486p25399579.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with result returning from interceptor

Posted by jcllings <jl...@gmail.com>.

jcllings wrote:
> 
> Hmmm.... on second thought, perhaps if it is a global-result, you should
> be able to see it on all actions?  Just a guess because I don't see that
> in my case. 
> 
> Jim C. 
> 

OK, I was able to get the config-browser to display the result. Is it OK to
use chain, as I have below?  All I'm really trying to do is force the user
to a specific page but I have to call an action to populate tables and list
boxes and stuff on that page. 

        <global-results>
            <result type="chain"
name="login">/admin/funkycool.action</result>
        </global-results>

-- 
View this message in context: http://www.nabble.com/Problem-with-result-returning-from-interceptor-tp25075486p25399361.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with result returning from interceptor

Posted by jcllings <jl...@gmail.com>.

jcllings wrote:
> 
> I don't think the config-browser can be used like this.  I have to select
> an
> action in order to see the results returned and this isn't an action. It's
> an interceptor. 
> 
> Jim C. 
> 

Hmmm.... on second thought, perhaps if it is a global-result, you should be
able to see it on all actions?  Just a guess because I don't see that in my
case. 

Jim C. 
-- 
View this message in context: http://www.nabble.com/Problem-with-result-returning-from-interceptor-tp25075486p25399254.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with result returning from interceptor

Posted by jcllings <jl...@gmail.com>.


 Check it out with the config-browser -- you should see on the results tab
if your login result is 
really there.

Chris

I don't think the config-browser can be used like this.  I have to select an
action in order to see the results returned and this isn't an action. It's
an interceptor. 

Jim C. 
-- 
View this message in context: http://www.nabble.com/Problem-with-result-returning-from-interceptor-tp25075486p25399111.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with result returning from interceptor

Posted by ManiKanta G <go...@gmail.com>.
Hi,

Sorry for my late reply. Yes I m setting the parent package property to the
default s2 package (not class package).

*struts.xml*
<struts>

    <!--===== Struts2 Configuration details =====-->
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.multipart.maxSize" value="-1"></constant>

    <!-- Set java templates as default theme -->
    <constant name="struts.ui.templateSuffix" value="java" />
    <constant name="struts.ui.theme" value="simple" />

    <!-- Other config -->
    <constant name="struts.multipart.saveDir" value="." />
    <constant name="struts.custom.i18n.resources" value="global-messages" />


    <!--===== Convention plug-in config =====-->
    <!-- list of action packages -->
    <constant name="struts.convention.action.packages"
value="com.sify.s2.action" />
    <constant name="struts.convention.default.parent.package"
value="s2-conv-default" />

    <!-- Set to scan only packages that start with the below value -->
    <constant name="struts.convention.package.locators.basePackage"
value="com.sify.s2.action" />
    <!--  <constant name="struts.convention.result.path" value="/jsp" /> -->

    <!--===== FullHibernateSession plug-in config =====-->
    <constant name="hibernatePlugin.configurationFiles"
value="hibernate.cfg.xml" />

    <!--===== Application' action config's =====-->
    <include file="s2-default.xml" />

</struts>

*s2-default.xml*

<struts>
 <package name="eawedan-conv-default" extends="convention-default"  >
        <result-types>
             <result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" default="true" />
        </result-types>

        <!-- interceptors & interceptor-stack configuration -->
        <interceptors>
            <interceptor name="auth"
class="com.sify.s2.interceptor.AuthInterceptor" />

            <!-- interceptor-stack with authentication -->
            <interceptor-stack name="userStack">
                <interceptor-ref name="auth" />
                <interceptor-ref name="params" />
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>

            <!-- interceptor-stack with out authentication -->
            <interceptor-stack name="guestStack">
                <interceptor-ref name="defaultStack" />
            </interceptor-stack>

        </interceptors>

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

        <!-- when an interceptor returns, the corresponding result in the
            global-results will be selected, if present  -->
        <global-results>
            <result name="ngo-login"
type="redirectAction">ngo-login</result>
            <result name="no-privilege"
type="redirectAction">no-privilege</result>
            <result name="no-admin-privilege"
type="redirectAction">no-admin-privilege</result>
            <result name="error"
type="dispatcher">/WEB-INF/content/error/excep.jsp</result>
            <result
name="invalid.token">/WEB-INF/content/error/error.jsp</result>
        </global-results>
        <!-- global exceptions -->
        <global-exception-mappings>
            <exception-mapping result="error"
exception="java.lang.Throwable"/>
        </global-exception-mappings>

        <action name="ngo-login" >
            <result
type="dispatcher">/WEB-INF/content/ngo-login.jsp</result>
        </action>
    </package>
</struts>


Please help.

Regards,
ManiKanta G
twitter.com/manikantag


On Fri, Aug 21, 2009 at 7:32 PM, <mu...@aol.com> wrote:

>
>  Check it out with the config-browser -- you should see on the results tab
> if your login result is
> really there.
>
>
>
>
>
> Chris
>
>
>
>
>
>
> -----Original Message-----
> From: ManiKanta G <go...@gmail.com>
> To: Struts-User <us...@struts.apache.org>
> Sent: Fri, Aug 21, 2009 3:36 am
> Subject: Problem with result returning from interceptor
>
>
>
>
>
>
>
>
>
>
> Hi,
>
> In my application actions are distributed into several namespaces using
> Conventions plugin.
> When a request come for an action in a namespace (other than default one,
> say, myapp/admin/action-name), and when there is no user session found, I m
> returning 'login', which is configured as global-result in the default
> namespace. But I m getting exception saying 'No result found with name...'.
>
> Result config:
>
> <global-results> <result name="login" type="redirectAction">login</result>
> </global-results>
>
>
> Intercept() of interceptor:
>
>  public String intercept(ActionInvocation invocation) throws Exception {
>
>
> Map<String, Object> session =
> invocation.getInvocationContext().getSession();
>
>      User user = (User) session.get(Constants.USER_HANDLE);
>
>   if(user == null) {
>
> return "login";
>
>  }else{
>
>  invocation.invoke();
>
>  }
>
>
> }
>
>
> Action is in other namespace (package) and so jsp. But the result is
> configured in default namespace, as login result should be accessible from
> any namespace.
>
>
> I m not getting what is the mistake I m doing. Is there any this kind of
> problem with conventions plugin?
>
> Some one please help.
>
> Regards,
> ManiKanta G
> twitter.com/manikantag
>
>
>
>
>
>

Re: Problem with result returning from interceptor

Posted by mu...@aol.com.
 Check it out with the config-browser -- you should see on the results tab if your login result is 
really there.


 


Chris

 


 

-----Original Message-----
From: ManiKanta G <go...@gmail.com>
To: Struts-User <us...@struts.apache.org>
Sent: Fri, Aug 21, 2009 3:36 am
Subject: Problem with result returning from interceptor










Hi,

In my application actions are distributed into several namespaces using
Conventions plugin.
When a request come for an action in a namespace (other than default one,
say, myapp/admin/action-name), and when there is no user session found, I m
returning 'login', which is configured as global-result in the default
namespace. But I m getting exception saying 'No result found with name...'.

Result config:

<global-results> <result name="login" type="redirectAction">login</result>
</global-results>


Intercept() of interceptor:

 public String intercept(ActionInvocation invocation) throws Exception {


Map<String, Object> session =
invocation.getInvocationContext().getSession();

      User user = (User) session.get(Constants.USER_HANDLE);

   if(user == null) {

return "login";

  }else{

 invocation.invoke();

  }


}


Action is in other namespace (package) and so jsp. But the result is
configured in default namespace, as login result should be accessible from
any namespace.


I m not getting what is the mistake I m doing. Is there any this kind of
problem with conventions plugin?

Some one please help.

Regards,
ManiKanta G
twitter.com/manikantag



 


Re: Problem with result returning from interceptor

Posted by Wes Wannemacher <we...@wantii.com>.
The conventions plugin reads a property called -

struts.convention.default.parent.package

Are you setting this property to the package that declares the global-result?

-Wes

On Fri, Aug 21, 2009 at 3:36 AM, ManiKanta G<go...@gmail.com> wrote:
> Hi,
>
> In my application actions are distributed into several namespaces using
> Conventions plugin.
> When a request come for an action in a namespace (other than default one,
> say, myapp/admin/action-name), and when there is no user session found, I m
> returning 'login', which is configured as global-result in the default
> namespace. But I m getting exception saying 'No result found with name...'.
>
> Result config:
>
> <global-results> <result name="login" type="redirectAction">login</result>
> </global-results>
>
>
> Intercept() of interceptor:
>
>  public String intercept(ActionInvocation invocation) throws Exception {
>
>
> Map<String, Object> session =
> invocation.getInvocationContext().getSession();
>
>      User user = (User) session.get(Constants.USER_HANDLE);
>
>   if(user == null) {
>
> return "login";
>
>  }else{
>
>  invocation.invoke();
>
>  }
>
>
> }
>
>
> Action is in other namespace (package) and so jsp. But the result is
> configured in default namespace, as login result should be accessible from
> any namespace.
>
>
> I m not getting what is the mistake I m doing. Is there any this kind of
> problem with conventions plugin?
>
> Some one please help.
>
> Regards,
> ManiKanta G
> twitter.com/manikantag
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org