You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Akins <an...@gmail.com> on 2010/12/27 16:11:37 UTC

namespace vs package

Having trouble getting interceptors to work.  I think it's because my
namespace and packages aren't aligned correctly.  Using Convention
plugin and when I start the app I get an error that ref-name can't be
found.

My interceptor is defined in struts.xml

	<package name="default" extends="struts-default">

		<interceptors>
			<interceptor name="login"
				class="com.fiserv.sourceone.sigmm.interceptor.AuthorizationInterceptor" />
			<interceptor-stack name="defaultLoginStack">
				<interceptor-ref name="servletConfig" />
				<interceptor-ref name="params" />
				<interceptor-ref name="login" /> <!-- Custom Login Interceptor -->
				<interceptor-ref name="prepare" />
				<interceptor-ref name="chain" />
				<interceptor-ref name="fileUpload" />
				<interceptor-ref name="staticParams" />
				<interceptor-ref name="params" />
				<interceptor-ref name="conversionError" />
				<interceptor-ref name="validation" />
				<interceptor-ref name="workflow" />
			</interceptor-stack>

		</interceptors>
		<default-interceptor-ref name="defaultLoginStack" />

		<global-results>
			<result name="custom-error">/WEB-INF/content/custom-error.jsp</result>
		</global-results>
	</package>

Action is

package com.fiserv.sourceone.sigmm.actions.mobilemoney;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

@Namespace("")
@InterceptorRefs({
    @InterceptorRef("login")
})
public class MaintainParameters extends ActionSupport {

	private static final long serialVersionUID = -161735293208543752L;

	@Override
	@Action(value = "maintain-parameters", results = {
		@Result(name = SUCCESS, location =
"auth/maintain-parameters-success.jsp" ) } )
	public String execute()
	{
		return SUCCESS;
	}
}



-- 
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre

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


Re: namespace vs package

Posted by Dave Newton <da...@gmail.com>.
Yes, there's a default package, and its value is shown in the documentation
for the Convention plugin IIRC (which I may very well not, and I'm
struggling w/ limited Verizon connectivity on my Google CR-48 laptop at the
moment.)

Dave

(Like I how I just snuck in that part about the Google laptop? My geek cred
shot up like maybe a thousand percent when that thing showed on my doorstep,
so I gotta brag every now and then.)

On Mon, Dec 27, 2010 at 1:11 PM, Greg Akins <an...@gmail.com> wrote:

> On Mon, Dec 27, 2010 at 1:05 PM, Dave Newton <da...@gmail.com>
> wrote:
> > It *is* the default namespace, but almost always ends up being confusing
> at
> > some point. The minimal namespace I recommend is "/".
>
> OK.. that makes sense.
>
> > There's no direct relationship between package and namespace other than a
> > package has a namespace--I always figured it was to allow decoupling of
> > paths and packages.
>
> Here is what I'm having a tough time understanding.
>
> Those Actions in sigmm.actions are in the default namespace; and are
> in the a package by virtue of the <package name="" /> in the
> struts.xml in which they're configured.
>
> If I'm using the Convention plugin, is there a "default" package,
> assuming I haven't used @ParentPackage or the
> struts.convention.default.parent.package prop in struts.properties?
>
> What I want to do, if it makes sense, is have an Action in
> sigmm.actions.mobile and an interceptor class in sigmm.interceptors
> I'd expect the actions in mobile to be in the /mobile namespace; think
> they'd be in the sigmm.actions.mobile package and don't know what
> package/namespace the Interceptor would be in (Other than the java
> package sigmm.interceptors).
>
> --
> Greg Akins
>
> http://insomnia-consulting.org
> http://www.pghcodingdojo.org
> http://pittjug.dev.java.net
> http://twitter.com/akinsgre
> http://www.linkedin.com/in/akinsgre
>

Re: namespace vs package

Posted by Greg Akins <an...@gmail.com>.
On Mon, Dec 27, 2010 at 1:05 PM, Dave Newton <da...@gmail.com> wrote:
> It *is* the default namespace, but almost always ends up being confusing at
> some point. The minimal namespace I recommend is "/".

OK.. that makes sense.

> There's no direct relationship between package and namespace other than a
> package has a namespace--I always figured it was to allow decoupling of
> paths and packages.

Here is what I'm having a tough time understanding.

Those Actions in sigmm.actions are in the default namespace; and are
in the a package by virtue of the <package name="" /> in the
struts.xml in which they're configured.

If I'm using the Convention plugin, is there a "default" package,
assuming I haven't used @ParentPackage or the
struts.convention.default.parent.package prop in struts.properties?

