Rest Plugin + IndexController and disabling content types

2008-08-30 Thread rakeshxp

Hi All,

I have 2 questions regarding the struts-rest plugin ( 2.1.3-snapshot)

1) How can I write a controller that will handle the request on / ( i.e
http://www.myhost.com )?

2) As I understand, the rest plugin by default handles XML and JSON
extensions too ( http://struts.apache.org/2.x/docs/rest-plugin.html ) . Is
there a way to disable these extensions ? ( Other than overriding
struts.rest.handlerOverride.EXTENSION and providing a dummy implementation )

Thanks!
-- 
View this message in context: 
http://www.nabble.com/Rest-Plugin-%2B-IndexController-and-disabling-content-types-tp19235492p19235492.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Result Annotations

2008-08-29 Thread rakeshxp

Hi,

I am using Result annotations in the following manner ( static way )
@Results({
@Result(name = index, value = /jsp/en_US/help.jsp)
})

How can I pass a dynamic value to the result annotation, so that I can
achieve something like this 
@Results({
@Result(name = index, value = /jsp/${locale}/help.jsp),
@Result(name = show, value = ${show} )
})
public class HelpController {
private String locale;
private String show;
...
}

Thanks!
-- 
View this message in context: 
http://www.nabble.com/Result-Annotations-tp19214472p19214472.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Result Annotations

2008-08-29 Thread rakeshxp

Awesome. This worked!

Thanks!


newton.dave wrote:
 
 --- On Fri, 8/29/08, rakeshxp wrote:
 I am using Result annotations in the following manner (static way )
 @Results({
 @Result(name = index, value =
 /jsp/en_US/help.jsp)
 })
 
 How can I pass a dynamic value to the result annotation, so
 that I can achieve something like this 

 @Results({
 @Result(name = index, value = /jsp/${locale}/help.jsp),
 @Result(name = show, value = ${show} )
 })
 public class HelpController {
 private String locale;
 private String show;
 ...
 }
 
 By either (a) providing getLocale()/getShow() methods or making
 locale/show public.
 
 The other response saying it wasn't possible is incorrect; while it's true
 that the annotations are scanned on startup, the value is evaluated at
 runtime. See [1] for more information; annotations share the same ability.
 
 Dave
 
 [1] Parameters in configuration results
 http://struts.apache.org/2.x/docs/parameters-in-configuration-results.html
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Result-Annotations-tp19214472p19220361.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts 2 Rest + Prevent Session creation

2008-08-28 Thread rakeshxp

Found the issue. I had missed adding 
%@ page contentType=text/html; charset=UTF-8 session=false
pageEncoding=UTF-8%
in the JSP page ( by default session is true ). Now no session is created (
and so no JSESSIONID cookie is set )

Thanks!


Jeromy Evans - Blue Sky Minds wrote:
 
 rakeshxp wrote:
 But this does not seem to work. When I hit any restful URL, then there is
 a
 JSESSIONID cookie being set. Could someone point out what is wrong with
 the
 above config ?

 Thanks!

   
 
 CodeBehind is responsible for setting up the packages.
 
 I don't know the history, but codebehind uses a separate property the 
 specify the default package.  Try setting both properties:
 
 constant name=struts.configuration.classpath.defaultParentPackage
 value=mydefault /
 
 constant name=struts.codebehind.defaultPackage value=mydefault /
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Struts-2-Rest-%2B-Prevent-Session-creation-tp19183756p19196465.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Struts 2 + Rest URLs

2008-08-27 Thread rakeshxp

Hi All,

I am migrating from struts 2.0.10 to 2.1.2 ( for need of restful URLs).
Could someone help me understand the following ?

1) Is it better to use Annotations or Codebehind for Restful URLs? ( I some
how like the annotations more than assuming some standard for resources)

2) I am stuck at running the restful URLs using codebehind plugin. Here are
the details: 
In web.xml, I have actionPackages = com.struts.example.action
and I have the following package struture:
com.struts.example.action - No files
com.struts.example.action.account - AccountController 
com.struts.example.action.help - HelpController 
expecting that, I will get the following URLs:
http://localhost:8080/myapp/account
http://localhost:8080/myapp/help

But this does not work. Could someone help me in figure out what is
happening ? Going forward, I wanted URLs of the following format
http://localhost:8080/myapp/account
http://localhost:8080/myapp/account/logout
http://localhost:8080/myapp/help
http://localhost:8080/myapp/displayname  ( so if it is not account or
help, then it would be a displayname and hence I want to process it
specifically ). 

Thanks!

-- 
View this message in context: 
http://www.nabble.com/Struts-2-%2B-Rest-URLs-tp19179856p19179856.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts 2 + Rest URLs

2008-08-27 Thread rakeshxp

