unit testing with junit + spring + struts2, NullPointerException with HttpServletRequest

2011-05-13 Thread Jake Vang
hi,

i am using struts v2.1.8.1 + spring 3.0 + junit 4.0. it should be
noted that i am using convention plugin for spring.

my action class extends ActionSupport and implements
ServletRequestAware and ServletResponseAware. the method i am testing
inside my action class never returns a string literal (i.e. succes,
error, input, etc...), and always returns null. the reason is that i
am not forwarding users to any JSP page, but instead, i am writing
JSON results back out to the response stream.

i need to test my action class, and i have a test class that extends
StrutsSpringTestCase. i followed the example at
http://struts.apache.org/2.1.8.1/docs/struts-2-junit-plugin-tutorial.html,
which was very helpful. however, when my code writes JSON back out
using ServletOutputStream, i get a NullPointerException. The
NullPointerException happens because the HttpServletResponse is null.
(i.e. null pointer happens on ServletOutputStream os =
getHttpServletResponse().getOutputStream()).

is there a step i am missing here that explains why the
HttpServletResponse object/field is null?

is there anyway to test action classes that do not return the usual
string literals but the contents of the output stream?

thank you in advance.

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



Re: unit testing with junit + spring + struts2, NullPointerException with HttpServletRequest

2011-05-13 Thread Jake Vang
never mind, i tinkered a little bit and read the API docs. if anyone
is interested, here's what i did.

ActionProxy proxy = getActionProxy(/dummy-action);
MyAction action = (MyAction)proxy.getAction();

MockHttpServletResponse response = new MockHttpServletResponse();
action.setServletResponse(response);

String result = action.dummyAction();
Assert.assertNull(result); //should always be null

String json = response.getContentAsString();
Assert.assertNotNull(json); //shouldn't be null

On Fri, May 13, 2011 at 2:58 PM, Jake Vang vangj...@googlemail.com wrote:
 hi,

 i am using struts v2.1.8.1 + spring 3.0 + junit 4.0. it should be
 noted that i am using convention plugin for spring.

 my action class extends ActionSupport and implements
 ServletRequestAware and ServletResponseAware. the method i am testing
 inside my action class never returns a string literal (i.e. succes,
 error, input, etc...), and always returns null. the reason is that i
 am not forwarding users to any JSP page, but instead, i am writing
 JSON results back out to the response stream.

 i need to test my action class, and i have a test class that extends
 StrutsSpringTestCase. i followed the example at
 http://struts.apache.org/2.1.8.1/docs/struts-2-junit-plugin-tutorial.html,
 which was very helpful. however, when my code writes JSON back out
 using ServletOutputStream, i get a NullPointerException. The
 NullPointerException happens because the HttpServletResponse is null.
 (i.e. null pointer happens on ServletOutputStream os =
 getHttpServletResponse().getOutputStream()).

 is there a step i am missing here that explains why the
 HttpServletResponse object/field is null?

 is there anyway to test action classes that do not return the usual
 string literals but the contents of the output stream?

 thank you in advance.


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



Re: streaming plain text, json, xml back to the user, IllegalStateException

2011-04-27 Thread Jake Vang
Pawel, you know of anything like this but for the convention plugin? I
don't use XML anymore. In fact, I've gotten away a lot with almost a
purely annotation based approach. In fact, my struts.xml is 4-5 lines
only.

2011/4/26 Paweł Wielgus poulw...@gmail.com:
 Hi Jake,
 maybe this aproach would help You:
 http://struts.apache.org/2.2.1.1/docs/stream-result.html

 Best greetings,
 Paweł Wielgus.


 2011/4/24 Jake Vang vangj...@googlemail.com:
 Dave,

 is there anyway to set it up so that the session can be created and
 not destroyed when i return null?

 i am finding out that when i stream back an image (CAPTCHA) this time
 (not json/xml/text as before), i need to store the answer in the
 session. even if i do session.setAttribute(captcha-answer,answer),
 when another action is called, there is nothing in the session i.e.
 session.getAttribute(captcha-answer) is null.

 the only way i can get a session object properly is if i go to an
 action where a JSP page is rendered.

 Thanks,

 On Sat, Apr 23, 2011 at 12:11 AM, Dave Newton davelnew...@gmail.com wrote:
 My first guess would be to return null so you're not rendering a jsp after
 the output stream is closed.

 Dave
  On Apr 22, 2011 11:49 PM, Jake Vang vangj...@googlemail.com wrote:
 what i did to get rid of this message was to add the following line
 before i do anything.

 getSerlvetRequest().getSession();

 that means anytime this method is called i make the two method calls
 above. i'm not sure what the impact on performance will be. but for
 now, it gets rid of the message. if anyone has a better suggestion,
 please let me know.

 On Fri, Apr 22, 2011 at 11:22 PM, Jake Vang vangj...@googlemail.com
 wrote:
 i am using struts 2 with the convention plugin. i have a bunch of
 actions that streams back plain text, json or xml. however, when a
 user goes to a certain URL, i keep seeing an IllegalStateException :
 Cannot create a session after the response has been committed.

 why is this happening?

 my action class and the method is defined like the following:

 public class MyAction extends ActionSupport implements
 ServletRequestAware, ServletResponseAware {
  @Action(value=/myService)
  public String execute() {
  HttpServletResponse response = getServletResponse();
  ServletOutputStream os = response.getOutputStream();
  response.reset();
  response.setContentType(text/plain);
  os.write(some text.getBytes());
  os.close();
  return SUCCESS;
  }
 }

 there is a file corresponding to this action in
 /web/WEB-INF/content/myService-success.jsp. this file is blank.

 one thing i noticed is that if i go to a URL that does not stream back
 plain text, json, or xml (for example, one that forwards to a JSP
 page), and then go back to /myService, the problem goes away. i
 think that when i go to a regular URL (one that forwards to a JSP
 page), the session object is created, and so whenever i go back to
 /myService, the problem goes away.

 my webapp will primarily be a backend service, and so there won't be
 any JSP front-ends. but i'd like to use struts2 + convention plugin to
 handle all the data posts. any pointer is appreciated. the full
 stacktrace is below. any help is appreciated.

 java.lang.IllegalStateException: Cannot create a session after the
 response has been committed
        at
 org.apache.catalina.connector.Request.doGetSession(Request.java:2381)
        at
 org.apache.catalina.connector.Request.getSession(Request.java:2098)
        at
 org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
        at
 javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
        at
 org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
        at
 org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:493)
        at
 javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:224)
        at
 org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:146)
        at
 org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:124)
        at
 org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:107)
        at
 org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:63)
        at
 org.apache.jsp.WEB_002dINF.content.locationService_002dsuccess_jsp._jspService(locationService_002dsuccess_js
 p.java:44)
        at
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
        at
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        at
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717

Re: streaming plain text, json, xml back to the user, IllegalStateException

2011-04-24 Thread Jake Vang
Dave,

is there anyway to set it up so that the session can be created and
not destroyed when i return null?

i am finding out that when i stream back an image (CAPTCHA) this time
(not json/xml/text as before), i need to store the answer in the
session. even if i do session.setAttribute(captcha-answer,answer),
when another action is called, there is nothing in the session i.e.
session.getAttribute(captcha-answer) is null.

the only way i can get a session object properly is if i go to an
action where a JSP page is rendered.

Thanks,

On Sat, Apr 23, 2011 at 12:11 AM, Dave Newton davelnew...@gmail.com wrote:
 My first guess would be to return null so you're not rendering a jsp after
 the output stream is closed.

 Dave
  On Apr 22, 2011 11:49 PM, Jake Vang vangj...@googlemail.com wrote:
 what i did to get rid of this message was to add the following line
 before i do anything.

 getSerlvetRequest().getSession();

 that means anytime this method is called i make the two method calls
 above. i'm not sure what the impact on performance will be. but for
 now, it gets rid of the message. if anyone has a better suggestion,
 please let me know.

 On Fri, Apr 22, 2011 at 11:22 PM, Jake Vang vangj...@googlemail.com
 wrote:
 i am using struts 2 with the convention plugin. i have a bunch of
 actions that streams back plain text, json or xml. however, when a
 user goes to a certain URL, i keep seeing an IllegalStateException :
 Cannot create a session after the response has been committed.

 why is this happening?

 my action class and the method is defined like the following:

 public class MyAction extends ActionSupport implements
 ServletRequestAware, ServletResponseAware {
  @Action(value=/myService)
  public String execute() {
  HttpServletResponse response = getServletResponse();
  ServletOutputStream os = response.getOutputStream();
  response.reset();
  response.setContentType(text/plain);
  os.write(some text.getBytes());
  os.close();
  return SUCCESS;
  }
 }

 there is a file corresponding to this action in
 /web/WEB-INF/content/myService-success.jsp. this file is blank.

 one thing i noticed is that if i go to a URL that does not stream back
 plain text, json, or xml (for example, one that forwards to a JSP
 page), and then go back to /myService, the problem goes away. i
 think that when i go to a regular URL (one that forwards to a JSP
 page), the session object is created, and so whenever i go back to
 /myService, the problem goes away.

 my webapp will primarily be a backend service, and so there won't be
 any JSP front-ends. but i'd like to use struts2 + convention plugin to
 handle all the data posts. any pointer is appreciated. the full
 stacktrace is below. any help is appreciated.

 java.lang.IllegalStateException: Cannot create a session after the
 response has been committed
        at
 org.apache.catalina.connector.Request.doGetSession(Request.java:2381)
        at
 org.apache.catalina.connector.Request.getSession(Request.java:2098)
        at
 org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
        at
 javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
        at
 org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
        at
 org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:493)
        at
 javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:224)
        at
 org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:146)
        at
 org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:124)
        at
 org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:107)
        at
 org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:63)
        at
 org.apache.jsp.WEB_002dINF.content.locationService_002dsuccess_jsp._jspService(locationService_002dsuccess_js
 p.java:44)
        at
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
        at
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        at
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
        at
 org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
        at
 org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java

streaming plain text, json, xml back to the user, IllegalStateException

2011-04-22 Thread Jake Vang
i am using struts 2 with the convention plugin. i have a bunch of
actions that streams back plain text, json or xml. however, when a
user goes to a certain URL, i keep seeing an IllegalStateException :
Cannot create a session after the response has been committed.

why is this happening?

my action class and the method is defined like the following:

public class MyAction extends ActionSupport implements
ServletRequestAware, ServletResponseAware {
 @Action(value=/myService)
 public String execute() {
  HttpServletResponse response = getServletResponse();
  ServletOutputStream os = response.getOutputStream();
  response.reset();
  response.setContentType(text/plain);
  os.write(some text.getBytes());
  os.close();
  return SUCCESS;
 }
}

there is a file corresponding to this action in
/web/WEB-INF/content/myService-success.jsp. this file is blank.

one thing i noticed is that if i go to a URL that does not stream back
plain text, json, or xml (for example, one that forwards to a JSP
page), and then go back to /myService, the problem goes away. i
think that when i go to a regular URL (one that forwards to a JSP
page), the session object is created, and so whenever i go back to
/myService, the problem goes away.

my webapp will primarily be a backend service, and so there won't be
any JSP front-ends. but i'd like to use struts2 + convention plugin to
handle all the data posts. any pointer is appreciated. the full
stacktrace is below. any help is appreciated.

java.lang.IllegalStateException: Cannot create a session after the
response has been committed
at org.apache.catalina.connector.Request.doGetSession(Request.java:2381)
at org.apache.catalina.connector.Request.getSession(Request.java:2098)
at 
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
at 
javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
at 
org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
at 
org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:493)
at 
javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:224)
at 
org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:146)
at 
org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:124)
at 
org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:107)
at 
org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:63)
at 
org.apache.jsp.WEB_002dINF.content.locationService_002dsuccess_jsp._jspService(locationService_002dsuccess_js
p.java:44)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at 
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at 
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at 
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at 
org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:156)
at 
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at 
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)
at 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
at 
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:16
5)
at 
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at 
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
at 
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInt
erceptor.java:68)
at 
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at 

Re: streaming plain text, json, xml back to the user, IllegalStateException

2011-04-22 Thread Jake Vang
what i did to get rid of this message was to add the following line
before i do anything.

getSerlvetRequest().getSession();

that means anytime this method is called i make the two method calls
above. i'm not sure what the impact on performance will be. but for
now, it gets rid of the message. if anyone has a better suggestion,
please let me know.

On Fri, Apr 22, 2011 at 11:22 PM, Jake Vang vangj...@googlemail.com wrote:
 i am using struts 2 with the convention plugin. i have a bunch of
 actions that streams back plain text, json or xml. however, when a
 user goes to a certain URL, i keep seeing an IllegalStateException :
 Cannot create a session after the response has been committed.

 why is this happening?

 my action class and the method is defined like the following:

 public class MyAction extends ActionSupport implements
 ServletRequestAware, ServletResponseAware {
  @Action(value=/myService)
  public String execute() {
  HttpServletResponse response = getServletResponse();
  ServletOutputStream os = response.getOutputStream();
  response.reset();
  response.setContentType(text/plain);
  os.write(some text.getBytes());
  os.close();
  return SUCCESS;
  }
 }

 there is a file corresponding to this action in
 /web/WEB-INF/content/myService-success.jsp. this file is blank.

 one thing i noticed is that if i go to a URL that does not stream back
 plain text, json, or xml (for example, one that forwards to a JSP
 page), and then go back to /myService, the problem goes away. i
 think that when i go to a regular URL (one that forwards to a JSP
 page), the session object is created, and so whenever i go back to
 /myService, the problem goes away.

 my webapp will primarily be a backend service, and so there won't be
 any JSP front-ends. but i'd like to use struts2 + convention plugin to
 handle all the data posts. any pointer is appreciated. the full
 stacktrace is below. any help is appreciated.

 java.lang.IllegalStateException: Cannot create a session after the
 response has been committed
        at 
 org.apache.catalina.connector.Request.doGetSession(Request.java:2381)
        at org.apache.catalina.connector.Request.getSession(Request.java:2098)
        at 
 org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
        at 
 javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
        at 
 org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
        at 
 org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:493)
        at 
 javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:224)
        at 
 org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:146)
        at 
 org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:124)
        at 
 org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:107)
        at 
 org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:63)
        at 
 org.apache.jsp.WEB_002dINF.content.locationService_002dsuccess_jsp._jspService(locationService_002dsuccess_js
 p.java:44)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at 
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
        at 
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at 
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at 
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at 
 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
        at 
 org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
        at 
 org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
        at 
 org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:156)
        at 
 org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
        at 
 com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)
        at 
 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
        at 
 com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:16
 5)
        at 
 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
        at 
 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237

Re: streaming plain text, json, xml back to the user, IllegalStateException

2011-04-22 Thread Jake Vang
Dave,

Yes, that works too. That is perhaps even more elegant. What I had was
a sort of a kludge. Per your suggestion, if I don't return SUCCESS and
return null, then that message doesn't appear. Another implication of
your solution is then I don't need to have an actionAlias-success.jsp.

Thank you so much.

On Sat, Apr 23, 2011 at 12:11 AM, Dave Newton davelnew...@gmail.com wrote:
 My first guess would be to return null so you're not rendering a jsp after
 the output stream is closed.

 Dave
  On Apr 22, 2011 11:49 PM, Jake Vang vangj...@googlemail.com wrote:
 what i did to get rid of this message was to add the following line
 before i do anything.

 getSerlvetRequest().getSession();

 that means anytime this method is called i make the two method calls
 above. i'm not sure what the impact on performance will be. but for
 now, it gets rid of the message. if anyone has a better suggestion,
 please let me know.

 On Fri, Apr 22, 2011 at 11:22 PM, Jake Vang vangj...@googlemail.com
 wrote:
 i am using struts 2 with the convention plugin. i have a bunch of
 actions that streams back plain text, json or xml. however, when a
 user goes to a certain URL, i keep seeing an IllegalStateException :
 Cannot create a session after the response has been committed.

 why is this happening?

 my action class and the method is defined like the following:

 public class MyAction extends ActionSupport implements
 ServletRequestAware, ServletResponseAware {
  @Action(value=/myService)
  public String execute() {
  HttpServletResponse response = getServletResponse();
  ServletOutputStream os = response.getOutputStream();
  response.reset();
  response.setContentType(text/plain);
  os.write(some text.getBytes());
  os.close();
  return SUCCESS;
  }
 }

 there is a file corresponding to this action in
 /web/WEB-INF/content/myService-success.jsp. this file is blank.

 one thing i noticed is that if i go to a URL that does not stream back
 plain text, json, or xml (for example, one that forwards to a JSP
 page), and then go back to /myService, the problem goes away. i
 think that when i go to a regular URL (one that forwards to a JSP
 page), the session object is created, and so whenever i go back to
 /myService, the problem goes away.

 my webapp will primarily be a backend service, and so there won't be
 any JSP front-ends. but i'd like to use struts2 + convention plugin to
 handle all the data posts. any pointer is appreciated. the full
 stacktrace is below. any help is appreciated.

 java.lang.IllegalStateException: Cannot create a session after the
 response has been committed
        at
 org.apache.catalina.connector.Request.doGetSession(Request.java:2381)
        at
 org.apache.catalina.connector.Request.getSession(Request.java:2098)
        at
 org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
        at
 javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
        at
 org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
        at
 org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:493)
        at
 javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:224)
        at
 org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:146)
        at
 org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:124)
        at
 org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:107)
        at
 org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:63)
        at
 org.apache.jsp.WEB_002dINF.content.locationService_002dsuccess_jsp._jspService(locationService_002dsuccess_js
 p.java:44)
        at
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
        at
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        at
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
        at
 org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
        at
 org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
        at
 org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:156)
        at
 org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186