What I want to do, if it makes sense, is have an Action in
sigmm.actions.mobile and an interceptor class in sigmm.interceptors
I'd expect the actions in mobile to be in the /mobile namespace; think
they'd be in the sigmm.actions.mobile package and don't know what
package/namespace the Interceptor would be in (Other than the java
package sigmm.interceptors).

-- 
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre

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


Re: namespace vs package

Posted by Dave Newton <da...@gmail.com>.
It *is* the default namespace, but almost always ends up being confusing at
some point. The minimal namespace I recommend is "/".

There's no direct relationship between package and namespace other than a
package has a namespace--I always figured it was to allow decoupling of
paths and packages.

Dave

On Mon, Dec 27, 2010 at 12:56 PM, Greg Akins <an...@gmail.com> wrote:

> On Mon, Dec 27, 2010 at 11:21 AM, Maurizio Cucchiara
> <ma...@gmail.com> wrote:
> > Did you try ParentPackage Annotation?
> > Also I'm not sure that empty string for namespace is the best value.
>
> No.
>
> I put them in the same package to get them working and figured I could
> experiment from there.
>
> I'm still a little confused about the relationship between namespace &
> package.  I thought the struts docs suggested an empty string as the
> "default" namespace.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: namespace vs package

Posted by Greg Akins <an...@gmail.com>.
On Mon, Dec 27, 2010 at 11:21 AM, Maurizio Cucchiara
<ma...@gmail.com> wrote:
> Did you try ParentPackage Annotation?
> Also I'm not sure that empty string for namespace is the best value.

No.

I put them in the same package to get them working and figured I could
experiment from there.

I'm still a little confused about the relationship between namespace &
package.  I thought the struts docs suggested an empty string as the
"default" namespace.

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


Re: namespace vs package

Posted by Maurizio Cucchiara <ma...@gmail.com>.
Did you try ParentPackage Annotation?
Also I'm not sure that empty string for namespace is the best value.

Maurizio Cucchiara

On Dec 27, 2010 4:12 PM, "Greg Akins" <an...@gmail.com> wrote:
> Having trouble getting interceptors to work. I think it's because my
> namespace and packages aren't aligned correctly. Using Convention
> plugin and when I start the app I get an error that ref-name can't be
> found.
>
> My interceptor is defined in struts.xml
>
> <package name="default" extends="struts-default">
>
> <interceptors>
> <interceptor name="login"
> class="com.fiserv.sourceone.sigmm.interceptor.AuthorizationInterceptor" />
> <interceptor-stack name="defaultLoginStack">
> <interceptor-ref name="servletConfig" />
> <interceptor-ref name="params" />
> <interceptor-ref name="login" /> <!-- Custom Login Interceptor -->
> <interceptor-ref name="prepare" />
> <interceptor-ref name="chain" />
> <interceptor-ref name="fileUpload" />
> <interceptor-ref name="staticParams" />
> <interceptor-ref name="params" />
> <interceptor-ref name="conversionError" />
> <interceptor-ref name="validation" />
> <interceptor-ref name="workflow" />
> </interceptor-stack>
>
> </interceptors>
> <default-interceptor-ref name="defaultLoginStack" />
>
> <global-results>
> <result name="custom-error">/WEB-INF/content/custom-error.jsp</result>
> </global-results>
> </package>
>
> Action is
>
> package com.fiserv.sourceone.sigmm.actions.mobilemoney;
>
> import org.apache.struts2.convention.annotation.Action;
> import org.apache.struts2.convention.annotation.InterceptorRef;
> import org.apache.struts2.convention.annotation.InterceptorRefs;
> import org.apache.struts2.convention.annotation.Namespace;
> import org.apache.struts2.convention.annotation.Result;
>
> import com.opensymphony.xwork2.ActionSupport;
>
> @Namespace("")
> @InterceptorRefs({
> @InterceptorRef("login")
> })
> public class MaintainParameters extends ActionSupport {
>
> private static final long serialVersionUID = -161735293208543752L;
>
> @Override
> @Action(value = "maintain-parameters", results = {
> @Result(name = SUCCESS, location =
> "auth/maintain-parameters-success.jsp" ) } )
> public String execute()
> {
> return SUCCESS;
> }
> }
>
>
>
> --
> Greg Akins
>
> http://insomnia-consulting.org
> http://www.pghcodingdojo.org
> http://pittjug.dev.java.net
> http://twitter.com/akinsgre
> http://www.linkedin.com/in/akinsgre
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>