Excellent. Thanks! So now, I have the following
com.struts.example.action.AccountController 
com.struts.example.action.account.LogoutController

When I hit, http://localhost:8080/myapp/account/logout , then I get the
following exception
 No result defined for action
com.struts.example.action.account.LogoutController and result index
The LogoutController looks like this:
 public HttpHeaders index() {
return new DefaultHttpHeaders(index).disableCaching();
}

I have a logout-index.jsp directly under the webapp folder ( along with
account-show.jsp, help-show.jsp etc ). So is it the proper name structure ?
Also, 

1) How to specify the location of the JSPs ?  
   I wanted to have custom folders like this 
   i18n/en_US/help/index.jsp
   i18n/en_US/help/show.jsp
   i18n/en_US/account/show.jsp
   i18n/en_US/account/logout.jsp etc 
So that I can problematically serve the appropriate locale JSPs ( When using
struts 2.0.10, in the action XML, I was using something like this result
name=success/jsp/i18n/${userLocale}/account/show.jsp/result )

2) The reason I wanted /displayname is something like this 
http://localhost/myapp/help - help pages
 some more static pages
anything which does not match the above, could potentially be a profile page
which has the url http://localhost/myapp/username. So I wanted something
like catch all , so that I can check if it happens to be a username.

3) Just curious, when running the above code, while tomcat was starting, I
was getting 
class:class com.struts.example.action.AccountController parent:null
current:com.struts.example.action.
class:class com.struts.example.action.account.LogoutController parent:null
current:com.struts.example.action.account

what does parent property mean ? 

Thanks!  


Jeromy Evans - Blue Sky Minds wrote:
 
 rakeshxp wrote:
 Hi All,

 I am migrating from struts 2.0.10 to 2.1.2 ( for need of restful URLs).
 Could someone help me understand the following ?

 1) Is it better to use Annotations or Codebehind for Restful URLs? ( I
 some
 how like the annotations more than assuming some standard for resources)

   
 
 This is a approach is fine. The annotations are a feature of CodeBehind 
 in 2.1 (used by CodeBehind to create the configuration)
 Note that CodeBehind will be replaced by the ConventionPlugin in 2.2ish 
 but the annotations won't need to change (much...).
 
 2) I am stuck at running the restful URLs using codebehind plugin. Here
 are
 the details: 
 In web.xml, I have actionPackages = com.struts.example.action
 and I have the following package struture:
 com.struts.example.action - No files
 com.struts.example.action.account - AccountController 
 com.struts.example.action.help - HelpController 
 expecting that, I will get the following URLs:
 http://localhost:8080/myapp/account
   
 
 Close, but not quite right. It works like this:
 com.struts.example.action.AccountController will be at  
 http://localhost:8080/myapp/account
 com.struts.example.action.account.AccountController will be at  
 http://localhost:8080/myapp/account/account
 
 http://localhost:8080/myapp/help

 But this does not work. Could someone help me in figure out what is
 happening ? Going forward, I wanted URLs of the following format
 http://localhost:8080/myapp/account
 http://localhost:8080/myapp/account/logout
 http://localhost:8080/myapp/help
 http://localhost:8080/myapp/displayname  ( so if it is not account or
 help, then it would be a displayname and hence I want to process it
 specifically ). 

   
 
 CodeBehind itself doesn't include any support for index actions, so you 
 have to set this as follows:
 
 com.struts.example.action.AccountController -  
 http://localhost:8080/myapp/account
 com.struts.example.action.account.LogoutController -  
 http://localhost:8080/myapp/account/logout
 com.struts.example.action.HelpController -  
 http://localhost:8080/myapp/help
 
 Not sure what you mean with display need.  You probably need this:
 
 com.struts.example.action.DisplayController -  
 http://localhost:8080/myapp/display/displayname
 
 Where displayname will be set as an ID for the DisplayController
 Otherwise you'll need to customize the actionmapper a little.
 
 Hope that helps.
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Struts-2-%2B-Rest-URLs-tp19179856p19180492.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts 2 + Rest URLs

2008-08-27 Thread rakeshxp




Jeromy Evans - Blue Sky Minds wrote:
 
 This is a approach is fine. The annotations are a feature of CodeBehind 
 in 2.1 (used by CodeBehind to create the configuration)
 Note that CodeBehind will be replaced by the ConventionPlugin in 2.2ish 
 but the annotations won't need to change (much...).
 

Regarding annotations, is it given higher preference than Codebehind? So for
example, can I create a LogoutController in
com.struts.example.action.xyz.LogoutController ( instead of
com.struts.example.action.account.LogoutController ) and have this
annotation?
@Namespace(value=/account/logout)

Thanks!