how to access spring beans from inside a custom validator

2010-11-01 Thread Jake Vang
i have a custom field validator that extends FieldValidatorSupport.
inside this class, i need to access some beans as defined in
applicationContext.xml by Spring. how do i access the spring managed
beans? any help is appreciated.

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



Re: how to access spring beans from inside a custom validator

2010-11-01 Thread Jake Vang
Eduard,

I tried that. I thought spring would inject the field, but I keep
getting a NullPointer (after I get the field and try to use it). Are
there any other configurations that I need in web.xml? Right now,
among other things, I have the listener
org.springframework.web.context.ContextLoaderListener  defined in
web.xml.

Thanks,

On Mon, Nov 1, 2010 at 4:17 AM, Eduard Neuwirt
eduard.neuw...@googlemail.com wrote:
 Hello Jake,

 It is simple.
 Use struts/spring plug in.
 Declare your bean within your validator and let spring inject your
 validator.

 That's all

 Regards
 Eduard
 P.S.: Do not forget to define the corresponding setter method for injection

 Am 01.11.2010 08:37, schrieb Jake Vang:

 i have a custom field validator that extends FieldValidatorSupport.
 inside this class, i need to access some beans as defined in
 applicationContext.xml by Spring. how do i access the spring managed
 beans? any help is appreciated.

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


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



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



Re: Struts2 validation

2010-07-13 Thread jake
You can use the fieldexpression validator. See 
http://struts.apache.org/2.1.8.1/docs/fieldexpression-validator.html for 
details.

On Tue, Jul 13, 2010 at 05:39:52AM -0700, kisja wrote:
 
 I have two textfield and I would like to validate that at least one of both
 have data. 
 How I can do? 
 
 (I apologize for my bad English)
 
 Thanks
 -- 
 View this message in context: 
 http://old.nabble.com/Struts2-validation-tp29149892p29149892.html
 Sent from the Struts - User mailing list archive at Nabble.com.
 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org
 

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



Re: validating integer, java.lang.NoSuchMethodException

2010-07-12 Thread Jake Vang
a workaround to this problem is to have a string field in the Action
class to represent MyPojo.integer. using this approach, the second set
of validation rules below work 100% and i no longer see the
NoSuchMethodException. however, the drawback is that now i have to
transfer this to my backing bean.

oh well, you win some, you lose some. if anyone has a better idea,
please let me know.

thanks.

On Mon, Jul 12, 2010 at 11:26 AM, Jake Vang vangj...@googlemail.com wrote:
 hi,

 i am trying to validate an integer field (int primitive type) on a
 POJO (i.e. MyPojo.integer). i have the validation defined in
 ActionClass-alias-validation.xml as follows.

 ...
 field name=myPojo.integer
  field-validator type=required
  messageInteger is required!/message
  /field-validator
 /field
 ...

 when the form posts to the action, if the value of s:textfield
 name=myPojo.integer/ is left blank, i keep seeing a
 java.lang.NoSuchMethodException:
 MyPojo.setInteger([Ljava.lang.String;). why is struts trying to insert
 a string into this int field?  the field value is blank (empty), so
 i'd expect struts to be smart enough to see this and not try to insert
 anything and just return back to the form with the validation error.

 it should be very easy to define the following validation rules:
 1. myPojo.integer is required
 2. myPojo.integer is an integer

 however, it is NOT that easy. here's a set of validation rules that i
 tried and did not succeed.

 field name=myPojo.integer
  !-- this says myPojo.integer is required --
  field-validator type=required
  messageInteger is required!/message
  /field-validator
  !-- this says myPojo has to be a positive integer --
  field-validator type=regex
  param name=expression![CDATA[^\d+$]]/param
  messagePlease enter an integer!/message
  /field-validator
 /field

 when i use this set of validation rules, i also observe the same
 NoSuchMethodException. this time, however, i do NOT see that the
 validation works (because I do not see the message, Integer is
 required!).

 something like the following works, but STILL, i see the
 NoSuchMethodException thrown if the field's value is left blank.
 ...
 field-validator type=int
  param name=min1/param
  param name=max10/param
  messageInteger must be between ${min} and ${max}, current value is
 ${myPojo.integer}./message
 /field-validator
 ...

 however, this last validation rule is absolutely the WORST one to use
 because if the value on the form is left blank, 1) i will see the
 NoSuchMethoException thrown and 2) if i allow for min=0 and max=10,
 the validation will never know if the user entered 0 or was the 0
 because there was no value!

 any ideas is appreciated. i already experimented a lot and did not
 come up with anything that is why this post is rather long.

 thanks.


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



validating integer, java.lang.NoSuchMethodException

2010-07-12 Thread Jake Vang
hi,

i am trying to validate an integer field (int primitive type) on a
POJO (i.e. MyPojo.integer). i have the validation defined in
ActionClass-alias-validation.xml as follows.

...
field name=myPojo.integer
 field-validator type=required
  messageInteger is required!/message
 /field-validator
/field
...

when the form posts to the action, if the value of s:textfield
name=myPojo.integer/ is left blank, i keep seeing a
java.lang.NoSuchMethodException:
MyPojo.setInteger([Ljava.lang.String;). why is struts trying to insert
a string into this int field?  the field value is blank (empty), so
i'd expect struts to be smart enough to see this and not try to insert
anything and just return back to the form with the validation error.

it should be very easy to define the following validation rules:
1. myPojo.integer is required
2. myPojo.integer is an integer

however, it is NOT that easy. here's a set of validation rules that i
tried and did not succeed.

field name=myPojo.integer
 !-- this says myPojo.integer is required --
 field-validator type=required
  messageInteger is required!/message
 /field-validator
 !-- this says myPojo has to be a positive integer --
 field-validator type=regex
  param name=expression![CDATA[^\d+$]]/param
  messagePlease enter an integer!/message
 /field-validator
/field

when i use this set of validation rules, i also observe the same
NoSuchMethodException. this time, however, i do NOT see that the
validation works (because I do not see the message, Integer is
required!).

something like the following works, but STILL, i see the
NoSuchMethodException thrown if the field's value is left blank.
...
field-validator type=int
 param name=min1/param
 param name=max10/param
 messageInteger must be between ${min} and ${max}, current value is
${myPojo.integer}./message
/field-validator
...

however, this last validation rule is absolutely the WORST one to use
because if the value on the form is left blank, 1) i will see the
NoSuchMethoException thrown and 2) if i allow for min=0 and max=10,
the validation will never know if the user entered 0 or was the 0
because there was no value!

any ideas is appreciated. i already experimented a lot and did not
come up with anything that is why this post is rather long.

thanks.

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



Re: validation and form display problem

2010-07-11 Thread Jake Vang
what i did was to override ValidationAware.hasErrors(). according to
the docs, the workflow interceptor calls this method, if there are
validation errors, it returns input and stops further execution of
the action. i tried this...

public boolean hasErrors() {
 boolean result = super.hasErrors();
 if(result) {
  //fetch data here
 }
 return result;
}

On Sun, Jul 11, 2010 at 7:23 AM, Burton Rhodes burtonrho...@gmail.com wrote:
 That sounds like a classic 'prepare' problem.  Take a look at the
 documentation on implementing Preparable in your action. You will want
 to initialize your backing beans inside the Prepare method in your
 action. That when 'input' is needed, your backing beans will be
 loaded.

 On 7/10/10, Jake Vang vangj...@googlemail.com wrote:
 i have a form that i display. but to display that form, i have to
 fetch some data from the database and then place that data on the
 valuestack (via backing beans). when the form is displayed, it expects
 that those backing beans should be populated. the form then posts to a
 save action.

 i have a className-alias-validation.xml that validates the form
 values. i have specified that if the result is input then go back to
 the form. the problem is that when the result is input and the
 form/page is reloaded, the beans are no longer populated and the form
 displays as blank.

 is there a way to intercept or is there a hook that i can grab to have
 an opportunity to populate my backing beans?

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



 --
 Sent from my mobile device

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



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



validation and form display problem

2010-07-10 Thread Jake Vang
i have a form that i display. but to display that form, i have to
fetch some data from the database and then place that data on the
valuestack (via backing beans). when the form is displayed, it expects
that those backing beans should be populated. the form then posts to a
save action.

i have a className-alias-validation.xml that validates the form
values. i have specified that if the result is input then go back to
the form. the problem is that when the result is input and the
form/page is reloaded, the beans are no longer populated and the form
displays as blank.

is there a way to intercept or is there a hook that i can grab to have
an opportunity to populate my backing beans?

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



convention plugin requires setting @Result explicitly