-- 
View this message in context: 
http://www.nabble.com/Struts-2-%2B-Rest-URLs-tp19179856p19180602.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts 2 + Rest URLs

2008-08-27 Thread rakeshxp

I think I am beginning to understand this plugin :)

One issue that I am stuck at is that, assuming I have only 1 class
com.struts.example.action.AccountController , then 
http://localhost:8080/myapp/account and
http://localhost:8080/myapp/account/1 ( maps to show ) works.

But the moment I have a sub controller
com.struts.example.action.account.LogoutController , then 
http://localhost:8080/myapp/account/1  == # There is no Action mapped for
namespace /account and action name 1.
( though http://localhost:8080/myapp/account and
http://localhost:8080/myapp/account/logout still works )

Thanks!



Jeromy Evans - Blue Sky Minds wrote:
 
 rakeshxp wrote:


 Jeromy Evans - Blue Sky Minds wrote:
   
 This is a approach is fine. The annotations are a feature of CodeBehind 
 in 2.1 (used by CodeBehind to create the configuration)
 Note that CodeBehind will be replaced by the ConventionPlugin in 2.2ish 
 but the annotations won't need to change (much...).

 

 Regarding annotations, is it given higher preference than Codebehind? So
 for
 example, can I create a LogoutController in
 com.struts.example.action.xyz.LogoutController ( instead of
 com.struts.example.action.account.LogoutController ) and have this
 annotation?
 @Namespace(value=/account/logout)

 Thanks!


   
 
 Yes.  The CodeBehind plugin checks for the presence of the annotation 
 when generating the namespace and gives precedence to the annotation.
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Struts-2-%2B-Rest-URLs-tp19179856p19183626.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Struts 2 Rest + Prevent Session creation

2008-08-27 Thread rakeshxp

Creating a new post for a new query on struts 2 rest plugin.

In my current app ( built on struts 2.0.10), I have a custom interceptor
stack ( which is set as default-interceptor-ref ). the code looks like this:
 package name=mydefault extends=struts-default namespace=/
   interceptor-stack name=myStack
interceptor-ref name=exception
  true
  WARN
/interceptor-ref
interceptor-ref name=servletConfig /
interceptor-ref name=params /
interceptor-ref name=conversionError /
   /interceptor-stack
 /interceptors
  default-interceptor-ref name=myStack/
 /package

This custom stack prevent any http session from being created ( and hence no
JSESSIONID cookie is created). 

I am trying to simulate the same for the newer code that I am writing (
based on struts 2.1.2 and rest plugin). I have the following entry in
struts.xml

constant name=struts.codebehind.defaultPackage value=mydefault /
constant name=struts.configuration.xml.reload value=true /

constant name=struts.configuration.classpath.defaultParentPackage
value=mydefault /
package name=mydefault extends=rest-default namespace=/
   interceptor-stack name=myStack
interceptor-ref name=exception
  true
  WARN
/interceptor-ref
interceptor-ref name=servletConfig /
interceptor-ref name=params /
interceptor-ref name=conversionError /
   /interceptor-stack
 /interceptors
  default-interceptor-ref name=myStack/
 /package

But this does not seem to work. When I hit any restful URL, then there is a
JSESSIONID cookie being set. Could someone point out what is wrong with the
above config ?

Thanks!

-- 
View this message in context: 
http://www.nabble.com/Struts-2-Rest-%2B-Prevent-Session-creation-tp19183756p19183756.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Struts2 + Profiling

2007-09-17 Thread rakeshxp

Hello Everyone,

I am using Struts 2.0.9. I want to disable profiling for my application and
have the following properties configured to set so


In Struts.xml
constant name=struts.devMode value=false /
The interceptors in my stack are 
interceptor-ref name=exception /
interceptor-ref name=servletConfig /
interceptor-ref name=prepare /
interceptor-ref name=params /
interceptor-ref name=conversionError /


The problem is when I was profiling my application using JProfiler, I could
see lot of calls to
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile in the call
tree. This is weired as I hoped the profiler is disabled due to
devMode=false and not having profile interceptor in my stack.

Could any one help me understand why I am seeing so many calls to the
UtilTimerStack.profile when I have disabled profiler ?

Thanks,
Rakesh
-- 
View this message in context: 
http://www.nabble.com/Struts2-%2B-Profiling-tf4469726.html#a12744304
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts 2 URL parameters lost - final status

2007-08-15 Thread rakeshxp

I am using Struts 2.0.6 and the jar contains struts struts-default.xml which
contains the following property 
bean type=org.apache.struts2.dispatcher.mapper.ActionMapper name=struts
class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper /
bean type=org.apache.struts2.dispatcher.mapper.ActionMapper
name=composite
class=org.apache.struts2.dispatcher.mapper.CompositeActionMapper /
bean type=org.apache.struts2.dispatcher.mapper.ActionMapper
name=restful
class=org.apache.struts2.dispatcher.mapper.RestfulActionMapper /
bean type=org.apache.struts2.dispatcher.mapper.ActionMapper
name=restful2
class=org.apache.struts2.dispatcher.mapper.Restful2ActionMapper /

We have a struts.xml in WEB-INF/classes folder and I was trying to override
the default actionmapper by having the following lines in my struts.xml (
just for testing I am overriding with the default class itself )
bean type=org.apache.struts2.dispatcher.mapper.ActionMapper name=struts
class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper /

But this results in an error when I started up tomcat
Unable to load bean: type:org.apache.struts2.dispatcher.mapper.ActionMapper
class:org.apache.struts2.dispatcher.mapper.DefaultActionMapper - bean -
file:/C:/software/tomcat6/webapps/abc/WEB-INF/classes/struts.xml:17:149

Caused by: Bean type interface
org.apache.struts2.dispatcher.mapper.ActionMapper with the name struts has
already been loaded by [unknown location] - bean -
file:/C:/software/tomcat6/webapps/abc/WEB-INF/classes/struts.xml:17:149

So the question that I have are 
1) How do I override the mapping class ?
2) Why are there 4 bean declaration for actionmapper ? 

thanks in advance!



JBL wrote:
 
 Final answer: we implemented a custom ActionMapper that handles a URL
 string that doesn't involve a ? to separate the query parameters. Stuck a
 reference to it in struts.properties:
 
 struts.mapper.class=mypackage.MyActionMapper
 
 Building a new ActionMapper isn't terribly difficult. It helps to define
 your expected URLs with a regular expression, then use a precompiled
 pattern. Ours looks something like:
 
 private static String NAMESPACE_REGEX = ...;
 private static String ACTION_REGEX = ...;
 private static String METHOD_REGEX = ...;
 private static String PARAMS_REGEX = ...;
 
 private static String URI_REGEX = (concatenate the four above)
 
 private static Pattern URI_PATTERN = Pattern.compile(URI_REGEX);
 
 Then, in getMapping(), pull out the URI (similar to DefaultActionMapper)
 and call
 
 Matcher m = URI_PATTERN.matcher(uri);
 
 If you get a match, create a new ActionMapping and set its components
 based on the matching groups:
 
 mapping.setNamespace(m.group(1));
 mapping.setName(m.group(1));
 
 etc.
 
 You can parse the parameter section and build a map to pass to
 mapping.setParams().
 
 Using a precompiled pattern may or may not be the most efficient possible
 solution, but it helps you define exactly what URIs you expect. I
 recommend throwing a bunch of possibilities at it in your unit test code
 with various components present and missing. If you're a little unsure
 about regular expressions, build some unit tests for those, too. Sun has a
 decent write-up in their Java documentation:
 
 http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html
 
 Especially read the Groups and Capturing section, it's a handy tool to
 have in your portfolio.
 
 We may yet discover why we couldn't get query parameters, but this works
 for now. Good luck.
 

-- 
View this message in context: 
http://www.nabble.com/Struts-2-URL-parameters-lost-tf4196254.html#a12160600
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Struts2 + Dynamic Forms + File Upload

2007-08-06 Thread rakeshxp

Hi,

I am trying to create a form which would have dynamic number of file tag (
this would be created by the JS ). I am looking for a way to do so in
struts. 

I have created the following class 
public class FileDetails {
private File file;

private String contentType;

private String filename;

public void setUpload(File file) {
this.file = file;
}

public void setUploadContentType(String contentType) {
this.contentType = contentType;
}

public void setUploadFileName(String filename) {
this.filename = filename;
}
}

And in my action class I am trying to do 

 private ListFileDetails beanList = new ArrayListFileDetails();
public ListFileDetails getBeanList() {
return beanList;
}

public void setBeanList(ListFileDetails beanList) {
this.beanList = beanList;
}

And in the JSP,
s:form namespace=/xyz action=doUpload method=post
enctype=multipart/form-data
  s:file name=beanList(0).upload value=%{value} /  
  s:file name=beanList(1).upload value=%{value} /  
  s:submit/
 /s:form

Above method does work as it results in lot of OGNL errors like 
[ERROR] XWorkMethodAccessor - An unexpected exception occurred
ognl.OgnlException: Error getting property descriptor:
nullognl.OgnlException: E
rror getting property descriptor: null
at
com.opensymphony.xwork2.util.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:92)
at
com.opensymphony.xwork2.util.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:61)

Could any one suggest a solution to my problem ?
-- 
View this message in context: 
http://www.nabble.com/Struts2-%2B-Dynamic-Forms-%2B-File-Upload-tf4226132.html#a12022372
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]