2010-06-29 Thread Jake Vang
i have an Action class in the package
com.company.web.struts.actions.admin.LoginAction. inside LoginAction,
i use Annotation to specify the Action (i.e. @Action(value=/login)
on a method. according to the documentation at,
http://struts.apache.org/2.1.8.1/docs/convention-plugin.html, this
should map to /admin/login (i.e.
http://localhost:8080/webapp/admin/login, on Tomcat). however, i keep
seeing the message below.

No result defined for action
com.company.web.struts.actions.admin.LoginAction and result success

this message goes away if i specify the result explicitly (i.e.
@Action(value=/login,result...@result(name=success,location=login-success.jsp)}).
BUT, why do i have to explicitly specify the result? doesn't this
defeat the purpose of the Convention plugin?

for all my Action classes, so far, and using the Convention plugin, i
just simply specify @Action(value=/something), and it is smart
enough to forward to /something-success.jsp, /something-error.jsp,
/something-input.jsp, etc... without any explicit setting of the
@Result. any ideas is appreciated.

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



Re: convention plugin requires setting @Result explicitly

2010-06-29 Thread Jake Vang
i've been reading the doc over and over. and something is not working.
according to the doc, you can specify the Namespace and ResultPath in
the package-info.java file.

@Namespace(/admin)
package my.package

theoretically, all action class under this package (just this package
and no sub-packages) will now have this default namespace. however,
annotating at the package level inside package-info.java does not
work. i keep getting the exception No result defined for action ...
and result success for my action class. the URL mapping is working
(it says so in the doc), but now it is having trouble finding the
resource (i.e. login-success.jsp). from reading the doc, the
convention plugin will look for the resource in
/WEB-INF/content/admin/login-success.jsp. but this is not the case, it
will actually look for the resource in
/WEB-INF/content/login-success.jsp. unless you explicitly use the
@Result annotation, then it will look at the default result path. but
that is annoying because you have already specified the Namespace at
the package level, but now you have to explicitly specify the view at
the method level? completely doesn't make any sense to me at all.

when i annotate Namespace at the class/Action level, then everything
works as intended. the expected location of the resource is read (i.e.
/WEB-INF/content/admin/login-success.jsp). i guess i will have to live
with this approach for now and annotate the namespace for every
action.

@Namespace(/admin)
public class LoginAction

if anyone has a good explanation please share. i've consulted 3
different books but unfortunately, they only deal with XML files. it's
kinda silly that there are few published reference material outside of
the struts 2 website dealing with annotations and the convention
plugin.



On Tue, Jun 29, 2010 at 7:28 AM, Jake Vang vangj...@googlemail.com wrote:
 i have an Action class in the package
 com.company.web.struts.actions.admin.LoginAction. inside LoginAction,
 i use Annotation to specify the Action (i.e. @Action(value=/login)
 on a method. according to the documentation at,
 http://struts.apache.org/2.1.8.1/docs/convention-plugin.html, this
 should map to /admin/login (i.e.
 http://localhost:8080/webapp/admin/login, on Tomcat). however, i keep
 seeing the message below.

 No result defined for action
 com.company.web.struts.actions.admin.LoginAction and result success

 this message goes away if i specify the result explicitly (i.e.
 @Action(value=/login,result...@result(name=success,location=login-success.jsp)}).
 BUT, why do i have to explicitly specify the result? doesn't this
 defeat the purpose of the Convention plugin?

 for all my Action classes, so far, and using the Convention plugin, i
 just simply specify @Action(value=/something), and it is smart
 enough to forward to /something-success.jsp, /something-error.jsp,
 /something-input.jsp, etc... without any explicit setting of the
 @Result. any ideas is appreciated.


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



fieldexpression validator not working

2010-06-28 Thread Jake Vang
i have a User class with two fields, password and confirmPassword. on
a web form, upon post, i am trying to see if they match using the
fieldexpression validator. however, no matter what i try, i keep
getting the message that they don't match. in the Tomcat console, i
can see this message: Got result of null when trying to get Boolean.

my ActionClass-alias-validation.xml has the following defined. no
matter what i try for the OGNL expression, i still don't get the
correct results. for example, i've tried, #user.password ==
#user.confirmPassword, #user.password neq #user.confirmPassword, and
#user.password != #user.confirmPassword. any help is appreciated.

...
field name=user.password
field-validator type=requiredstring
messagePassword is required!/message
/field-validator
field-validator type=fieldexpression
param name=expression![CDATA[#user.password eq
#user.confirmPassword]]/param
messagePasswords are not the same./message
/field-validator
/field
field name=user.confirmPassword
field-validator type=requiredstring
messagePassword confirmation is required!/message
/field-validator
/field
...

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



Re: fieldexpression validator not working

2010-06-28 Thread Jake Vang
never mind, i removed # from the OGNL expression and i get the correct
behavior now.

On Tue, Jun 29, 2010 at 12:23 AM, Jake Vang vangj...@googlemail.com wrote:
 i have a User class with two fields, password and confirmPassword. on
 a web form, upon post, i am trying to see if they match using the
 fieldexpression validator. however, no matter what i try, i keep
 getting the message that they don't match. in the Tomcat console, i
 can see this message: Got result of null when trying to get Boolean.

 my ActionClass-alias-validation.xml has the following defined. no
 matter what i try for the OGNL expression, i still don't get the
 correct results. for example, i've tried, #user.password ==
 #user.confirmPassword, #user.password neq #user.confirmPassword, and
 #user.password != #user.confirmPassword. any help is appreciated.

 ...
        field name=user.password
                field-validator type=requiredstring
                        messagePassword is required!/message
                /field-validator
                field-validator type=fieldexpression
                        param name=expression![CDATA[#user.password eq
 #user.confirmPassword]]/param
                        messagePasswords are not the same./message
                /field-validator
        /field
        field name=user.confirmPassword
                field-validator type=requiredstring
                        messagePassword confirmation is required!/message
                /field-validator
        /field
 ...


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



Re: one-to-many persistence, ConstraintViolationException

2010-06-22 Thread Jake Vang
ken,

thanks for responding. i got things to work, but i haven't figured out
really why it's working (on a conceptual, philosophical level). here's
what i did to the code above.

1. for the Company class, i removed the @ForeignKey annotation
2. for the Employee class, i removed the companyId field. instead, i
used added a Company field.
@ManyToOne
@JoinColumn(name=companyId)
private Company company;
3. for the Employee class, i added
@GeneratedValue(strategy=GenerationType.AUTO) to the id field

this effectively makes the relationship a bidirectional and 1-N
multiplicity for Company and N-1 multiplicity for Employee.

one additional thing is that in my code, when you add an Employee to a
Company, you have to add the Company to the Employee too. i guess this
is what the official JEE 5 tutorial was saying when it said you have
to manage the relationship yourself (i had no idea what they were
talking about).

this JPA approach is quite strange. i don't find it easy at all or
intuitive to say the least. even though the JEE 5 and JEE 6 tutorials
tell you (in a poor way) about multiplicities and directions, their
examples are taken out-of-context.

right now, i am having a fun time trying to persist a 1-1
unidirectional relationship. i thought it would be easier, but it is
not. what complicates things is that there are many ways to accomplish
1-1 unidirectional relationships (using annotations and the DDL of the
actual database). what makes me wildly insane is that a search for
jpa tutorial returns pages that are too thin or too heavy weight. i
wish there was a tutorial on how to get JPA + Hibernate + Spring +
Struts2 all working on simple (very simple) examples in different
combinations of multiplicity and direction (regarding data
persistence).

by the way, i got a great response from another post regarding how to
do integration unit testing with all these guys (JPA, Hibernate,
Spring + Struts2) so now at least i can test data persistence.


On Tue, Jun 22, 2010 at 1:38 PM, Ken ken.mcwilli...@aerose.com wrote:
 I'm sorry I quickly scanned this and didn't read it in full...

 Here is my 2 cents.

 InnoDB rejects any INSERT or UPDATE operation that attempts to create a
 foreign key value in a child table if there is no a matching candidate
 key value in the parent table. So the parent has a valid entry before a
 row is created in the child?

 I noticed in defining the mysql table you use:
    foreign key (companyId) references company(id)

 Which has no ON DELETE or ON UPDATE clauses... so of course the above
 becomes:
    FOREIGN KEY (jcompanyid) REFERENCES company(id)
        ON DELETE RESTRICT
        ON UPDATE RESTRICT

 This would prevent you from deleting the parent or changing the foreign
 key in the parent if there is a dependant child.  I bring this up
 because I noticed the use of CascadeType's.


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



Re: i need more documentation on applicationContext.xml

2010-06-21 Thread Jake Vang
Stephen,

i know it is a spring xml file. i can tell that with the bean
id=transactionManager.../ element, they are defining a transaction
manager. however, what does tx:annotation-driven transaction-manager
.../ do? to me, intuitively, it defines a transaction manager that
will process by annotations.

the tutorial that gives this applicationContext.xml shows us how to
get things working, but doesn't really explain in detail why we are
doing what we are doing. that's kind of what i meant.

On Mon, Jun 21, 2010 at 10:04 AM, Stephen Turner stur...@mit.edu wrote:

 On Mon, 21 Jun 2010 00:56:19 -0400, Jake Vang vangj...@googlemail.com
 wrote:

 hi, i've been reading and studying
 http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.
 i want to know what is actually going on in applicationContext.xml.
 for example, what do these two lines do? please explain or refer me to
 better documentation.

  bean id=transactionManager
        class=org.springframework.orm.jpa.JpaTransactionManager
        property name=entityManagerFactory ref=entityManagerFactory /
    /bean

    tx:annotation-driven transaction-manager=transactionManager /


 Hi Jake,

 This file holds the Spring configuration. You'll need to read up on Spring -
 they have excellent documentation at:

 http://www.springsource.org/

 Steve


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



Re: i need more documentation on applicationContext.xml

2010-06-21 Thread Jake Vang
thanks Martin. that gives me a little more confidence. that takes a
little mystery away from that XML file.

by the way, do you know any books that discusses Struts 2 (the latest
latest version 2.1.x)? i would purchase it in a heartbeat.

On Mon, Jun 21, 2010 at 11:42 AM, Martin Gainty mgai...@hotmail.com wrote:
 a listing of  persistence-providers

 //notice the vendorAdapter changes for every vendor
 Toplink: bean id=entityManagerFactory
 class=org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
    vendorAdapter
    bean class=org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter
 property name=database value=HSQL/
 property name=showSql value=true/
 property name=generateDdl value=true/
    /bean
   /property
    TransactionManager: ?

 Spring OpenJpa:   bean id=entityManagerFactory
 class=org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
     bean
 class=org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter
     property name=database value=HSQL/
     property name=showSql value=true/
     property name=generateDdl value=true/
       /bean
   TransactionManager: ?

 Hibernate:  bean id=entityManagerFactory
 class=org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
    property name=jpaVendorAdapter
    bean
 class=org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
 property name=database value=HSQL/
 property name=showSql value=true/
 property name=generateDdl value=true/
    /bean
   /property
  TransactionManager: ?

 //Spring SharedEntityManager supports EntityManagerFactory thru
 transactionManager:
  bean id=entityManager
 class=org.springframework.orm.jpa.support.SharedEntityManagerBean
   property name=entityManagerFactory ref=entityManagerFactory/
  /bean
 //transactionManager
  bean id=transactionManager
 class=org.springframework.orm.jpa.JpaTransactionManager
   property name=entityManagerFactory ref=entityManagerFactory/
   property name=dataSource ref=dataSource/
  /bean


 conclusion seems to be we can implement both the entityManager and
 transactionManager
 but only if wholly configured to use entityManagerFactory's (based on
 jpaVendorAdapter vendor specific configuration)

 Martin Gainty
 __
 Jogi és Bizalmassági kinyilatkoztatás/Verzicht und
 Vertraulichkeitanmerkung/Note de déni et de confidentialité


 Ez az üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
 jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának készítése
 nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és semmiféle jogi
 alkalmazhatósága sincs.  Mivel az electronikus üzenetek könnyen
 megváltoztathatóak, ezért minket semmi felelöség nem terhelhet ezen üzenet
 tartalma miatt.

 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
 Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
 Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
 dient lediglich dem Austausch von Informationen und entfaltet keine
 rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
 E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.

 Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
 destinataire prévu, nous te demandons avec bonté que pour satisfaire
 informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
 de ceci est interdite. Ce message sert à l'information seulement et n'aura
 pas n'importe quel effet légalement obligatoire. Étant donné que les email
 peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
 aucune responsabilité pour le contenu fourni.




 To: user@struts.apache.org; vangj...@googlemail.com
 Subject: Re: i need more documentation on applicationContext.xml
 Date: Mon, 21 Jun 2010 10:04:57 -0400
 From: stur...@mit.edu


 On Mon, 21 Jun 2010 00:56:19 -0400, Jake Vang vangj...@googlemail.com
 wrote:

  hi, i've been reading and studying
  http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.
  i want to know what is actually going on in applicationContext.xml.
  for example, what do these two lines do? please explain or refer me to
  better documentation.
 
  bean id=transactionManager
  class=org.springframework.orm.jpa.JpaTransactionManager
  property name=entityManagerFactory ref=entityManagerFactory
  /
  /bean
 
  tx:annotation-driven transaction-manager=transactionManager /
 

 Hi Jake,

 This file holds the Spring configuration. You'll need to read up on Spring
 - they have excellent documentation at:

 http://www.springsource.org/

 Steve

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


 
 Hotmail is redefining busy with tools for the New Busy

Re: unit test the service layer (aka data access layer)

2010-06-21 Thread Jake Vang
james,

would setting up the unit test in that way load up the service class
as if it would in in the J2EE container?

the reason why i asked is because in the tutorial, as far as i
understand, they have wired in using Spring a transaction manager.
that means in my service object, when i call update/delete/create, i
don't have to get a EntityTransaction and do .begin() and .commit()
before and after i call the EntityManager's merge/remove/persist
methods, respectively.

i tried unit testing naively, by constructing an EntityManagerFactory
from the Persistence class (defining yet another
META-INF/persistence.xml file), but my CRUD operations (minus read)
never persists changes to the database (because it is in a J2SE
environment without a transaction manager? as opposed to being in a
J2EE environment with a transaction manager? well, that's what some
sites suggests anyways).


On Mon, Jun 21, 2010 at 5:02 AM, James Cook james.c...@wecomm.com wrote:
 Get involved with:

 Junit 4.4
 Spring-test libs

 And started your service test class like such:

 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = classpath:/testConfigXML.xml)
 public class MyServiceImplTest extends AbstractJUnit4SpringContextTests
 {

   �...@autowired(required = true)
    private MyService myService = null;

 testConfigXML.xml will contain your *test* config..

 Then do the do!


 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 21 June 2010 05:54
 To: Struts Users Mailing List
 Subject: unit test the service layer (aka data access layer)

 hi, i've been following this code here at
 http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.
 what i want to know is how to unit test the service layer (or data
 access object layer). in the case of the link, it would be the
 PersonServiceImpl class.

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


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



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



Re: unit test the service layer (aka data access layer)

2010-06-21 Thread Jake Vang
James,

thank you! that second link at the spring site was precisely what i
needed. i have one more question, my spring.xml file refers to a
properties file, how do i annotate to make the reference work?

On Mon, Jun 21, 2010 at 12:31 PM, James Cook james.c...@wecomm.com wrote:
 You would still have you build your own EntityManager, like if you were doing 
 it for Tomcat eg.

 http://najfiles.blogspot.com/2010/01/jpa-cat-spring.html

 Then check out:

 http://static.springsource.org/spring/docs/2.5.x/reference/testing.html

 Particularly the bit where it talks about extending 
 AbstractTransactionalJUnit4SpringContextTests for your unit test and the like

 Cheers

 James


 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 21 June 2010 17:27
 To: Struts Users Mailing List
 Subject: Re: unit test the service layer (aka data access layer)

 james,

 would setting up the unit test in that way load up the service class
 as if it would in in the J2EE container?

 the reason why i asked is because in the tutorial, as far as i
 understand, they have wired in using Spring a transaction manager.
 that means in my service object, when i call update/delete/create, i
 don't have to get a EntityTransaction and do .begin() and .commit()
 before and after i call the EntityManager's merge/remove/persist
 methods, respectively.

 i tried unit testing naively, by constructing an EntityManagerFactory
 from the Persistence class (defining yet another
 META-INF/persistence.xml file), but my CRUD operations (minus read)
 never persists changes to the database (because it is in a J2SE
 environment without a transaction manager? as opposed to being in a
 J2EE environment with a transaction manager? well, that's what some
 sites suggests anyways).


 On Mon, Jun 21, 2010 at 5:02 AM, James Cook james.c...@wecomm.com wrote:
 Get involved with:

 Junit 4.4
 Spring-test libs

 And started your service test class like such:

 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = classpath:/testConfigXML.xml)
 public class MyServiceImplTest extends AbstractJUnit4SpringContextTests
 {

   �...@autowired(required = true)
    private MyService myService = null;

 testConfigXML.xml will contain your *test* config..

 Then do the do!


 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 21 June 2010 05:54
 To: Struts Users Mailing List
 Subject: unit test the service layer (aka data access layer)

 hi, i've been following this code here at
 http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.
 what i want to know is how to unit test the service layer (or data
 access object layer). in the case of the link, it would be the
 PersonServiceImpl class.

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


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



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


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



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



one-to-many persistence, ConstraintViolationException

2010-06-21 Thread Jake Vang
i am following the example at
http://struts.apache.org/2.1.8.1/docs/struts-2-spring-2-jpa-ajax.html.
in this example, a very simple persistence is given (of which i am
thankful). but, what i am trying to do is slightly more complicated
with persistence. i need to persist a one-to-many relationship. when i
attempt to do so, i keep getting the following error.

Caused by: java.sql.BatchUpdateException: Cannot add or update a child
row: a foreign key constraint fails (`demo`.`employee`, CONSTRAINT
`employee_ibfk_1` FOREIGN KEY (`companyId`) REFERENCES `company`
(`id`))

what am i doing wrong?

i am using mysql, and these are my DDLs.
create table company (
name varchar(100) unique,
id mediumint not null auto_increment,
primary key(id),
index using btree(id)
);

create table employee(
companyId mediumint,
firstName varchar(100),
lastName varchar(100),
id mediumint not null auto_increment,
primary key(id),
index using btree(id),
foreign key (companyId) references company(id)
);

these are my classes for Company and Employee.

@Entity
@Table(name=company)
public class Company {

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
private String name;
@OneToMany(mappedBy=companyId,
cascade={CascadeType.REMOVE, CascadeType.PERSIST},
targetEntity=Employee.class,
fetch=FetchType.EAGER)
@JoinColumn(name=companyId)
@ForeignKey(name=id,inverseName=companyId)
private ListEmployee employees;

public Company() { }

public Company(String name) {
this.name = name;
}

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

public void addEmployee(Employee employee) {
ListEmployee employees = getEmployees();
employees.add(employee);

employee.setCompanyId(getId());
}

public ListEmployee getEmployees() {
if(null == employees) {
employees = new ArrayListEmployee();
}
return employees;
}

public void setEmployees(ListEmployee employees) {
this.employees = employees;
}

}

@Entity
@Table(name=employee)
public class Employee {

private int companyId;
@Id
private int id;
private String firstName;
private String lastName;

public Employee() { }

public Employee(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}

public int getCompanyId() {
return companyId;
}

public void setCompanyId(int companyId) {
this.companyId = companyId;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}
}

my service implementation that keeps failing to persist is as follows.
any help would be greatly appreciated.

@Transactional
public class CompanyDao {

@PersistenceContext
protected EntityManager entityManager;

public CompanyDao() { }

public CompanyDao(EntityManager entityManager) {
this.entityManager = entityManager;
}

public void create(Company company) {
EntityManager em = getEntityManager();
em.persist(company);
}

public Company read(int id) {
EntityManager em = getEntityManager();
Company company = em.find(Company.class, id);
return company;
}

public void update(Company company) {
EntityManager em = getEntityManager();
em.merge(company);
}

public void delete(int id) {
Company company = read(id);
if(null != company) {
EntityManager em = getEntityManager();
em.remove(company);
}
}

public EntityManager getEntityManager() {

unit test the service layer (aka data access layer)

2010-06-20 Thread Jake Vang
hi, i've been following this code here at
http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.
what i want to know is how to unit test the service layer (or data
access object layer). in the case of the link, it would be the
PersonServiceImpl class.

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



i need more documentation on applicationContext.xml

2010-06-20 Thread Jake Vang
hi, i've been reading and studying
http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.
i want to know what is actually going on in applicationContext.xml.
for example, what do these two lines do? please explain or refer me to
better documentation.

 bean id=transactionManager
class=org.springframework.orm.jpa.JpaTransactionManager
property name=entityManagerFactory ref=entityManagerFactory /
/bean

tx:annotation-driven transaction-manager=transactionManager /

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



spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
i am using struts 2.1.8.1 and the convention plugin. i am also using
spring for dependency injections (DI). my question is if it is
possible to to use struts2 + convention plugin with spring for DI on
my Action classes? i have searched  the internet but only seen
examples using struts 1 + spring for DI on Action classes. the
convention plugin makes life simpler (no XML), but also, partially
because of little documentation, makes it uneasy to do certain things.
i wonder if this is part of the reason why DI on Action classes using
spring + struts is not obvious for me.

Here's a simple code. This is my action class.

public class SpringWiringAction extends ActionSupport {
 private String message = no dependency injection;

 @Action(value=/spring-wiring)
 public String springWiring() {
  return SUCCESS;
 }

 public String getMessage() { return message; }
 public void setMessage(String message) { this.message = message; }
}

My view or the JSP page corresponding to the Action is:
/webapp/WEB-INF/content/spring-wiring-success.jsp.

%@ page language=java contentType=text/html; charset=ISO-8859-1
pageEncoding=ISO-8859-1%
%...@taglib uri=/struts-tags prefix=s %
html
 headtitleTest Spring Wiring/title/head
 body
 s:property value=message/
 /body
/html

My web.xml is setup according to
http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.

My spring XML file (/webapp/WEB-INF/applicationContext.xml) is defined
as following.

...
bean id=placeholderConfig
class=org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
 property name=location value=WEB-INF/applicationContext.properties/
/bean
...
bean name=/spring-wiring class=com.me.actions.SpringWiringAction
 property name=message value=${message}/
/bean

My /webapp/WEB-INF/applicationContext.properties file then has this content.

message=dependency inject success

when i start up tomcat 6, everything starts up correctly and there are
no complaints. however, when i go to
http://localhost/webapp/spring-wiring, the message that gets displayed
is no dependency injection.

is there something that i am missing using spring + struts2 (with the
convention plugin) to use DI on Actions?

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



Re: spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
well, there's something strange about struts2 (with convention plugin)
+ spring. if your action has a field representing a service,
MyInjectedService myInjectedService, you just have to define that in
the spring xml file. for example, your Action class looks like the
following.

public class MyAction extends ActionSupport {
 private Service service;

 @Action(value=/dummy)
 public String dummy() { return SUCCESS; }
 public Service getService() { return service; }
 public void setService(Service service) { this.service = service; }
}

in your spring xml file (i.e. applicationContext.xml), you simply
define a bean with the id=service. for example,

bean id=service class=my.class.Service/

that's it; you don't have to do anything else. you don't even have to
explicitly say (using XML) to inject this when you are creating an
instance of MyAction. now when a user accesses /dummy, MyAction will
be created and its service field will actually be injected with what
is specified in the spring xml file.

what irks me or  bothers me is that it is not obvious at the moment
how to simply inject strings or booleans into the Action class. it
should be just as simple.

upon analyzing what i am doing, and in light of what you said, perhaps
i am trying to push some logic into the Action class that shouldn't be
there. perhaps i should push the logic to a service class instead. in
this case, this problem goes away. BUT, the question remains, how can
i use DI with struts2 (convention plugin)  and spring on Action
classes? or can i not? if i can't, end of story. if i can, how?

On Thu, May 13, 2010 at 5:44 AM, James Cook james.c...@wecomm.com wrote:
 Hmm. I use the same combo.

 I found at some point I could jsut do

 public class MyAction extends ActionSupport {

 private MyInjectedService service

 etc etc

 But I have started doing:

 public class MyAction extends ActionSupport {

 @Autowired
 private MyInjectedService service

 I am not sure if that alters the way Struts2/Spring does it. But it does
 make it a bit clearer to read.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 10:23
 To: user@struts.apache.org
 Subject: spring, struts2, convention plugin, how to wire an action
 class

 i am using struts 2.1.8.1 and the convention plugin. i am also using
 spring for dependency injections (DI). my question is if it is
 possible to to use struts2 + convention plugin with spring for DI on
 my Action classes? i have searched  the internet but only seen
 examples using struts 1 + spring for DI on Action classes. the
 convention plugin makes life simpler (no XML), but also, partially
 because of little documentation, makes it uneasy to do certain things.
 i wonder if this is part of the reason why DI on Action classes using
 spring + struts is not obvious for me.

 Here's a simple code. This is my action class.

 public class SpringWiringAction extends ActionSupport {
  private String message = no dependency injection;

 �...@action(value=/spring-wiring)
  public String springWiring() {
  return SUCCESS;
  }

  public String getMessage() { return message; }
  public void setMessage(String message) { this.message = message; }
 }

 My view or the JSP page corresponding to the Action is:
 /webapp/WEB-INF/content/spring-wiring-success.jsp.

 %@ page language=java contentType=text/html; charset=ISO-8859-1
 pageEncoding=ISO-8859-1%
 %...@taglib uri=/struts-tags prefix=s %
 html
  headtitleTest Spring Wiring/title/head
  body
  s:property value=message/
  /body
 /html

 My web.xml is setup according to
 http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.

 My spring XML file (/webapp/WEB-INF/applicationContext.xml) is defined
 as following.

 ...
 bean id=placeholderConfig
 class=org.springframework.beans.factory.config.PropertyPlaceholderConfi
 gurer
  property name=location
 value=WEB-INF/applicationContext.properties/
 /bean
 ...
 bean name=/spring-wiring class=com.me.actions.SpringWiringAction
  property name=message value=${message}/
 /bean

 My /webapp/WEB-INF/applicationContext.properties file then has this
 content.

 message=dependency inject success

 when i start up tomcat 6, everything starts up correctly and there are
 no complaints. however, when i go to
 http://localhost/webapp/spring-wiring, the message that gets displayed
 is no dependency injection.

 is there something that i am missing using spring + struts2 (with the
 convention plugin) to use DI on Actions?

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


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



-
To unsubscribe, e-mail: user-unsubscr

Re: spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
by the way, which package is the @Autowired annotation in? using
eclipse and code assist, i can't get it to show up. is it in some
other jar file (it's not in the spring-core-x.jar)?

On Thu, May 13, 2010 at 5:44 AM, James Cook james.c...@wecomm.com wrote:
 Hmm. I use the same combo.

 I found at some point I could jsut do

 public class MyAction extends ActionSupport {

 private MyInjectedService service

 etc etc

 But I have started doing:

 public class MyAction extends ActionSupport {

 @Autowired
 private MyInjectedService service

 I am not sure if that alters the way Struts2/Spring does it. But it does
 make it a bit clearer to read.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 10:23
 To: user@struts.apache.org
 Subject: spring, struts2, convention plugin, how to wire an action
 class

 i am using struts 2.1.8.1 and the convention plugin. i am also using
 spring for dependency injections (DI). my question is if it is
 possible to to use struts2 + convention plugin with spring for DI on
 my Action classes? i have searched  the internet but only seen
 examples using struts 1 + spring for DI on Action classes. the
 convention plugin makes life simpler (no XML), but also, partially
 because of little documentation, makes it uneasy to do certain things.
 i wonder if this is part of the reason why DI on Action classes using
 spring + struts is not obvious for me.

 Here's a simple code. This is my action class.

 public class SpringWiringAction extends ActionSupport {
  private String message = no dependency injection;

 �...@action(value=/spring-wiring)
  public String springWiring() {
  return SUCCESS;
  }

  public String getMessage() { return message; }
  public void setMessage(String message) { this.message = message; }
 }

 My view or the JSP page corresponding to the Action is:
 /webapp/WEB-INF/content/spring-wiring-success.jsp.

 %@ page language=java contentType=text/html; charset=ISO-8859-1
 pageEncoding=ISO-8859-1%
 %...@taglib uri=/struts-tags prefix=s %
 html
  headtitleTest Spring Wiring/title/head
  body
  s:property value=message/
  /body
 /html

 My web.xml is setup according to
 http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.

 My spring XML file (/webapp/WEB-INF/applicationContext.xml) is defined
 as following.

 ...
 bean id=placeholderConfig
 class=org.springframework.beans.factory.config.PropertyPlaceholderConfi
 gurer
  property name=location
 value=WEB-INF/applicationContext.properties/
 /bean
 ...
 bean name=/spring-wiring class=com.me.actions.SpringWiringAction
  property name=message value=${message}/
 /bean

 My /webapp/WEB-INF/applicationContext.properties file then has this
 content.

 message=dependency inject success

 when i start up tomcat 6, everything starts up correctly and there are
 no complaints. however, when i go to
 http://localhost/webapp/spring-wiring, the message that gets displayed
 is no dependency injection.

 is there something that i am missing using spring + struts2 (with the
 convention plugin) to use DI on Actions?

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


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



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



Re: spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
doesn't answer the question but thanks anyways.

On Thu, May 13, 2010 at 6:12 AM, James Cook james.c...@wecomm.com wrote:
 Nope, no they are not in the xml for me. I use the @Service/@Repository 
 annotations on the class, coupled with the component scan in the Spring xml.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:09
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action class

 well, there's something strange about struts2 (with convention plugin)
 + spring. if your action has a field representing a service,
 MyInjectedService myInjectedService, you just have to define that in
 the spring xml file. for example, your Action class looks like the
 following.

 public class MyAction extends ActionSupport {
  private Service service;

 �...@action(value=/dummy)
  public String dummy() { return SUCCESS; }
  public Service getService() { return service; }
  public void setService(Service service) { this.service = service; }
 }

 in your spring xml file (i.e. applicationContext.xml), you simply
 define a bean with the id=service. for example,

 bean id=service class=my.class.Service/

 that's it; you don't have to do anything else. you don't even have to
 explicitly say (using XML) to inject this when you are creating an
 instance of MyAction. now when a user accesses /dummy, MyAction will
 be created and its service field will actually be injected with what
 is specified in the spring xml file.

 what irks me or  bothers me is that it is not obvious at the moment
 how to simply inject strings or booleans into the Action class. it
 should be just as simple.

 upon analyzing what i am doing, and in light of what you said, perhaps
 i am trying to push some logic into the Action class that shouldn't be
 there. perhaps i should push the logic to a service class instead. in
 this case, this problem goes away. BUT, the question remains, how can
 i use DI with struts2 (convention plugin)  and spring on Action
 classes? or can i not? if i can't, end of story. if i can, how?

 On Thu, May 13, 2010 at 5:44 AM, James Cook james.c...@wecomm.com wrote:
 Hmm. I use the same combo.

 I found at some point I could jsut do

 public class MyAction extends ActionSupport {

 private MyInjectedService service

 etc etc

 But I have started doing:

 public class MyAction extends ActionSupport {

 @Autowired
 private MyInjectedService service

 I am not sure if that alters the way Struts2/Spring does it. But it does
 make it a bit clearer to read.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 10:23
 To: user@struts.apache.org
 Subject: spring, struts2, convention plugin, how to wire an action
 class

 i am using struts 2.1.8.1 and the convention plugin. i am also using
 spring for dependency injections (DI). my question is if it is
 possible to to use struts2 + convention plugin with spring for DI on
 my Action classes? i have searched  the internet but only seen
 examples using struts 1 + spring for DI on Action classes. the
 convention plugin makes life simpler (no XML), but also, partially
 because of little documentation, makes it uneasy to do certain things.
 i wonder if this is part of the reason why DI on Action classes using
 spring + struts is not obvious for me.

 Here's a simple code. This is my action class.

 public class SpringWiringAction extends ActionSupport {
  private String message = no dependency injection;

 �...@action(value=/spring-wiring)
  public String springWiring() {
  return SUCCESS;
  }

  public String getMessage() { return message; }
  public void setMessage(String message) { this.message = message; }
 }

 My view or the JSP page corresponding to the Action is:
 /webapp/WEB-INF/content/spring-wiring-success.jsp.

 %@ page language=java contentType=text/html; charset=ISO-8859-1
 pageEncoding=ISO-8859-1%
 %...@taglib uri=/struts-tags prefix=s %
 html
  headtitleTest Spring Wiring/title/head
  body
  s:property value=message/
  /body
 /html

 My web.xml is setup according to
 http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.

 My spring XML file (/webapp/WEB-INF/applicationContext.xml) is defined
 as following.

 ...
 bean id=placeholderConfig
 class=org.springframework.beans.factory.config.PropertyPlaceholderConfi
 gurer
  property name=location
 value=WEB-INF/applicationContext.properties/
 /bean
 ...
 bean name=/spring-wiring class=com.me.actions.SpringWiringAction
  property name=message value=${message}/
 /bean

 My /webapp/WEB-INF/applicationContext.properties file then has this
 content.

 message=dependency inject success

 when i start up tomcat 6, everything starts up correctly and there are
 no complaints. however, when i go to
 http://localhost/webapp/spring-wiring, the message that gets displayed
 is no dependency injection.

 is there something that i am missing using spring + struts2 (with the
 convention plugin

Re: spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
thanks. i won't go that route. i noticed your example (in the first
response) and i realized that i may trying to push some business logic
into the Action class. and, i don't think that's too good of a
practice. i simply revised my Service class to hold these values
(booleans, String, int, etc...) and now the problem goes away. it's a
workaround.

if anyone is reading this post and knows how to use struts2 (w/
convention plugin) + spring to construct Action classes, please let me
know. the examples i've seen are only with struts1 (and though not too
complicated, seem verbose with the xml).

On Thu, May 13, 2010 at 6:20 AM, James Cook james.c...@wecomm.com wrote:
 Yeah sorry, short on time here, didn't see your question at the bottom. Add 
 the spring jar from the spring project.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:16
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action class

 doesn't answer the question but thanks anyways.

 On Thu, May 13, 2010 at 6:12 AM, James Cook james.c...@wecomm.com wrote:
 Nope, no they are not in the xml for me. I use the @Service/@Repository 
 annotations on the class, coupled with the component scan in the Spring xml.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:09
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action 
 class

 well, there's something strange about struts2 (with convention plugin)
 + spring. if your action has a field representing a service,
 MyInjectedService myInjectedService, you just have to define that in
 the spring xml file. for example, your Action class looks like the
 following.

 public class MyAction extends ActionSupport {
  private Service service;

 �...@action(value=/dummy)
  public String dummy() { return SUCCESS; }
  public Service getService() { return service; }
  public void setService(Service service) { this.service = service; }
 }

 in your spring xml file (i.e. applicationContext.xml), you simply
 define a bean with the id=service. for example,

 bean id=service class=my.class.Service/

 that's it; you don't have to do anything else. you don't even have to
 explicitly say (using XML) to inject this when you are creating an
 instance of MyAction. now when a user accesses /dummy, MyAction will
 be created and its service field will actually be injected with what
 is specified in the spring xml file.

 what irks me or  bothers me is that it is not obvious at the moment
 how to simply inject strings or booleans into the Action class. it
 should be just as simple.

 upon analyzing what i am doing, and in light of what you said, perhaps
 i am trying to push some logic into the Action class that shouldn't be
 there. perhaps i should push the logic to a service class instead. in
 this case, this problem goes away. BUT, the question remains, how can
 i use DI with struts2 (convention plugin)  and spring on Action
 classes? or can i not? if i can't, end of story. if i can, how?

 On Thu, May 13, 2010 at 5:44 AM, James Cook james.c...@wecomm.com wrote:
 Hmm. I use the same combo.

 I found at some point I could jsut do

 public class MyAction extends ActionSupport {

 private MyInjectedService service

 etc etc

 But I have started doing:

 public class MyAction extends ActionSupport {

 @Autowired
 private MyInjectedService service

 I am not sure if that alters the way Struts2/Spring does it. But it does
 make it a bit clearer to read.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 10:23
 To: user@struts.apache.org
 Subject: spring, struts2, convention plugin, how to wire an action
 class

 i am using struts 2.1.8.1 and the convention plugin. i am also using
 spring for dependency injections (DI). my question is if it is
 possible to to use struts2 + convention plugin with spring for DI on
 my Action classes? i have searched  the internet but only seen
 examples using struts 1 + spring for DI on Action classes. the
 convention plugin makes life simpler (no XML), but also, partially
 because of little documentation, makes it uneasy to do certain things.
 i wonder if this is part of the reason why DI on Action classes using
 spring + struts is not obvious for me.

 Here's a simple code. This is my action class.

 public class SpringWiringAction extends ActionSupport {
  private String message = no dependency injection;

 �...@action(value=/spring-wiring)
  public String springWiring() {
  return SUCCESS;
  }

  public String getMessage() { return message; }
  public void setMessage(String message) { this.message = message; }
 }

 My view or the JSP page corresponding to the Action is:
 /webapp/WEB-INF/content/spring-wiring-success.jsp.

 %@ page language=java contentType=text/html; charset=ISO-8859-1
 pageEncoding=ISO-8859-1%
 %...@taglib uri=/struts-tags prefix=s %
 html

Re: spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
yes. precisely.

On Thu, May 13, 2010 at 6:41 AM, James Cook james.c...@wecomm.com wrote:
 Oh, did you want your action as a spring managed bean? Ah I think i massively 
 miss read you. You want to inject predefined values etc?


 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:38
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action class

 thanks. i won't go that route. i noticed your example (in the first
 response) and i realized that i may trying to push some business logic
 into the Action class. and, i don't think that's too good of a
 practice. i simply revised my Service class to hold these values
 (booleans, String, int, etc...) and now the problem goes away. it's a
 workaround.

 if anyone is reading this post and knows how to use struts2 (w/
 convention plugin) + spring to construct Action classes, please let me
 know. the examples i've seen are only with struts1 (and though not too
 complicated, seem verbose with the xml).

 On Thu, May 13, 2010 at 6:20 AM, James Cook james.c...@wecomm.com wrote:
 Yeah sorry, short on time here, didn't see your question at the bottom. Add 
 the spring jar from the spring project.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:16
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action 
 class

 doesn't answer the question but thanks anyways.

 On Thu, May 13, 2010 at 6:12 AM, James Cook james.c...@wecomm.com wrote:
 Nope, no they are not in the xml for me. I use the @Service/@Repository 
 annotations on the class, coupled with the component scan in the Spring xml.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:09
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action 
 class

 well, there's something strange about struts2 (with convention plugin)
 + spring. if your action has a field representing a service,
 MyInjectedService myInjectedService, you just have to define that in
 the spring xml file. for example, your Action class looks like the
 following.

 public class MyAction extends ActionSupport {
  private Service service;

 �...@action(value=/dummy)
  public String dummy() { return SUCCESS; }
  public Service getService() { return service; }
  public void setService(Service service) { this.service = service; }
 }

 in your spring xml file (i.e. applicationContext.xml), you simply
 define a bean with the id=service. for example,

 bean id=service class=my.class.Service/

 that's it; you don't have to do anything else. you don't even have to
 explicitly say (using XML) to inject this when you are creating an
 instance of MyAction. now when a user accesses /dummy, MyAction will
 be created and its service field will actually be injected with what
 is specified in the spring xml file.

 what irks me or  bothers me is that it is not obvious at the moment
 how to simply inject strings or booleans into the Action class. it
 should be just as simple.

 upon analyzing what i am doing, and in light of what you said, perhaps
 i am trying to push some logic into the Action class that shouldn't be
 there. perhaps i should push the logic to a service class instead. in
 this case, this problem goes away. BUT, the question remains, how can
 i use DI with struts2 (convention plugin)  and spring on Action
 classes? or can i not? if i can't, end of story. if i can, how?

 On Thu, May 13, 2010 at 5:44 AM, James Cook james.c...@wecomm.com wrote:
 Hmm. I use the same combo.

 I found at some point I could jsut do

 public class MyAction extends ActionSupport {

 private MyInjectedService service

 etc etc

 But I have started doing:

 public class MyAction extends ActionSupport {

 @Autowired
 private MyInjectedService service

 I am not sure if that alters the way Struts2/Spring does it. But it does
 make it a bit clearer to read.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 10:23
 To: user@struts.apache.org
 Subject: spring, struts2, convention plugin, how to wire an action
 class

 i am using struts 2.1.8.1 and the convention plugin. i am also using
 spring for dependency injections (DI). my question is if it is
 possible to to use struts2 + convention plugin with spring for DI on
 my Action classes? i have searched  the internet but only seen
 examples using struts 1 + spring for DI on Action classes. the
 convention plugin makes life simpler (no XML), but also, partially
 because of little documentation, makes it uneasy to do certain things.
 i wonder if this is part of the reason why DI on Action classes using
 spring + struts is not obvious for me.

 Here's a simple code. This is my action class.

 public class SpringWiringAction extends ActionSupport {
  private String message = no dependency injection;

 �...@action

Re: spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
 If you want Spring to create your action class (as opposed to Struts
 creating them) then you need to define your action in the
 applicationContext.xml file.

how do you do that? here's a couple of ways i have tried that do NOT work.

1. (normal, naive way that works for defining services)
bean id=action class=com.services.MyAction
 property name=propertyA value=${propertyA}/
/bean

2. (in this case, we do not use the id attribute, but the name attribute)
bean name=/action class=com.services.MyAction
 property name=propertyA value=${propertyA}/
/bean

i've also tried configuring struts.properties to have the
ObjectFactory use spring and this does not help.

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



Re: spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
thanks. example please? (when you have time).

On Thu, May 13, 2010 at 6:52 AM, James Cook james.c...@wecomm.com wrote:
 Ahh hmm.

 You can use the autowired, You just have to declare you stuff in the spring 
 xml. E.g.

 bean id=myJDBCString class=java.lang.String 

 I think you can also use the @Resource anno as well. Can't think off the top 
 of my head.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:44
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action class

 yes. precisely.

 On Thu, May 13, 2010 at 6:41 AM, James Cook james.c...@wecomm.com wrote:
 Oh, did you want your action as a spring managed bean? Ah I think i 
 massively miss read you. You want to inject predefined values etc?


 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:38
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action 
 class

 thanks. i won't go that route. i noticed your example (in the first
 response) and i realized that i may trying to push some business logic
 into the Action class. and, i don't think that's too good of a
 practice. i simply revised my Service class to hold these values
 (booleans, String, int, etc...) and now the problem goes away. it's a
 workaround.

 if anyone is reading this post and knows how to use struts2 (w/
 convention plugin) + spring to construct Action classes, please let me
 know. the examples i've seen are only with struts1 (and though not too
 complicated, seem verbose with the xml).

 On Thu, May 13, 2010 at 6:20 AM, James Cook james.c...@wecomm.com wrote:
 Yeah sorry, short on time here, didn't see your question at the bottom. Add 
 the spring jar from the spring project.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:16
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action 
 class

 doesn't answer the question but thanks anyways.

 On Thu, May 13, 2010 at 6:12 AM, James Cook james.c...@wecomm.com wrote:
 Nope, no they are not in the xml for me. I use the @Service/@Repository 
 annotations on the class, coupled with the component scan in the Spring 
 xml.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:09
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action 
 class

 well, there's something strange about struts2 (with convention plugin)
 + spring. if your action has a field representing a service,
 MyInjectedService myInjectedService, you just have to define that in
 the spring xml file. for example, your Action class looks like the
 following.

 public class MyAction extends ActionSupport {
  private Service service;

 �...@action(value=/dummy)
  public String dummy() { return SUCCESS; }
  public Service getService() { return service; }
  public void setService(Service service) { this.service = service; }
 }

 in your spring xml file (i.e. applicationContext.xml), you simply
 define a bean with the id=service. for example,

 bean id=service class=my.class.Service/

 that's it; you don't have to do anything else. you don't even have to
 explicitly say (using XML) to inject this when you are creating an
 instance of MyAction. now when a user accesses /dummy, MyAction will
 be created and its service field will actually be injected with what
 is specified in the spring xml file.

 what irks me or  bothers me is that it is not obvious at the moment
 how to simply inject strings or booleans into the Action class. it
 should be just as simple.

 upon analyzing what i am doing, and in light of what you said, perhaps
 i am trying to push some logic into the Action class that shouldn't be
 there. perhaps i should push the logic to a service class instead. in
 this case, this problem goes away. BUT, the question remains, how can
 i use DI with struts2 (convention plugin)  and spring on Action
 classes? or can i not? if i can't, end of story. if i can, how?

 On Thu, May 13, 2010 at 5:44 AM, James Cook james.c...@wecomm.com wrote:
 Hmm. I use the same combo.

 I found at some point I could jsut do

 public class MyAction extends ActionSupport {

 private MyInjectedService service

 etc etc

 But I have started doing:

 public class MyAction extends ActionSupport {

 @Autowired
 private MyInjectedService service

 I am not sure if that alters the way Struts2/Spring does it. But it does
 make it a bit clearer to read.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 10:23
 To: user@struts.apache.org
 Subject: spring, struts2, convention plugin, how to wire an action
 class

 i am using struts 2.1.8.1 and the convention plugin. i am also using
 spring for dependency injections (DI). my question is if it is
 possible to to use struts2

Re: spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
yes, i read the documentation for that before posting here too. it
says to simply drop in the struts2-spring-plugin-version.jar. i
already have that in /WEB-INF/lib. however, towards the end of the
document, they are referencing how to initialize Actions from spring
using struts.xml and applicationContext.xml. since i am using
Annotations and the conventions plugin, i don't think this is what i
am looking for. currently, my struts.xml file is 3 lines only! (minus
the DOCTYPE lines).

there are little but significant differences in how a struts2 based
application behaves using the convention plugin (as opposed to using
the traditional struts.xml file).

i am committed to using the convention plugin + annotations and to
avoid as much as possible configurations in struts.xml. if there is an
example of how to get all this working (struts2 + convention +
annotations + spring), i would be most pleased. thanks.

On Thu, May 13, 2010 at 8:24 AM, Denis Cabasson
denis.cabas...@gmail.com wrote:
 Jake, the short answer to your problem is : use the struts-spring plugin (
 http://struts.apache.org/2.1.8.1/docs/spring-plugin.html ). Include the jar
 for that plugin in your classpath, and Struts 2 will use Spring to manage
 the Action lifecycle, meaning you can inject anything the way you are
 describing it above (including String, etc...)
 Denis.

 Le 2010-05-13 08:09, Jake Vang a écrit :

 thanks. example please? (when you have time).

 On Thu, May 13, 2010 at 6:52 AM, James Cookjames.c...@wecomm.com  wrote:


 Ahh hmm.

 You can use the autowired, You just have to declare you stuff in the
 spring xml. E.g.

 bean id=myJDBCString class=java.lang.String 

 I think you can also use the @Resource anno as well. Can't think off the
 top of my head.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:44
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action
 class

 yes. precisely.

 On Thu, May 13, 2010 at 6:41 AM, James Cookjames.c...@wecomm.com
  wrote:


 Oh, did you want your action as a spring managed bean? Ah I think i
 massively miss read you. You want to inject predefined values etc?


 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:38
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an action
 class

 thanks. i won't go that route. i noticed your example (in the first
 response) and i realized that i may trying to push some business logic
 into the Action class. and, i don't think that's too good of a
 practice. i simply revised my Service class to hold these values
 (booleans, String, int, etc...) and now the problem goes away. it's a
 workaround.

 if anyone is reading this post and knows how to use struts2 (w/
 convention plugin) + spring to construct Action classes, please let me
 know. the examples i've seen are only with struts1 (and though not too
 complicated, seem verbose with the xml).

 On Thu, May 13, 2010 at 6:20 AM, James Cookjames.c...@wecomm.com
  wrote:


 Yeah sorry, short on time here, didn't see your question at the bottom.
 Add the spring jar from the spring project.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:16
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an
 action class

 doesn't answer the question but thanks anyways.

 On Thu, May 13, 2010 at 6:12 AM, James Cookjames.c...@wecomm.com
  wrote:


 Nope, no they are not in the xml for me. I use the
 @Service/@Repository annotations on the class, coupled with the component
 scan in the Spring xml.

 -Original Message-
 From: Jake Vang [mailto:vangj...@googlemail.com]
 Sent: 13 May 2010 11:09
 To: Struts Users Mailing List
 Subject: Re: spring, struts2, convention plugin, how to wire an
 action class

 well, there's something strange about struts2 (with convention plugin)
 + spring. if your action has a field representing a service,
 MyInjectedService myInjectedService, you just have to define that in
 the spring xml file. for example, your Action class looks like the
 following.

 public class MyAction extends ActionSupport {
  private Service service;

 �...@action(value=/dummy)
  public String dummy() { return SUCCESS; }
  public Service getService() { return service; }
  public void setService(Service service) { this.service = service; }
 }

 in your spring xml file (i.e. applicationContext.xml), you simply
 define a bean with the id=service. for example,

 bean id=service class=my.class.Service/

 that's it; you don't have to do anything else. you don't even have to
 explicitly say (using XML) to inject this when you are creating an
 instance of MyAction. now when a user accesses /dummy, MyAction will
 be created and its service field will actually be injected with what
 is specified in the spring xml file.

 what irks me or  bothers

Re: spring, struts2, convention plugin, how to wire an action class

2010-05-13 Thread Jake Vang
roger,

thanks for the steps. i went through each of those steps and made sure
my settings/configurations complied. however, i still cannot
initialize Action classes using Spring.

as an illustration of the problem i am facing, i have created an
example that you may download and verify for yourself that this does
not work.

http://www.box.net/shared/iycamr9uo6

this will download a zip file with an Eclipse project; unzip it. if
you have Ant, you simply type in ant war and the war file will be
created. if you have Tomcat, then drop the war file into the webapps
directory (assuming you have Tomcat 6.0).

if you go to http://localhost:8080/myapp/, you will see four lines displayed.
String from Action: default
boolean from Action: false
String from Service: overwritten
boolean from Service: true

The first and second lines confirm that the String and boolean values
are not injected into the Action class. The third and fourth lines
confirm that the String and boolean values are injected into the
service class.

thanks.

On Thu, May 13, 2010 at 9:32 AM, RogerV roger.var...@googlemail.com wrote:



 Jake Vang wrote:

 If you want Spring to create your action class (as opposed to Struts
 creating them) then you need to define your action in the
 applicationContext.xml file.

 how do you do that? here's a couple of ways i have tried that do NOT work.


 1) Add constant name=struts.objectFactory
 value=org.apache.struts2.spring.StrutsSpringObjectFactory / to your
 struts.xml file.

 2) Add  listener

 listener-classorg.springframework.web.context.ContextLoaderListener/listener-class
    /listener

 to your web.xml

 3) Make sure that you have the Struts2 Spring plugin installed.

 4) Put something along the lines of
 bean id=myAction class=com.somwhere.mypackage.MyAction
 scope=prototype/ (The scope prototype is important otherwise Spring
 creates a singleton rather than a new action on each invocation which is
 what Struts 2 expects)

 and that should get Spring instantiating your action classes for you.

 Although I'm guessing from your response you've already got to that stage.

 I'm not sure that I understand what you are trying to acheive with

 bean name=/action class=com.services.MyAction
  property name=propertyA value=${propertyA}/
 /bean

 If you're trying to inject another class, then the format is on the lines of

 bean name=/action class=com.services.MyAction
  property name=classA ref=classA/
 /bean

 where you need a setter that matches the name parameter (setClassA(ClassA
 classA)) in MyAction. The ref value points to another bean id=classA
 class=com.services.classA/

 HTH and I haven't completely misunderstood what you are trying to do.

 Regards


 --
 View this message in context: 
 http://old.nabble.com/spring%2C-struts2%2C-convention-plugin%2C-how-to-%22wire%22-an-action-class-tp28545412p28547552.html
 Sent from the Struts - User mailing list archive at Nabble.com.


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



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



Struts release 2.1.9

2010-05-10 Thread jake
Hi, 

When will there be a GA release of 2.1.9 or above?

Cheers,
Jake

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



Re: how to customize the rendering of a tabbedpanel? struts2, dojo plugin

2010-02-05 Thread Jake Vang
stephen,

thanks. i'm looking into the dojo js framework right now. i've
downloaded the files, but they are almost 10 MB?  i know you can
reference the JS on other servers too, but i'd like local copies for
development testing. i didn't really want to use dojo directly because
i didn't want to do programming (Java or JavaScript) right on the
page.

On Thu, Feb 4, 2010 at 6:10 PM, Stephen Ince stephenpi...@gmail.com wrote:
 Jake,
  The sx: tags are based on the .4 dojo tags. I would just use the
 dojo tags themselves. The dojo plugin is also being depricated. The
 new dojo tags are at 1.4.  I solved a similiar height problem on dojo
 1.4 by doing the following.


  style type=text/css
      body, html { height: 99%;overflow:hidden;
 margin-bottom:0;padding-bottom:0;}
  /style
 /head
 body class=tundra
 div id=tabbedPaneContainer style=height:100%;
 div id=tabbedPane dojoType=dijit.layout.TabContainer
 preload=false style=width:100%;height:100%

 Steve



 On Thu, Feb 4, 2010 at 10:25 AM, Jake Vang vangj...@googlemail.com wrote:
 i'm using the sx:tabbedpanel/ in the struts2-dojo-plugin. i have a
 few questions on controlling the display/rendering of this component.

 1. can i make the sx:tabbedpanel/ expand 100% in height? i've tried
 several things: a) place the sx:tabbedpanel/ inside a table and
 set the height of the table to 100%, b) set the body/ height to
 100%, c) set the sx:tabbedpanel/ height to 100% (with combinations
 of a and/or b). none of these seem to work unless i explicitly set the
 height in px (i.e. sx:tabbedpanel cssStyle=width: 100%; height:
 400px;/), but then this doesn't expand 100% in height.

 2. how can i control how the actual tabs inside sx:tabbedpanel/ gets
 displayed (the sx:div/)? from looking at the TLD and generated HTML,
 it seems the rendering is controlled through CSS. however, at which
 level, sx:tabbedpanel/ or sx:div/, do i set the CSS? my problem is
 that i don't particularly like the rounded, blue tab display. i want
 to change it to something more linear/rectangular. when i look at the
 HTML generated, there is a link to
 /my-context/struts/TabbedPanel.css, but looking at this CSS file, i
 just see something defined for, .strutsDisabledTab div span.

 any help is appreciated. thanks.

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



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



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



Re: how to customize the rendering of a tabbedpanel? struts2, dojo plugin

2010-02-05 Thread Jake Vang
Steve, i know this is a dojo question, but while we're on it, i don't
think i need all those .js files. i think the only ones i need are
referenced by dojo.require(..) right? thanks for the heads up (i was
worried about those remote servers going away too).

On Fri, Feb 5, 2010 at 9:40 AM, Stephen Ince stephenpi...@gmail.com wrote:
 Jake,
  I actually ran into a lot problems accessing dojo from other
 servers. They all went away when I installed it locally. I think you
 get some sandbox security issues with some of the packages.

 cheers,
 Steve

 On Fri, Feb 5, 2010 at 8:44 AM, Jake Vang vangj...@googlemail.com wrote:
 stephen,

 thanks. i'm looking into the dojo js framework right now. i've
 downloaded the files, but they are almost 10 MB?  i know you can
 reference the JS on other servers too, but i'd like local copies for
 development testing. i didn't really want to use dojo directly because
 i didn't want to do programming (Java or JavaScript) right on the
 page.

 On Thu, Feb 4, 2010 at 6:10 PM, Stephen Ince stephenpi...@gmail.com wrote:
 Jake,
  The sx: tags are based on the .4 dojo tags. I would just use the
 dojo tags themselves. The dojo plugin is also being depricated. The
 new dojo tags are at 1.4.  I solved a similiar height problem on dojo
 1.4 by doing the following.


  style type=text/css
      body, html { height: 99%;overflow:hidden;
 margin-bottom:0;padding-bottom:0;}
  /style
 /head
 body class=tundra
 div id=tabbedPaneContainer style=height:100%;
 div id=tabbedPane dojoType=dijit.layout.TabContainer
 preload=false style=width:100%;height:100%

 Steve



 On Thu, Feb 4, 2010 at 10:25 AM, Jake Vang vangj...@googlemail.com wrote:
 i'm using the sx:tabbedpanel/ in the struts2-dojo-plugin. i have a
 few questions on controlling the display/rendering of this component.

 1. can i make the sx:tabbedpanel/ expand 100% in height? i've tried
 several things: a) place the sx:tabbedpanel/ inside a table and
 set the height of the table to 100%, b) set the body/ height to
 100%, c) set the sx:tabbedpanel/ height to 100% (with combinations
 of a and/or b). none of these seem to work unless i explicitly set the
 height in px (i.e. sx:tabbedpanel cssStyle=width: 100%; height:
 400px;/), but then this doesn't expand 100% in height.

 2. how can i control how the actual tabs inside sx:tabbedpanel/ gets
 displayed (the sx:div/)? from looking at the TLD and generated HTML,
 it seems the rendering is controlled through CSS. however, at which
 level, sx:tabbedpanel/ or sx:div/, do i set the CSS? my problem is
 that i don't particularly like the rounded, blue tab display. i want
 to change it to something more linear/rectangular. when i look at the
 HTML generated, there is a link to
 /my-context/struts/TabbedPanel.css, but looking at this CSS file, i
 just see something defined for, .strutsDisabledTab div span.

 any help is appreciated. thanks.

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



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



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



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



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



how to customize the rendering of a tabbedpanel? struts2, dojo plugin

2010-02-04 Thread Jake Vang
i'm using the sx:tabbedpanel/ in the struts2-dojo-plugin. i have a
few questions on controlling the display/rendering of this component.

1. can i make the sx:tabbedpanel/ expand 100% in height? i've tried
several things: a) place the sx:tabbedpanel/ inside a table and
set the height of the table to 100%, b) set the body/ height to
100%, c) set the sx:tabbedpanel/ height to 100% (with combinations
of a and/or b). none of these seem to work unless i explicitly set the
height in px (i.e. sx:tabbedpanel cssStyle=width: 100%; height:
400px;/), but then this doesn't expand 100% in height.

2. how can i control how the actual tabs inside sx:tabbedpanel/ gets
displayed (the sx:div/)? from looking at the TLD and generated HTML,
it seems the rendering is controlled through CSS. however, at which
level, sx:tabbedpanel/ or sx:div/, do i set the CSS? my problem is
that i don't particularly like the rounded, blue tab display. i want
to change it to something more linear/rectangular. when i look at the
HTML generated, there is a link to
/my-context/struts/TabbedPanel.css, but looking at this CSS file, i
just see something defined for, .strutsDisabledTab div span.

any help is appreciated. thanks.

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



Re: struts 2 and servlets, how to exclude servlet url patterns from struts filter

2010-02-01 Thread Jake Vang
thanks, that addressed my problem directly. although, i liked the no
action extension approach.

is there a feature request to pass in init-params to the struts filter
to exclude certain url patterns?

On Sun, Jan 31, 2010 at 6:56 PM, Greg Lindholm greg.lindh...@gmail.com wrote:
 Check out the Filter Mapping, default Action extensions, and
 Servlets section on this wiki page:

 http://cwiki.apache.org/confluence/display/S2WIKI/Troubleshooting+guide+migrating+from+Struts+2.0.x+to+2.1.x#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-FilterMapping%2CdefaultActionextensions%2CandServlets


 On Sun, Jan 31, 2010 at 9:12 AM, Jake Vang vangj...@googlemail.com wrote:
 i am using servlets (HttpServlet) and struts 2. my mapping in web.xml
 for the struts filter maps to the url pattern, /*. my servlet maps to
 something like this, /test. however, when i try to access my servlet,
 http://localhost:8080/myapp/test, i get the following message:

 There is no Action mapped for namespace / and action name test

 can i make exceptions for the servlet mapping so that the struts
 filter won't try to map it?

 here's a snippet from my web.xml.

 filter
  filter-namestruts2/filter-name
  filter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class
 /filter
 filter-mapping
  filter-namestruts2/filter-name
  url-pattern/*/url-pattern
 /filter-mapping
 servlet
  servlet-nametestServlet/servlet-name
  servlet-classmypackage.web.servlets.TestServlet/servlet-class
 /servlet
 servlet-mapping
  servlet-nametestServlet/servlet-name
  url-pattern/test/url-pattern
 /servlet-mapping
 servlet-mapping
 servlet-nametestServlet/servlet-name
 url-pattern/test/*/url-pattern
 /servlet-mapping

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



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



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



struts 2, writing a custom tag that is able to access objects in ActionContext using OGNL

2010-02-01 Thread Jake Vang
i was wondering if it was possible to write a custom tag that is able
to access objects in the ActionContext using OGNL? i'm not sure if
this is a correct question.

my problem is that i have a form. the form is posted to an action. the
action has getters/setters for the form fields. i then forward to
form-success.jsp. on this page, i can use the struts taglibs to access
the information posted. for example, s:property value=email/.
however, if i have a custom tag, how do i access email from the
ActionContext? for example, customTabLib:showEmail value=email/,
doesn't work. the tag displays the value, email. i also tried a
couple of things too that didn't work.

customTagLib:showEmail value=#email/
customTagLib:showEmail value=%{#email}/

is there a class/interface that i can extend/implement in struts 2
that would easily help me get the value of email from the
ActionContext in my custom tag?

thanks.

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



Re: interceptor is not being called for all action

2010-02-01 Thread Jake Vang
there were 2 approaches to getting a custom stack to work (using the
convention plugin).

approach 1: use annotations. for example, use
@ParentPackage(default) for each Action class you want to use your
custom stack. also, use @InterceptorRef for each method that you want
to use your custom stack.

why do you have to use @ParentPackage(default)? here's a non-formal
answer. when you use the convention plugin, the namespace is not
default but convention-default. i infer that defining a custom
stack is placed in the default namespace, but if you use the
convention plugin, your actions will be passed through the
convention-default namespace and associated stacks. since your stack
is in the default namespace, the stack won't ever get called (even
if you set it as the default!).

hopefully other struts 2 gurus can give us more formal/precise answers.

why do you have to use @InterceptorRef? tell tell struts which stack
to use for this action (within the namespace defined by
@ParentPackage).

approach 2: simply add 1 line to struts.xml. before the package ...
... /package declarations, add constant
name=struts.convention.default.parent.package value=default/.
using this approach, you don't need to use annotations at all. also,
with this approach, it's a one-hitter-quitter, because you don't need
to do @ParentPackage and @InterceptorRef for every class/method. the
default namespace will be used, and the custom stack will be called
on every request (assuming you use default-interceptor-ref/ to
select your custom stack as the default stack).

hope that helps.

On Sun, Jan 31, 2010 at 2:24 PM, Leah OConnor leahocon...@sbcglobal.net wrote:
 Thank you for posting your solution.  I aso read
 http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-XWorkpackages

 several times and do not see the connection.  I'm not sure I understand 
 exactly what you
 did solved the problem, but it is clerarer than the documention


 --- On Sat, 1/30/10, Jake Vang vangj...@googlemail.com wrote:


 From: Jake Vang vangj...@googlemail.com
 Subject: Re: interceptor is not being called for all action
 To: user@struts.apache.org
 Date: Saturday, January 30, 2010, 5:38 PM


 okay, to answer my own question, yes, if you configure everything correctly,
 then you can get a customized stack to work for all Actions. the only thing
 you really need to do is add this line to struts.xml

 constant name=struts.convention.default.parent.package value=default/

 with this defined, you can remove the @ParentPackage and @InterceptorRef
 from the classes and methods.

 wow, it was that easy.

 On Sat, Jan 30, 2010 at 6:14 PM, Jake Vang vangj...@googlemail.com wrote:

 okay, after fiddling around for 2 hours, with the weak documentation out
 there, i think i have it figured out. at least empirically, it works now.
 just in case there are other users out there who are running into this
 problem, let me explain what in the world i did. i know A LOT of other
 people have run into this problem on how to get interceptors to work with
 the convention plugin (googling). the shame is that although i saw a lot of
 thanks, i got it working, no one ever bothered to show how they got it to
 work.

 at any rate, if you read the original post by me, you will see how my
 interceptor stack was defined in struts.xml. you will also see how i
 implemented a dummy interceptor. i had to do two things to get my
 interceptor working (called on my action).
 1. add @ParentPackage(default) to my Action class
 2. add @interceptorref...@interceptorref(dummyStack) to my execute method
 (in my Action class).

 after i did this, my interceptor's intercept(ActionInvocation) method is
 called when my Action is called.

 here's how my dummy Action class looks like.

 @ParentPackage(default)
 public class DummyAction extends ActionSupport {
  @Action(value=/dummy,
   result...@result(name=success,location=dummy-success.jsp)},
   interceptorref...@interceptorref(dummyStack)}
  )
  public String execute() {
   return SUCCESS;
  }
 }

 alright, so, now i'd like to know how to get this interceptor stack
 (dummyStack) to work on all actions? in the link i posted, you can do so
 using one single line in struts.xml (i.e. default-interceptor-ref
 name=dummyStack/). with the convention plugin + annotations, is such a
 simple approach possible? or do i have to continuously add @ParentPackage
 and @InterceptorRef annotations to the classes and methods i want to use the
 stack?

 i don't know why this is such a pain (but then again, i'm not a developer
 on the struts2 project, so there may be a lot of complexities to get this
 working elegantly that i'm unaware of).

 On Sat, Jan 30, 2010 at 4:10 PM, Jake Vang vangj...@googlemail.comwrote:

 i have written an interceptor implementation, however, it seems i cannot
 get it to work. i have followed the instructions at
 http://struts.apache.org/2.x/docs/interceptors.html. i have also followed
 the instructions at
 http

Re: struts 2, writing a custom tag that is able to access objects in ActionContext using OGNL

2010-02-01 Thread Jake Vang
i found something helpful here. it works.

http://struts.apache.org/2.1.8.1/docs/access-to-valuestack-from-jsps.html



On Mon, Feb 1, 2010 at 7:34 AM, Jake Vang vangj...@googlemail.com wrote:
 i was wondering if it was possible to write a custom tag that is able
 to access objects in the ActionContext using OGNL? i'm not sure if
 this is a correct question.

 my problem is that i have a form. the form is posted to an action. the
 action has getters/setters for the form fields. i then forward to
 form-success.jsp. on this page, i can use the struts taglibs to access
 the information posted. for example, s:property value=email/.
 however, if i have a custom tag, how do i access email from the
 ActionContext? for example, customTabLib:showEmail value=email/,
 doesn't work. the tag displays the value, email. i also tried a
 couple of things too that didn't work.

 customTagLib:showEmail value=#email/
 customTagLib:showEmail value=%{#email}/

 is there a class/interface that i can extend/implement in struts 2
 that would easily help me get the value of email from the
 ActionContext in my custom tag?

 thanks.


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



Re: struts 2, writing a custom tag that is able to access objects in ActionContext using OGNL

2010-02-01 Thread Jake Vang
bill, thanks for including the code (especially the import statements
so i will know where these objects/classes are coming from).

On Mon, Feb 1, 2010 at 11:09 AM, Bill Bohnenberger bill98...@gmail.com wrote:
 Hi Jake,

 I have a custom table tag that needs Value Stack access, too.
 Here's how I do it:

 package...

 import org.apache.struts2.views.jsp.TagUtils;
 import org.apache.struts2.util.MakeIterator;

 public class TableTag extends SimpleTagSupport
 {
    private String list;

    public void doTag() throws JspException
    {
        ValueStack stack = TagUtils.getStack((PageContext)getJspContext());
        Iterator iterator = MakeIterator.convert(stack.findValue(list));
            while (iterator.hasNext())
            {
                ...
            }
    }

    public void setList(String list)
    {
        this.list = list;
    }
 }

 Of course list is one of my custom tag's attributes and appropriately
 defined in my TLD.

 Cheers,
 Bill


 On Mon, Feb 1, 2010 at 5:04 AM, Jake Vang vangj...@googlemail.com wrote:

 i found something helpful here. it works.

 http://struts.apache.org/2.1.8.1/docs/access-to-valuestack-from-jsps.html



 On Mon, Feb 1, 2010 at 7:34 AM, Jake Vang vangj...@googlemail.com wrote:
  i was wondering if it was possible to write a custom tag that is able
  to access objects in the ActionContext using OGNL? i'm not sure if
  this is a correct question.
 
  my problem is that i have a form. the form is posted to an action. the
  action has getters/setters for the form fields. i then forward to
  form-success.jsp. on this page, i can use the struts taglibs to access
  the information posted. for example, s:property value=email/.
  however, if i have a custom tag, how do i access email from the
  ActionContext? for example, customTabLib:showEmail value=email/,
  doesn't work. the tag displays the value, email. i also tried a
  couple of things too that didn't work.
 
  customTagLib:showEmail value=#email/
  customTagLib:showEmail value=%{#email}/
 
  is there a class/interface that i can extend/implement in struts 2
  that would easily help me get the value of email from the
  ActionContext in my custom tag?
 
  thanks.
 

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




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



struts 2 and servlets, how to exclude servlet url patterns from struts filter

2010-01-31 Thread Jake Vang
i am using servlets (HttpServlet) and struts 2. my mapping in web.xml
for the struts filter maps to the url pattern, /*. my servlet maps to
something like this, /test. however, when i try to access my servlet,
http://localhost:8080/myapp/test, i get the following message:

There is no Action mapped for namespace / and action name test

can i make exceptions for the servlet mapping so that the struts
filter won't try to map it?

here's a snippet from my web.xml.

filter
 filter-namestruts2/filter-name
 
filter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class
/filter
filter-mapping
 filter-namestruts2/filter-name
 url-pattern/*/url-pattern
/filter-mapping
servlet
 servlet-nametestServlet/servlet-name
 servlet-classmypackage.web.servlets.TestServlet/servlet-class
/servlet
servlet-mapping
 servlet-nametestServlet/servlet-name
 url-pattern/test/url-pattern
/servlet-mapping
servlet-mapping
servlet-nametestServlet/servlet-name
url-pattern/test/*/url-pattern
/servlet-mapping

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



interceptor is not being called for all action

2010-01-30 Thread Jake Vang
i have written an interceptor implementation, however, it seems i cannot get
it to work. i have followed the instructions at
http://struts.apache.org/2.x/docs/interceptors.html. i have also followed
the instructions at
http://struts.apache.org/2.x/docs/how-do-we-configure-an-interceptor-to-be-used-with-every-action.htmlto
use the interceptor with every action.

however, when any of my actions run, i never see the pre and post processing
logging messages (logging messages inside the intercept method). i do see
the logging messages from the init and destroy methods. this is not a
problem with logging (as for sanity checking, i also use System.out.println,
and have Tomcat running in console mode). i also have placed some break
points in the intercept(ActionInvocation) method, but these break points are
never reached.

this is my struts.xml.

struts
package name=default extends=struts-default
interceptors
interceptor name=dummyInterceptor
class=mypackage.DummyInterceptor/
interceptor-stack name=dummyStack
interceptor-ref name=dummyInterceptor/
interceptor-ref name=defaultStack/
/interceptor-stack
/interceptors
default-interceptor-ref name=dummyStack/
/package
/struts

this is my DummyInterceptor class.

public class DummyInterceptor implements Interceptor {
private static final Log _log =
LogFactory.getLog(DummyInterceptor.class);
public void destroy() {
_log.debug(dummy interceptor destroyed called);
System.out.println(dummy interceptor destroyed
called.toUpperCase());
}
public void init() {
_log.debug(dummy interceptor init called);
System.out.println(dummy interceptor init called.toUpperCase());
}
public String intercept(ActionInvocation actionInvocation) throws
Exception {
_log.debug(dummy interceptor intercept pre processing);
System.out.println(dummy interceptor intercept pre
processing.toUpperCase());

String result = actionInvocation.invoke();

_log.debug(dummy interceptor intercept post processing);
System.out.println(dummy interceptor intercept post
processing.toUpperCase());
return result;
}
}

i am using annotations for my Action classes, so i do not define any
action elements in struts.xml (using the Struts2 Convention jar).

one very interesting thing i did was to get struts-default.xml out of the
struts2-core-2.1.8.1.jar. i then modified struts-default.xml by adding: 1) a
definition of my interceptor and 2) my interceptor onto the defaultStack.
when i did this, my interceptor does work as expected (i see logging output
from the intercept method, i can hit break points set inside this method)
for all my actions.

i wonder if there is some gotcha that i am missing here. is there something
extra that i have to do when mixing annotations with interceptors?

thanks.


Re: interceptor is not being called for all action

2010-01-30 Thread Jake Vang
what does that have to do with my problem? please enlighten.

On Sat, Jan 30, 2010 at 4:37 PM, Dave Newton newton.d...@yahoo.com wrote:


 http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-XWorkpackages


 - Original Message 
  From: Jake Vang vangj...@googlemail.com
  To: user@struts.apache.org
  Sent: Sat, January 30, 2010 4:10:31 PM
  Subject: interceptor is not being called for all action
 
  i have written an interceptor implementation, however, it seems i cannot
 get
  it to work. i have followed the instructions at
  http://struts.apache.org/2.x/docs/interceptors.html. i have also
 followed
  the instructions at
 
 http://struts.apache.org/2.x/docs/how-do-we-configure-an-interceptor-to-be-used-with-every-action.htmlto
  use the interceptor with every action.
 
  however, when any of my actions run, i never see the pre and post
 processing
  logging messages (logging messages inside the intercept method). i do see
  the logging messages from the init and destroy methods. this is not a
  problem with logging (as for sanity checking, i also use
 System.out.println,
  and have Tomcat running in console mode). i also have placed some break
  points in the intercept(ActionInvocation) method, but these break points
 are
  never reached.
 
  this is my struts.xml.
 
 
 
 
 
  class=mypackage.DummyInterceptor/
 
 
 
 
 
 
 
 
 
  this is my DummyInterceptor class.
 
  public class DummyInterceptor implements Interceptor {
  private static final Log _log =
  LogFactory.getLog(DummyInterceptor.class);
  public void destroy() {
  _log.debug(dummy interceptor destroyed called);
  System.out.println(dummy interceptor destroyed
  called.toUpperCase());
  }
  public void init() {
  _log.debug(dummy interceptor init called);
  System.out.println(dummy interceptor init
 called.toUpperCase());
  }
  public String intercept(ActionInvocation actionInvocation) throws
  Exception {
  _log.debug(dummy interceptor intercept pre processing);
  System.out.println(dummy interceptor intercept pre
  processing.toUpperCase());
 
  String result = actionInvocation.invoke();
 
  _log.debug(dummy interceptor intercept post processing);
  System.out.println(dummy interceptor intercept post
  processing.toUpperCase());
  return result;
  }
  }
 
  i am using annotations for my Action classes, so i do not define any
  elements in struts.xml (using the Struts2 Convention jar).
 
  one very interesting thing i did was to get struts-default.xml out of the
  struts2-core-2.1.8.1.jar. i then modified struts-default.xml by adding:
 1) a
  definition of my interceptor and 2) my interceptor onto the defaultStack.
  when i did this, my interceptor does work as expected (i see logging
 output
  from the intercept method, i can hit break points set inside this method)
  for all my actions.
 
  i wonder if there is some gotcha that i am missing here. is there
 something
  extra that i have to do when mixing annotations with interceptors?
 
  thanks.


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




Re: interceptor is not being called for all action

2010-01-30 Thread Jake Vang
i read that section on that page 10 times and i don't know how that relates
to my problem. there's simply not enough information. i guess it's pointing
me to something about namespaces, but, how do we get around this?

on the other hand, the rest of that page was informative on annotations and
the convention plugin. when i added
interceptorref...@interceptorref(dummyStack)} to the Action class' execute
method, the web application won't start up.

ERROR
com.opensymphony.xwork2.util.logging.commons.CommonsLogger.error(CommonsLogger.java:27)
- Dispatcher initialization failed
...
Caused by: Unable to find interceptor class referenced by ref-name
dummyStack - [unknown location]

how hard can it be to get this to work? interestingly, if i do this,
interceptorref...@interceptorref(defaultStack)}, all is fine and dandy
(but then, my Interceptor is not called).

On Sat, Jan 30, 2010 at 4:37 PM, Dave Newton newton.d...@yahoo.com wrote:


 http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-XWorkpackages


 - Original Message 
  From: Jake Vang vangj...@googlemail.com
  To: user@struts.apache.org
  Sent: Sat, January 30, 2010 4:10:31 PM
  Subject: interceptor is not being called for all action
 
  i have written an interceptor implementation, however, it seems i cannot
 get
  it to work. i have followed the instructions at
  http://struts.apache.org/2.x/docs/interceptors.html. i have also
 followed
  the instructions at
 
 http://struts.apache.org/2.x/docs/how-do-we-configure-an-interceptor-to-be-used-with-every-action.htmlto
  use the interceptor with every action.
 
  however, when any of my actions run, i never see the pre and post
 processing
  logging messages (logging messages inside the intercept method). i do see
  the logging messages from the init and destroy methods. this is not a
  problem with logging (as for sanity checking, i also use
 System.out.println,
  and have Tomcat running in console mode). i also have placed some break
  points in the intercept(ActionInvocation) method, but these break points
 are
  never reached.
 
  this is my struts.xml.
 
 
 
 
 
  class=mypackage.DummyInterceptor/
 
 
 
 
 
 
 
 
 
  this is my DummyInterceptor class.
 
  public class DummyInterceptor implements Interceptor {
  private static final Log _log =
  LogFactory.getLog(DummyInterceptor.class);
  public void destroy() {
  _log.debug(dummy interceptor destroyed called);
  System.out.println(dummy interceptor destroyed
  called.toUpperCase());
  }
  public void init() {
  _log.debug(dummy interceptor init called);
  System.out.println(dummy interceptor init
 called.toUpperCase());
  }
  public String intercept(ActionInvocation actionInvocation) throws
  Exception {
  _log.debug(dummy interceptor intercept pre processing);
  System.out.println(dummy interceptor intercept pre
  processing.toUpperCase());
 
  String result = actionInvocation.invoke();
 
  _log.debug(dummy interceptor intercept post processing);
  System.out.println(dummy interceptor intercept post
  processing.toUpperCase());
  return result;
  }
  }
 
  i am using annotations for my Action classes, so i do not define any
  elements in struts.xml (using the Struts2 Convention jar).
 
  one very interesting thing i did was to get struts-default.xml out of the
  struts2-core-2.1.8.1.jar. i then modified struts-default.xml by adding:
 1) a
  definition of my interceptor and 2) my interceptor onto the defaultStack.
  when i did this, my interceptor does work as expected (i see logging
 output
  from the intercept method, i can hit break points set inside this method)
  for all my actions.
 
  i wonder if there is some gotcha that i am missing here. is there
 something
  extra that i have to do when mixing annotations with interceptors?
 
  thanks.


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




Re: interceptor is not being called for all action

2010-01-30 Thread Jake Vang
okay, after fiddling around for 2 hours, with the weak documentation out
there, i think i have it figured out. at least empirically, it works now.
just in case there are other users out there who are running into this
problem, let me explain what in the world i did. i know A LOT of other
people have run into this problem on how to get interceptors to work with
the convention plugin (googling). the shame is that although i saw a lot of
thanks, i got it working, no one ever bothered to show how they got it to
work.

at any rate, if you read the original post by me, you will see how my
interceptor stack was defined in struts.xml. you will also see how i
implemented a dummy interceptor. i had to do two things to get my
interceptor working (called on my action).
1. add @ParentPackage(default) to my Action class
2. add @interceptorref...@interceptorref(dummyStack) to my execute method
(in my Action class).

after i did this, my interceptor's intercept(ActionInvocation) method is
called when my Action is called.

here's how my dummy Action class looks like.

@ParentPackage(default)
public class DummyAction extends ActionSupport {
 @Action(value=/dummy,
  result...@result(name=success,location=dummy-success.jsp)},
  interceptorref...@interceptorref(dummyStack)}
 )
 public String execute() {
  return SUCCESS;
 }
}

alright, so, now i'd like to know how to get this interceptor stack
(dummyStack) to work on all actions? in the link i posted, you can do so
using one single line in struts.xml (i.e. default-interceptor-ref
name=dummyStack/). with the convention plugin + annotations, is such a
simple approach possible? or do i have to continuously add @ParentPackage
and @InterceptorRef annotations to the classes and methods i want to use the
stack?

i don't know why this is such a pain (but then again, i'm not a developer on
the struts2 project, so there may be a lot of complexities to get this
working elegantly that i'm unaware of).

On Sat, Jan 30, 2010 at 4:10 PM, Jake Vang vangj...@googlemail.com wrote:

 i have written an interceptor implementation, however, it seems i cannot
 get it to work. i have followed the instructions at
 http://struts.apache.org/2.x/docs/interceptors.html. i have also followed
 the instructions at
 http://struts.apache.org/2.x/docs/how-do-we-configure-an-interceptor-to-be-used-with-every-action.htmlto
  use the interceptor with every action.

 however, when any of my actions run, i never see the pre and post
 processing logging messages (logging messages inside the intercept method).
 i do see the logging messages from the init and destroy methods. this is not
 a problem with logging (as for sanity checking, i also use
 System.out.println, and have Tomcat running in console mode). i also have
 placed some break points in the intercept(ActionInvocation) method, but
 these break points are never reached.

 this is my struts.xml.

 struts
 package name=default extends=struts-default
 interceptors
 interceptor name=dummyInterceptor
 class=mypackage.DummyInterceptor/
 interceptor-stack name=dummyStack
 interceptor-ref name=dummyInterceptor/
 interceptor-ref name=defaultStack/
 /interceptor-stack
 /interceptors
 default-interceptor-ref name=dummyStack/
 /package
 /struts

 this is my DummyInterceptor class.

 public class DummyInterceptor implements Interceptor {
 private static final Log _log =
 LogFactory.getLog(DummyInterceptor.class);
 public void destroy() {
 _log.debug(dummy interceptor destroyed called);
 System.out.println(dummy interceptor destroyed
 called.toUpperCase());
 }
 public void init() {
 _log.debug(dummy interceptor init called);
 System.out.println(dummy interceptor init called.toUpperCase());
 }
 public String intercept(ActionInvocation actionInvocation) throws
 Exception {
 _log.debug(dummy interceptor intercept pre processing);
 System.out.println(dummy interceptor intercept pre
 processing.toUpperCase());

 String result = actionInvocation.invoke();

 _log.debug(dummy interceptor intercept post processing);
 System.out.println(dummy interceptor intercept post
 processing.toUpperCase());
 return result;
 }
 }

 i am using annotations for my Action classes, so i do not define any
 action elements in struts.xml (using the Struts2 Convention jar).

 one very interesting thing i did was to get struts-default.xml out of the
 struts2-core-2.1.8.1.jar. i then modified struts-default.xml by adding: 1) a
 definition of my interceptor and 2) my interceptor onto the defaultStack.
 when i did this, my interceptor does work as expected (i see logging output
 from the intercept method, i can hit break points set inside this method)
 for all my actions.

 i wonder if there is some gotcha that i am missing here. is there something
 extra that i have to do when mixing annotations

Re: interceptor is not being called for all action

2010-01-30 Thread Jake Vang
okay, to answer my own question, yes, if you configure everything correctly,
then you can get a customized stack to work for all Actions. the only thing
you really need to do is add this line to struts.xml

constant name=struts.convention.default.parent.package value=default/

with this defined, you can remove the @ParentPackage and @InterceptorRef
from the classes and methods.

wow, it was that easy.

On Sat, Jan 30, 2010 at 6:14 PM, Jake Vang vangj...@googlemail.com wrote:

 okay, after fiddling around for 2 hours, with the weak documentation out
 there, i think i have it figured out. at least empirically, it works now.
 just in case there are other users out there who are running into this
 problem, let me explain what in the world i did. i know A LOT of other
 people have run into this problem on how to get interceptors to work with
 the convention plugin (googling). the shame is that although i saw a lot of
 thanks, i got it working, no one ever bothered to show how they got it to
 work.

 at any rate, if you read the original post by me, you will see how my
 interceptor stack was defined in struts.xml. you will also see how i
 implemented a dummy interceptor. i had to do two things to get my
 interceptor working (called on my action).
 1. add @ParentPackage(default) to my Action class
 2. add @interceptorref...@interceptorref(dummyStack) to my execute method
 (in my Action class).

 after i did this, my interceptor's intercept(ActionInvocation) method is
 called when my Action is called.

 here's how my dummy Action class looks like.

 @ParentPackage(default)
 public class DummyAction extends ActionSupport {
  @Action(value=/dummy,
   result...@result(name=success,location=dummy-success.jsp)},
   interceptorref...@interceptorref(dummyStack)}
  )
  public String execute() {
   return SUCCESS;
  }
 }

 alright, so, now i'd like to know how to get this interceptor stack
 (dummyStack) to work on all actions? in the link i posted, you can do so
 using one single line in struts.xml (i.e. default-interceptor-ref
 name=dummyStack/). with the convention plugin + annotations, is such a
 simple approach possible? or do i have to continuously add @ParentPackage
 and @InterceptorRef annotations to the classes and methods i want to use the
 stack?

 i don't know why this is such a pain (but then again, i'm not a developer
 on the struts2 project, so there may be a lot of complexities to get this
 working elegantly that i'm unaware of).

 On Sat, Jan 30, 2010 at 4:10 PM, Jake Vang vangj...@googlemail.comwrote:

 i have written an interceptor implementation, however, it seems i cannot
 get it to work. i have followed the instructions at
 http://struts.apache.org/2.x/docs/interceptors.html. i have also followed
 the instructions at
 http://struts.apache.org/2.x/docs/how-do-we-configure-an-interceptor-to-be-used-with-every-action.htmlto
  use the interceptor with every action.

 however, when any of my actions run, i never see the pre and post
 processing logging messages (logging messages inside the intercept method).
 i do see the logging messages from the init and destroy methods. this is not
 a problem with logging (as for sanity checking, i also use
 System.out.println, and have Tomcat running in console mode). i also have
 placed some break points in the intercept(ActionInvocation) method, but
 these break points are never reached.

 this is my struts.xml.

 struts
 package name=default extends=struts-default
 interceptors
 interceptor name=dummyInterceptor
 class=mypackage.DummyInterceptor/
 interceptor-stack name=dummyStack
 interceptor-ref name=dummyInterceptor/
 interceptor-ref name=defaultStack/
 /interceptor-stack
 /interceptors
 default-interceptor-ref name=dummyStack/
 /package
 /struts

 this is my DummyInterceptor class.

 public class DummyInterceptor implements Interceptor {
 private static final Log _log =
 LogFactory.getLog(DummyInterceptor.class);
 public void destroy() {
 _log.debug(dummy interceptor destroyed called);
 System.out.println(dummy interceptor destroyed
 called.toUpperCase());
 }
 public void init() {
 _log.debug(dummy interceptor init called);
 System.out.println(dummy interceptor init called.toUpperCase());
 }
 public String intercept(ActionInvocation actionInvocation) throws
 Exception {
 _log.debug(dummy interceptor intercept pre processing);
 System.out.println(dummy interceptor intercept pre
 processing.toUpperCase());

 String result = actionInvocation.invoke();

 _log.debug(dummy interceptor intercept post processing);
 System.out.println(dummy interceptor intercept post
 processing.toUpperCase());
 return result;
 }
 }

 i am using annotations for my Action classes, so i do not define any
 action elements in struts.xml (using the Struts2 Convention jar).

 one very

Re: Redirect Action and wildcard methods

2009-10-18 Thread jake
Thanks for the reply, it does work as it should, but I made a silly mistake :(
Nothing like wasting a day!

Jake

On Sat, Oct 17, 2009 at 04:23:05PM -0700, Tommy Pham wrote:
 
 
 
 
 From: j...@researchtogether.com j...@researchtogether.com
 To: user@struts.apache.org
 Sent: Sat, October 17, 2009 10:12:45 AM
 Subject: Redirect Action and wildcard methods
 
 Hi,
 
 I have the following actions set up:
 
action name=post* class=com.mypack.PostAction method={1}
  result 
 name=category/WEB-INF/jsp/pages/PostCategory.jsp/result
  result name=topic/WEB-INF/jsp/pages/PostTopic.jsp/result
  result name=display 
 type=redirectActiondisplayCategory/result
/action
   
action name=display* class=com.mypack.DisplayAction method={1}
  result 
 name=category/WEB-INF/jsp/pages/DisplayCategory.jsp/result
  result name=topic/WEB-INF/jsp/pages/Topic.jsp/result
/action
 
 In my post action I return display which should redirect to the action 
 displayCategory which, by the way I have the display action set up should 
 call the Category method in the DisplayAction class, but it doesn't. It 
 calls the execute method.
 
 Tommy  I remember correctly from my reading, you need to return category. 
  Have you gone through the bootstrap guide/tutorial?
 
 I have tried setting up the redirectAction up in a coupld of ways, firstly as 
 show above, but also using
 param name=actioniNamedisplay/param
 param name=methodCategory/param
 using this method I get a java.lang.NoSuchMethodException: 
 com.mypack.DisplayAction.!Category() the method *does* exist as I can browse 
 to displayCategory and the behaviour is correct - is the .! part of the 
 problem here?
 
 and also param name=actionNamedisplayCategory/param does the same as 
 the more complete action detailed above.
 
 Can anyone provide any insight as to why it isn't working as I expect?
 
 Cheers,
 Jake aka _LisWork
 
 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org

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



Redirect Action and wildcard methods

2009-10-17 Thread jake
Hi,

I have the following actions set up:

   action name=post* class=com.mypack.PostAction method={1}
 result 
name=category/WEB-INF/jsp/pages/PostCategory.jsp/result
 result name=topic/WEB-INF/jsp/pages/PostTopic.jsp/result
 result name=display 
type=redirectActiondisplayCategory/result
   /action
   
   action name=display* class=com.mypack.DisplayAction method={1}
 result 
name=category/WEB-INF/jsp/pages/DisplayCategory.jsp/result
 result name=topic/WEB-INF/jsp/pages/Topic.jsp/result
   /action

In my post action I return display which should redirect to the action 
displayCategory which, by the way I have the display action set up should 
call the Category method in the DisplayAction class, but it doesn't. It calls 
the execute method.

I have tried setting up the redirectAction up in a coupld of ways, firstly as 
show above, but also using
param name=actioniNamedisplay/param
param name=methodCategory/param
using this method I get a java.lang.NoSuchMethodException: 
com.mypack.DisplayAction.!Category() the method *does* exist as I can browse to 
displayCategory and the behaviour is correct - is the .! part of the problem 
here?

and also param name=actionNamedisplayCategory/param does the same as the 
more complete action detailed above.

Can anyone provide any insight as to why it isn't working as I expect?

Cheers,
Jake aka _LisWork

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



RE: Struts 2 and SSL

2007-12-19 Thread Jake Robb
Have a look at the implementation of the plugin's interceptor:

http://struts2-ssl-plugin.googlecode.com/svn/trunk/plugin/src/main/java/
com/googlecode/sslplugin/interceptors/SSLInterceptor.java

Just change it so that it looks at something else instead of the
annotation.

-Jake


-Original Message-
From: Maxx [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 19, 2007 2:10 PM
To: Struts Users Mailing List
Subject: Re: Struts 2 and SSL

Hello,

Good idea, but when it's about annotations, is it about Java 5?
How to handle/use this in Java (1.)4 ?

Thanks,
Maxx

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


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



RE: s:checkbox preselect

2007-12-12 Thread Jake Robb
What about using s:checkboxlist with a single-item list?

-Jake


-Original Message-
From: bhaarat Sharma [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 12, 2007 4:36 PM
To: Struts Users Mailing List
Subject: Re: s:checkbox preselect

tried it and doesnt work :(

this is a real drawback that struts2 allows only true or false to come
from checkboxes

On 12/12/07, Jason Deffenbaugh [EMAIL PROTECTED] wrote:
Try this:

 s:checkbox label=\\\checkbox test\\\ name=\\\checkboxField1\\\
 fieldValue=\\\something\\\ value=\checkboxField1\/

 I\'m not sure that will work.

 -J

 On Wed, 2007-12-12 at 16:15 -0500, bhaarat Sharma wrote:
  but in my action class i am doing a lot of stuff based on the
  \\\'value\\\' of the checkbox.
 
  is there no way to do this other than making fieldValue a boolean
value!?!
 
  If I do that I will have to change a lot of stuff in my action
class.
  Also, this isnt mentioned in the documentation for checkbox.  :(
 
  On 12/12/07, Johannes Geppert [EMAIL PROTECTED] wrote:
  try to use boolean and not String for checkboxes.
  
   Bye
   jogep
  
my getters and setters:
public String getCheckboxField1() {
return checkboxField1;
}
   
public void setCheckboxField1(String checkboxField1) {
this.checkboxField1 = checkboxField1;
}
   
  
  
  
-
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
  --
  -bhaarat
 
 
-
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 


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



--
-bhaarat

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


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



[S2] Restricting paths?

2007-11-06 Thread Jake Robb
I have an action called MainMenu.  It's defined as follows:

action name=MainMenu class=mainMenuAction
result name=success type=tilesmainMenu/result
/action

(I'm using the Spring plugin - mainMenuAction is the name of the spring
bean)

I want MainMenu to be accessible at the following URL:

http://server/main/MainMenu.action

And, as expected, it is available there.  However, it's also available
at any of these:

http://server/MainMenu.action
http://server/what/MainMenu.action
http://server/foo/MainMenu.action
http://server/bar/MainMenu.action
http://server/arbitrarily/long/path/MainMenu.action

etc.

I tried changing the action definition like so:

action name=/main/MainMenu class=mainMenuAction
result name=success type=tilesmainMenu/result
/action

But now my action isn't available at *any* path.

How can I restrict access to the action to only the path(s) I want?

Thanks!

-Jake

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



RE: [S2] Restricting paths?

2007-11-06 Thread Jake Robb
Thanks, that did it!  I didn't have namespace attributes for any of my
packages.  :)

-Original Message-
From: Gary Affonso [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 06, 2007 9:33 AM
To: Struts Users Mailing List
Subject: Re: [S2] Restricting paths?

Did you checkout the namespace setting of your package?

- Gary

Jake Robb wrote:
 I have an action called MainMenu.  It's defined as follows:
 
 action name=MainMenu class=mainMenuAction
 result name=success type=tilesmainMenu/result
 /action
 
 (I'm using the Spring plugin - mainMenuAction is the name of the
spring
 bean)
 
 I want MainMenu to be accessible at the following URL:
 
 http://server/main/MainMenu.action
 
 And, as expected, it is available there.  However, it's also available
 at any of these:
 
 http://server/MainMenu.action
 http://server/what/MainMenu.action
 http://server/foo/MainMenu.action
 http://server/bar/MainMenu.action
 http://server/arbitrarily/long/path/MainMenu.action
 
 etc.
 
 I tried changing the action definition like so:
 
 action name=/main/MainMenu class=mainMenuAction
 result name=success type=tilesmainMenu/result
 /action
 
 But now my action isn't available at *any* path.
 
 How can I restrict access to the action to only the path(s) I want?
 
 Thanks!
 
 -Jake
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


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


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



[S2] Display Tag? (2.0.11)

2007-11-01 Thread Jake Robb
I've used DisplayTag with S1 before, with excellent results.  I'm also
using it in S2 in a few cases, and it's working fine.

However, now I want to use it to render a form.  Each row in the table
will contain a couple of input tags, and the table as a whole represents
a single List on my action.

Without DisplayTag, I can accomplish that as follows:

  s:iterator value=rules status=status id=rule
div class=resultRow${status.odd ? ' highlight' : ''}
  div class=name
s:property value=name /
  /div
  div class=value
s:textfield name=%{'rules['+#status.index+'].value'} label=
size=90 /
  /div
/div
  /s:iterator


I converted the code above as follows:

  display:table htmlId=rulesTable list=rules id=rule
display:column title=Rule Name
  s:property value=name /
/display:column
display:column title=Rule Name
  s:textfield name=rules[rule_rowNum].value label= size=90 /
/display:column
  /display:table


But that didn't work, because DisplayTag doesn't push rule_rowNum onto
the stack.  So I added a push tag:

  display:table htmlId=rulesTable list=rules id=rule
s:push value=%= rule_rowNum.toString() % id=rowNum/
display:column title=Rule Name
  s:property value=name /
/display:column
display:column title=Rule Name
  s:textfield name=rules[rowNum].value size=90 /
/display:column
  /display:table


Then I discovered that s:push doesn't accept runtime expressions, just
like everything else in 2.0.11.

So, how do I accomplish this?  I guess I could keep it the old way, but
I'd really rather be consistent.

-Jake

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



RE: property from S2 in S1

2007-10-12 Thread Jake Robb
I think you're looking for bean:write.

-Jake

-Original Message-
From: Pavel Sapozhnikov [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 12, 2007 1:25 PM
To: Struts Users Mailing List
Subject: s:property from S2 in S1

Hi I have a question. So in S2 you have s:property which just takes from
a
form and simply displays it on the page. How do you do exactly that in
S1.
Thanks.

-- 
Pavel Sapozhnikov
xFact, Inc
[EMAIL PROTECTED]

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



[S2] s:if test attribute not a runtime expression?

2007-10-10 Thread Jake Robb
Okay, this might be a question for the dev list, but bear with me for a
minute.

My application is currently using Struts 2.0.8.  I read about some
security and bug fixes in 2.0.9 and 2.0.10.  According to the Struts
JIRA server, 2.0.10 has been complete since September 9th, so I figured
I'd wait for that to get promoted to GA rather than upgrading to 2.0.9
and then to 2.0.10 shortly thereafter.  I then noticed that 2.0.11 is
also complete in JIRA, and has been since September 21st.

My application is in early development, so I can afford to be an early
adopter.  To that end, I just downloaded Struts 2.0.11 from here: 
http://people.apache.org/builds/struts/2.0.11/

I upgraded the JAR files in my application and rebuilt.  A quick sanity
check revealed a JSP compile error:

ConfigureRules.jsp:9:7: Static attribute must be a String literal, its
illegal to specify an expression.
s:if test=${not empty rules}
  ^--^

I dug around for a minute and found something weird.  The following is
an excerpt from struts-tags.tld, which is in struts2-core-2.0.11.jar:

  tag
nameif/name
tag-classorg.apache.struts2.views.jsp.IfTag/tag-class
body-contentJSP/body-content
description![CDATA[If tag]]/description
attribute
  nameid/name
  requiredfalse/required
  rtexprvaluefalse/rtexprvalue
  description![CDATA[id for referencing element. For UI and form
tags it will be used as HTML id attribute]]/description
/attribute
attribute
  nametest/name
  requiredtrue/required
  rtexprvaluefalse/rtexprvalue
  description![CDATA[Expression to determine if body of tag is to
be displayed]]/description
/attribute
  /tag

As you can see, the attribute test is configured not to allow runtime
expressions.  I went back and checked in 2.0.8, and rtexprvalue was true
in that version.  I downloaded 2.0.9, and it was true there too.  I
haven't downloaded 2.0.10.

So, here's my question:

Is that a deliberate change?  If so, why, and what is the new way to
accomplish what I was doing before?

And a side question: once a version is complete in JIRA, what else has
to happen before that version becomes GA?

Thanks,
Jake Robb

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



RE: [S2] s:if test attribute not a runtime expression?

2007-10-10 Thread Jake Robb
Pardon me for being totally new to OGNL, but what would be the
equivalent of ${not empty rules}?

-Original Message-
From: Wes Wannemacher [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 10, 2007 2:44 PM
To: Struts Users Mailing List
Subject: Re: [S2] s:if test attribute not a runtime expression?

I noticed something broken in showcase on trunk once and brought it up -

https://issues.apache.org/struts/browse/WW-2206

In discussion, I realized that the dev team is moving away from other
expression languages in favor of OGNL only (or whatever is plugged-in
in struts 2.1.x).

-W

On 10/10/07, Jake Robb [EMAIL PROTECTED] wrote:
 Okay, this might be a question for the dev list, but bear with me for
a
 minute.

 My application is currently using Struts 2.0.8.  I read about some
 security and bug fixes in 2.0.9 and 2.0.10.  According to the Struts
 JIRA server, 2.0.10 has been complete since September 9th, so I
figured
 I'd wait for that to get promoted to GA rather than upgrading to 2.0.9
 and then to 2.0.10 shortly thereafter.  I then noticed that 2.0.11 is
 also complete in JIRA, and has been since September 21st.

 My application is in early development, so I can afford to be an early
 adopter.  To that end, I just downloaded Struts 2.0.11 from here:
 http://people.apache.org/builds/struts/2.0.11/

 I upgraded the JAR files in my application and rebuilt.  A quick
sanity
 check revealed a JSP compile error:

 ConfigureRules.jsp:9:7: Static attribute must be a String literal, its
 illegal to specify an expression.
 s:if test=${not empty rules}
   ^--^

 I dug around for a minute and found something weird.  The following is
 an excerpt from struts-tags.tld, which is in struts2-core-2.0.11.jar:

   tag
 nameif/name
 tag-classorg.apache.struts2.views.jsp.IfTag/tag-class
 body-contentJSP/body-content
 description![CDATA[If tag]]/description
 attribute
   nameid/name
   requiredfalse/required
   rtexprvaluefalse/rtexprvalue
   description![CDATA[id for referencing element. For UI and
form
 tags it will be used as HTML id attribute]]/description
 /attribute
 attribute
   nametest/name
   requiredtrue/required
   rtexprvaluefalse/rtexprvalue
   description![CDATA[Expression to determine if body of tag is
to
 be displayed]]/description
 /attribute
   /tag

 As you can see, the attribute test is configured not to allow
runtime
 expressions.  I went back and checked in 2.0.8, and rtexprvalue was
true
 in that version.  I downloaded 2.0.9, and it was true there too.  I
 haven't downloaded 2.0.10.

 So, here's my question:

 Is that a deliberate change?  If so, why, and what is the new way to
 accomplish what I was doing before?

 And a side question: once a version is complete in JIRA, what else
has
 to happen before that version becomes GA?

 Thanks,
 Jake Robb

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




-- 
Wesley Wannemacher
President, Head Engineer/Consultant
WanTii, Inc.
http://www.wantii.com

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


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



RE: [S2] s:if test attribute not a runtime expression?

2007-10-10 Thread Jake Robb
Thanks, that seems to have done the trick.  :)

-Original Message-
From: Wes Wannemacher [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 10, 2007 2:50 PM
To: Struts Users Mailing List
Subject: Re: [S2] s:if test attribute not a runtime expression?

%{rules != null  rules.size()  0}

(I didn't test it, I'm just guessing)

-W

On 10/10/07, Jake Robb [EMAIL PROTECTED] wrote:
 Pardon me for being totally new to OGNL, but what would be the
 equivalent of ${not empty rules}?

 -Original Message-
 From: Wes Wannemacher [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, October 10, 2007 2:44 PM
 To: Struts Users Mailing List
 Subject: Re: [S2] s:if test attribute not a runtime expression?

 I noticed something broken in showcase on trunk once and brought it up
-

 https://issues.apache.org/struts/browse/WW-2206

 In discussion, I realized that the dev team is moving away from other
 expression languages in favor of OGNL only (or whatever is plugged-in
 in struts 2.1.x).

 -W

 On 10/10/07, Jake Robb [EMAIL PROTECTED] wrote:
  Okay, this might be a question for the dev list, but bear with me
for
 a
  minute.
 
  My application is currently using Struts 2.0.8.  I read about some
  security and bug fixes in 2.0.9 and 2.0.10.  According to the Struts
  JIRA server, 2.0.10 has been complete since September 9th, so I
 figured
  I'd wait for that to get promoted to GA rather than upgrading to
2.0.9
  and then to 2.0.10 shortly thereafter.  I then noticed that 2.0.11
is
  also complete in JIRA, and has been since September 21st.
 
  My application is in early development, so I can afford to be an
early
  adopter.  To that end, I just downloaded Struts 2.0.11 from here:
  http://people.apache.org/builds/struts/2.0.11/
 
  I upgraded the JAR files in my application and rebuilt.  A quick
 sanity
  check revealed a JSP compile error:
 
  ConfigureRules.jsp:9:7: Static attribute must be a String literal,
its
  illegal to specify an expression.
  s:if test=${not empty rules}
^--^
 
  I dug around for a minute and found something weird.  The following
is
  an excerpt from struts-tags.tld, which is in
struts2-core-2.0.11.jar:
 
tag
  nameif/name
  tag-classorg.apache.struts2.views.jsp.IfTag/tag-class
  body-contentJSP/body-content
  description![CDATA[If tag]]/description
  attribute
nameid/name
requiredfalse/required
rtexprvaluefalse/rtexprvalue
description![CDATA[id for referencing element. For UI and
 form
  tags it will be used as HTML id attribute]]/description
  /attribute
  attribute
nametest/name
requiredtrue/required
rtexprvaluefalse/rtexprvalue
description![CDATA[Expression to determine if body of tag
is
 to
  be displayed]]/description
  /attribute
/tag
 
  As you can see, the attribute test is configured not to allow
 runtime
  expressions.  I went back and checked in 2.0.8, and rtexprvalue was
 true
  in that version.  I downloaded 2.0.9, and it was true there too.  I
  haven't downloaded 2.0.10.
 
  So, here's my question:
 
  Is that a deliberate change?  If so, why, and what is the new way to
  accomplish what I was doing before?
 
  And a side question: once a version is complete in JIRA, what else
 has
  to happen before that version becomes GA?
 
  Thanks,
  Jake Robb
 
 
-
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


 --
 Wesley Wannemacher
 President, Head Engineer/Consultant
 WanTii, Inc.
 http://www.wantii.com

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


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




-- 
Wesley Wannemacher
President, Head Engineer/Consultant
WanTii, Inc.
http://www.wantii.com

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


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



[S2] Indexed properties

2007-10-10 Thread Jake Robb
Okay, so I figured out the right syntax for the question I posted
yesterday (subject: List properties in Struts 2).

Let's say I have a List of key-value pairs and I want to render the
entire list to the user as a form.  In Struts 1.x, here's the JSP
snippet:

  logic:iterate list=pairs
html:text name=pairs property=key indexed=true /
html:text name=pairs property=value indexed=true /
  /logic:iterate 

But in S2, I have to do this:

  s:iterator value=pairs status=status
s:textfield name=%{'pairs['+#status.index+'].name'} /
s:textfield name=%{'pairs['+#status.index+'].value'} /
  /s:iterator

It seems to me that this use case is common enough that the S2 method
should be more friendly and obvious, and should not involve assembling
an OGNL expression manually in the JSP.  It seems to me that bringing
back Struts 1's iterator-aware field tags would be relatively
straightforward.  It'd be extra nice if the tag simply recognized that
the value being pulled in from an iterator automatically, so that you
didn't even need the indexed attribute:

  s:iterator value=pairs id=pair
s:textfield name=name /
s:textfield name=value /
  /s:iterator

How difficult would that be?  It already works to *populate* a form; I
just can't submit back to the action and have it fill in my object.  

Am I the only one that thinks that the current S2 way is a huge pain?

-Jake Robb

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



List properties in Struts 2

2007-10-09 Thread Jake Robb
Hi everyone.  I’m new to the list.  :)

I’m working on a new Struts 2 application (my first).  I have quite a bit of 
experience with Struts 1.x.

I have a need to administer a set of rules, which are essentially name/value 
pairs.  The number of rules is dynamic.  I have a POJO class called Rule that 
has getters and setters for name and value.

On my Action, I have a List property with corresponding get and set methods:

public ListRule getRules() {
return rules;
}

public void setRules(ListRule rules_) {
rules = rules_;
}

private ListRule rules;

On my JSP, I have the following block of code:

div id=results
s:iterator value=rules status=status
div class=resultRow
div class=name
s:textfield name=name /
/div
div class=value
s:textfield name=value /
/div
/div
/s:iterator
/div

The page renders as expected, but when I submit the page, ParametersInterceptor 
logs the following error messages:

 [setParameters]: Unexpected Exception caught setting 'name' on 'class 
 com.blah.BlahAction: Error setting expression 'name' with value 
 '[Ljava.lang.String;@1fbc95c'

 [setParameters]: Unexpected Exception caught setting 'value' on 'class
 com.blah.BlahAction: Error setting expression 'value' with value 
 '[Ljava.lang.String;@160cd93'

What am I doing wrong?  I've tried several other approaches (indexed and mapped 
setters, and changing the name properties on the textfield tags accordingly), 
but I did some googling and found this: 
http://www.mail-archive.com/user@struts.apache.org/msg60905.html.  It seems to 
me that the approach I described above is the same as the one described in that 
message.

I'm thinking this is a typical greenie mistake, and I'm hoping someone here can 
set me straight.

Thanks,
Jake Robb