Re: unit testing Struts2 application (with Spring and Hibernate)

2009-08-07 Thread Dimitrios Christodoulakis
Thanks for this news! I will give it a try.

On Fri, Aug 7, 2009 at 1:56 PM, Musachy Barrosomusa...@gmail.com wrote:
 I have updated the JUnit plugin, to provide support for this kind of
 testing(also for spring testing), see the documentation here:

 http://cwiki.apache.org/confluence/display/WW/Testing+Actions

 See the 2 classes here:

 http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/

 feedback is welcome, before 2.1.8 is released, using this classes you
 can test your action output like:

 public void testExecuteAction() throws ServletException,
 UnsupportedEncodingException {
        String output = executeAction(/test/testAction.action);
        assertEquals(Hello, output);
 }

 for something like this to work you will have to use FreeMarker or
 velocity for the results, or the experimental JSP plugin:

 http://cwiki.apache.org/S2PLUGINS/embedded-jsp-plugin.html

 musachy

 On Tue, Jul 21, 2009 at 2:26 PM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:

 In your code below, where you say // and then execute proxy again, are you
 missing some stepls where you need to supply some parameters to the
 action?

 Yes, that wasn't actual code, just the steps I was considering.

 -In any case it's good to know the limitations of the example. You are
 right, sometimes I need to test a broader unit of work, which can
 include a couple of actions, rather than just one. So, in that sense,
 I could be stepping into the functional testing area.

 I appreciate all the helpful information. I've already learned a lot,
 by the example code, and the discussions on this thread!


 On Tue, Jul 21, 2009 at 3:31 PM, Haroon
 Rafiqueharoon.rafi...@utoronto.ca wrote:
 On Today at 2:02pm, DC=Dimitrios Christodoulakis dimi@gmail.com 
 wrote:

 DC [..snip..]
 DC
 DC The CONFIG_LOCATIONS is used to initialize the servletContext which in
 DC turn is used to initialize the applicationContext, right? So, I am not
 DC sure where is the correct place to add the web.xml file, or how to
 DC tell BaseStrutsTestCase to include OpenEntityManagerInViewFilter
 DC during the recreation of the framework.
 DC

 The CONFIG_LOCATIONS variable is used to initialize spring only. I don't
 use spring-orm, so I can't comment on how to tell BaseStrutsTestCase to
 include that particular filter (or any other filter for that matter).

 DC
 DC Is that a limitation of this test class, or I am trying to include my
 DC web.xml file the wrong way?
 DC

 Most probably a limitation.

 DC
 DC I am not sure if other folks using this example code dealt with
 DC something like this in the past and solved it. Haroon, I hope you
 DC don't mind my asking you again about this :)
 DC
 DC Also, a more general question: Can the proxy class be used to create
 DC and run two actions sequentially? Let's say I want to test an action
 DC in my secure namespace, meaning that some sort of login or
 DC registration action comes first.
 DC

 I think you're over-stepping the bounds of unit testing here. In any case,
 I have created multiple invocations of the same action in the same test
 method without any problems. E.g.,

 createAction(SomeAction.class, /namespace, actionName);
 //... set some parameters
 assertEquals(SUCCESS, proxy.execute());
 //create action again
 createAction(SomeAction.class, /namespace, actionName);
 //... set some *different* parameters so that we expect INPUT to be
 // returned
 assertEquals(INPUT, proxy.execute());

 There's nothing to prevent you from recreating another Action all
 together. You just have to remember that every time you execute
 createAction, it creates a new mock request and mock response, so you have
 to populate things properly.


 DC
 DC So, could I do something like this in my test method?:
 DC

 In your code below, where you say // and then execute proxy again, are you
 missing some stepls where you need to supply some parameters to the
 action?

 DC
 DC @Test
 DC public void testExecute() throws Exception{
 DC Login testLogin = createAction(Login.class, /, Login);
 DC //set my fields
 DC testLogin.setPassword(...);
 DC //execute proxy once
 DC proxy.execute();
 DC //Then create my secure action
 DC UpdateProfile testUpdateProfile =
 DC                     createAction(UpdateProfile.class, /secure, 
 UpdateProfile);
 DC //and then execute proxy again
 DC proxy.execute();
 DC }
 DC
 DC [..snip..]
 DC
 DC Up until now I manually created mock objects to satisfy any
 DC dependencies of the class under test: Created a user object and put in
 DC on a Session map manually to simulate a successful login action. So
 DC the motive here was to use this example test code to actually create
 DC and execute a successful test of the predecessor action (so the login
 DC action itself could add the logged in user to the session) before the
 DC actual action that I am primarily testing (updateProfile).
 DC

 Smells like functional testing to me.

 DC
 DC Anyway, I sure hope I am

Re: studying struts2 framework, ActionInvocation question

2009-07-24 Thread Dimitrios Christodoulakis
I tried to logically trace the flow within the framework and wanted to
check if my thoughts are correct here, while at the same time asking a
few more questions:

As a start I take DefaultActionProxyFactory. DefaultActionProxyFactory
instantiates DefaultActionProxy, but also gives us
DefaultActionInvocation via its createActionProxy methods, using the
new operator.

The DefaultActionProxy constructor takes ActionInvocation as parameter
and sets the ActionInvocation interface field by means of a
DefaultActionInvocation implementation.

Next, DefaultActionInvocation takes extraContext and a boolean as
constructor params. It also has a reference to the ActionProxy which I
believe sets via its init method?

DefaultActionInvocation also creates the actions with its
createAction(MapString, Object contextMap) method, letting an
objectFactory take care of the actual creation with information taken
from the ActionProxy (like action name, name space, config, etc).

Then DefaultActionInvocation also invokes the action by calling
invokeAction(action, actionConfig).

This is more to help me understand the basic workflow at a higher
level at first. Are my above statements correct?

One thing that I find confusing (at this time) is the use of so many
contexts: extraContext, actionContext, invocationContext, etc. What
is the primary use of the context? Is it similar to the configuration
object?

I still have as a short term objective to unit test my
intercept(actionInvocation) method of my custom Interceptor, but is it
true to assume that to prepare for the test I'd probably need to
create a lot of dependencies manually? i.e. Create mock objects all
the way deep to DefaultActionProxyFactory?

Many thanks again for your help.




On Thu, Jul 23, 2009 at 5:37 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 By the way I noticed that when I downloaded the s2 source code, it
 didn't come with the opensymphony packages... Does the xwork source
 has to be downloaded separately?

 Yes.

 Dave

 -
 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: studying struts2 framework, ActionInvocation question

2009-07-24 Thread Dimitrios Christodoulakis
I plan to unit test the interceptor on its own. I am more interested
in testing its logic, not necessarily within the framework.

First step would be to mock an ActionInvocation object which is what
is passed to the Interceptor's intercept method. The action invocation
would need a mock action, and a mock session which will be holding the
user credentials. In order to have a session I would need to first
have an invocation object to get the session from:
actionInvocation.getInvocationContext().getSession()

On Fri, Jul 24, 2009 at 10:52 AM, Musachy Barrosomusa...@gmail.com wrote:
 You don't need to create mock objects for the framework, you onlt need
 to mock the objects passed to the interceptor and invoke the
 interceptor directly, unless you really want to test the interceptor
 running inside struts (there is a long thread about that so i wont get
 into it)

 musachy

 On Fri, Jul 24, 2009 at 6:31 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 I tried to logically trace the flow within the framework and wanted to
 check if my thoughts are correct here, while at the same time asking a
 few more questions:

 As a start I take DefaultActionProxyFactory. DefaultActionProxyFactory
 instantiates DefaultActionProxy, but also gives us
 DefaultActionInvocation via its createActionProxy methods, using the
 new operator.

 The DefaultActionProxy constructor takes ActionInvocation as parameter
 and sets the ActionInvocation interface field by means of a
 DefaultActionInvocation implementation.

 Next, DefaultActionInvocation takes extraContext and a boolean as
 constructor params. It also has a reference to the ActionProxy which I
 believe sets via its init method?

 DefaultActionInvocation also creates the actions with its
 createAction(MapString, Object contextMap) method, letting an
 objectFactory take care of the actual creation with information taken
 from the ActionProxy (like action name, name space, config, etc).

 Then DefaultActionInvocation also invokes the action by calling
 invokeAction(action, actionConfig).

 This is more to help me understand the basic workflow at a higher
 level at first. Are my above statements correct?

 One thing that I find confusing (at this time) is the use of so many
 contexts: extraContext, actionContext, invocationContext, etc. What
 is the primary use of the context? Is it similar to the configuration
 object?

 I still have as a short term objective to unit test my
 intercept(actionInvocation) method of my custom Interceptor, but is it
 true to assume that to prepare for the test I'd probably need to
 create a lot of dependencies manually? i.e. Create mock objects all
 the way deep to DefaultActionProxyFactory?

 Many thanks again for your help.




 On Thu, Jul 23, 2009 at 5:37 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 By the way I noticed that when I downloaded the s2 source code, it
 didn't come with the opensymphony packages... Does the xwork source
 has to be downloaded separately?

 Yes.

 Dave

 -
 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





 --
 Hey you! Would you help me to carry the stone? Pink Floyd

 -
 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: studying struts2 framework, ActionInvocation question

2009-07-24 Thread Dimitrios Christodoulakis
Let me correct an error below, I meant: ... I would need to first
have an invocation *context* to get the session from...

I still have difficulty grasping the idea of all the different
contexts, and their general use, but should be able to go ahead with
the unit test.

On Fri, Jul 24, 2009 at 11:14 AM, Dimitrios
Christodoulakisdimi@gmail.com wrote:
 I plan to unit test the interceptor on its own. I am more interested
 in testing its logic, not necessarily within the framework.

 First step would be to mock an ActionInvocation object which is what
 is passed to the Interceptor's intercept method. The action invocation
 would need a mock action, and a mock session which will be holding the
 user credentials. In order to have a session I would need to first
 have an invocation object to get the session from:
 actionInvocation.getInvocationContext().getSession()

 On Fri, Jul 24, 2009 at 10:52 AM, Musachy Barrosomusa...@gmail.com wrote:
 You don't need to create mock objects for the framework, you onlt need
 to mock the objects passed to the interceptor and invoke the
 interceptor directly, unless you really want to test the interceptor
 running inside struts (there is a long thread about that so i wont get
 into it)

 musachy

 On Fri, Jul 24, 2009 at 6:31 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 I tried to logically trace the flow within the framework and wanted to
 check if my thoughts are correct here, while at the same time asking a
 few more questions:

 As a start I take DefaultActionProxyFactory. DefaultActionProxyFactory
 instantiates DefaultActionProxy, but also gives us
 DefaultActionInvocation via its createActionProxy methods, using the
 new operator.

 The DefaultActionProxy constructor takes ActionInvocation as parameter
 and sets the ActionInvocation interface field by means of a
 DefaultActionInvocation implementation.

 Next, DefaultActionInvocation takes extraContext and a boolean as
 constructor params. It also has a reference to the ActionProxy which I
 believe sets via its init method?

 DefaultActionInvocation also creates the actions with its
 createAction(MapString, Object contextMap) method, letting an
 objectFactory take care of the actual creation with information taken
 from the ActionProxy (like action name, name space, config, etc).

 Then DefaultActionInvocation also invokes the action by calling
 invokeAction(action, actionConfig).

 This is more to help me understand the basic workflow at a higher
 level at first. Are my above statements correct?

 One thing that I find confusing (at this time) is the use of so many
 contexts: extraContext, actionContext, invocationContext, etc. What
 is the primary use of the context? Is it similar to the configuration
 object?

 I still have as a short term objective to unit test my
 intercept(actionInvocation) method of my custom Interceptor, but is it
 true to assume that to prepare for the test I'd probably need to
 create a lot of dependencies manually? i.e. Create mock objects all
 the way deep to DefaultActionProxyFactory?

 Many thanks again for your help.




 On Thu, Jul 23, 2009 at 5:37 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 By the way I noticed that when I downloaded the s2 source code, it
 didn't come with the opensymphony packages... Does the xwork source
 has to be downloaded separately?

 Yes.

 Dave

 -
 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





 --
 Hey you! Would you help me to carry the stone? Pink Floyd

 -
 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: studying struts2 framework, ActionInvocation question

2009-07-23 Thread Dimitrios Christodoulakis
Just another thought I had this morning.

Usually the framework is rather transparent to the struts user who
only creates actions with their corresponding results and run the
application on a server. I mean if the user doesn't have to customize
anything, create an interceptor, or even bother with session objects,
they might not encounter Proxy, Action Invocation, or Invocation
Context at all in their own code.

But, of course, those objects are part of the framework, and they must
be instantiated and initialized without such user even knowing about
it. Which means that initialization happens within the framework
itself, and not in the user's code necessarily, right?

So putting a breakpoint in the constructor of my
intercept(ActionInvocation actionInvocation) method, possibly won't
show me much, right? I have yet to try it, but this was just a
thought.

On Wed, Jul 22, 2009 at 8:59 PM, Musachy Barrosomusa...@gmail.com wrote:
 an easier way, is to install the maven plugin for eclipse, and then
 checkout the struts 2 code, and import apps/blank/pom.xml as a maven
 project. Then you can run and debug it from eclipse without having to
 download any code.

 musachy

 On Wed, Jul 22, 2009 at 6:23 PM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Thanks Dave and Martin. I learn something new every time!

 I was able to attach the source to struts2-core-2.1.6.jar and
 xwork-2.1.2.jar by first downloading the source code and pointing to
 the it from within eclipse.

 project-right click-properties-Java build path-Libraries-select
 jar-Source Attachment-edit

 I will try the breakpoint next. I hope eclipse can trace a breakpoint
 all the way to at least classes within those jars. Attaching code to
 each and every jar in the project sounds a bit tedious. I mean I
 manually downloaded the source and attached it. So for all other jars,
 spring, hibernate, commons, etc -- should take a long time. Unless it
 could be done automatically by eclipse, but I am not sure. Probably
 not

 On Wed, Jul 22, 2009 at 8:11 PM, Martin Gaintymgai...@hotmail.com wrote:

 unless someone redesigned Eclipse breakpoint wont be able to see a class 
 packaged in the jar *at least with ganymede*
 stick with debug algorithm's mentioned earlier
 (main focus would be to debug action initialisation as dave mentioned)
 ...
 Martin
 __
 Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 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.




 Date: Wed, 22 Jul 2009 19:49:23 -0500
 Subject: Re: studying struts2 framework, ActionInvocation question
 From: dimi@gmail.com
 To: user@struts.apache.org

 Dave Newton wrote:
 
  Won't help track action invocation initialization, methinks.
 

 Is there a particular way you would recommend to go about doing it
 actually? I am using eclipse for my ide, but I am not sure if
 breakpoints can trace through the compiled classes in the jars.

 Much appreciate the advice.

 On Wed, Jul 22, 2009 at 7:44 PM, Dave Newtonnewton.d...@yahoo.com wrote:
  Martin Gainty wrote:
 
  does vi have breakpoints.. am i missing something?
 
  
 
  In this case you actually saw something nobody else did--a vi reference.
 
  or debug
  before craig and ted left (i wished they both stayed but thats another
  topic)
  a DebuggingInterceptor was coded and is activated by
  struts.devMode = true
  http://struts.apache.org/2.0.14/docs/debugging.html
 
  then address would contain ?debug=parameter in url should specifies
  either
  ?debug=xml or ?debug=console to the URL.
 
  Won't help track action invocation initialization, methinks.
 
  Dave
 
  -
  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: studying struts2 framework, ActionInvocation question

2009-07-23 Thread Dimitrios Christodoulakis
Actually I was speaking of my own custom interceptor (Authentiaction
interceptor) which I add on top of the default package.

Originally, I wanted to unit test my interceptor class and
particularly its intercept method which takes an ActionInvocation as a
parameter. My concern was how to create and instantiate a mock
ActionInvocation implementation and bind a dummy action to it.

This is leading me through the struts2 and xwork source code, which I
am thinking of running using breakpoints to see how the
ActionInvocation is intantiated. And at least follow the basic
workflow of the framework when it is trying to execute an action.

By the way I noticed that when I downloaded the s2 source code, it
didn't come with the opensymphony packages... Does the xwork source
has to be downloaded separately?

On Thu, Jul 23, 2009 at 11:11 AM, Martin Gaintymgai...@hotmail.com wrote:

 you're speaking of org.apache.struts2.s1.ActionFormValidationInterceptor?
 which is an Interceptor class contained within Struts2-Struts1-plugin

 an excellent step by step tutorial on Struts2-Struts1-plugin is available at
 http://www.slideshare.net/mraible/migrating-from-struts-1-to-struts-2-presentation

 Maven is a build environment which outputs distros based on version specific 
 plugins
 although l/t you'll want to use it for development it can be a bit daunting 
 to setup properly
 HINT: I use localRepository always to avoid disconnect probs with main maven 
 plugin remoteRepositories

 fairly intuitive tutorial is located at
 http://maven.apache.org/guides/getting-started/index.html

 hth
 Martin Gainty
 __
 Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 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.




 Date: Thu, 23 Jul 2009 07:51:37 -0500
 Subject: Re: studying struts2 framework, ActionInvocation question
 From: dimi@gmail.com
 To: user@struts.apache.org

 Just another thought I had this morning.

 Usually the framework is rather transparent to the struts user who
 only creates actions with their corresponding results and run the
 application on a server. I mean if the user doesn't have to customize
 anything, create an interceptor, or even bother with session objects,
 they might not encounter Proxy, Action Invocation, or Invocation
 Context at all in their own code.

 But, of course, those objects are part of the framework, and they must
 be instantiated and initialized without such user even knowing about
 it. Which means that initialization happens within the framework
 itself, and not in the user's code necessarily, right?

 So putting a breakpoint in the constructor of my
 intercept(ActionInvocation actionInvocation) method, possibly won't
 show me much, right? I have yet to try it, but this was just a
 thought.

 On Wed, Jul 22, 2009 at 8:59 PM, Musachy Barrosomusa...@gmail.com wrote:
  an easier way, is to install the maven plugin for eclipse, and then
  checkout the struts 2 code, and import apps/blank/pom.xml as a maven
  project. Then you can run and debug it from eclipse without having to
  download any code.
 
  musachy
 
  On Wed, Jul 22, 2009 at 6:23 PM, Dimitrios
  Christodoulakisdimi@gmail.com wrote:
  Thanks Dave and Martin. I learn something new every time!
 
  I was able to attach the source to struts2-core-2.1.6.jar and
  xwork-2.1.2.jar by first downloading the source code and pointing to
  the it from within eclipse.
 
  project-right click-properties-Java build path-Libraries-select
  jar-Source Attachment-edit
 
  I will try the breakpoint next. I hope eclipse can trace a breakpoint
  all the way to at least classes within those jars. Attaching code to
  each and every jar in the project sounds a bit tedious. I mean I
  manually downloaded the source and attached it. So for all other jars,
  spring, hibernate, commons, etc -- should take a long time. Unless it
  could be done automatically by eclipse, but I am not sure. Probably
  not
 
  On Wed, Jul 22, 2009 at 8:11 PM, Martin Gaintymgai...@hotmail.com wrote:
 
  unless someone redesigned Eclipse 

studying struts2 framework, ActionInvocation question

2009-07-22 Thread Dimitrios Christodoulakis
Hello,

According to the XWork feature description,
http://www.opensymphony.com/xwork/wikidocs/XWork%20Features.html, the
ActionInvocation represents the execution state of an action holding
the action instance and the interceptors.

I have been looking at
http://struts.apache.org/2.1.6/struts2-core/apidocs and examining an
implementation of the ActionInvocation interface:
DefaultActionInvocation and was wondering how does this class gets a
hold of the action instance and the interceptors? It has relevant
fields like action, interceptors and proxy with getters for the action
and the proxy. But it is not straightforward to me how the action
instance (and the interceptors) are injected to it.. I didn't see
setter methods for the action.

My motivation for this question comes also from wanting to unit test
an interceptor's intercept(ActionInvocation actionInvocation) method.
I will need to pass an ActionInvocation as a parameter, which then the
interceptor will use to extract the actual action instance from.
(Among other things, like the InvocationContext to get the session).

So I was also wondering how to provide a mock-type of an
ActionInvocation which will contain a mock action, a mock session etc.
I mean I understand how to create a mock action and a mock session map
with some parameters in it, but how do I bind those to a mock
ActionInvocation? Would I need perhaps to start with a mock
ActionProxy?

Thanks for your advice. This will help me design the test case and
also learn more about the struts2 mechanics.
Regards!

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



Re: studying struts2 framework, ActionInvocation question

2009-07-22 Thread Dimitrios Christodoulakis
Yes, I figured doing a trace and see how things happen would answer a
lot of questions. So, I'll try that.

From looking at the DefaultActionProxy constructor, it does make sense
to start with the actionproxy. The proxy gets an action invocation as
a constructor parameter. So the invocation instantiation should be
coming shortly after that.

On Wed, Jul 22, 2009 at 4:17 PM, Musachy Barrosomusa...@gmail.com wrote:
 The best way to find out all these things is to put breakpoints in the
 constructor and/or the setter methods.

 musachy

 On Wed, Jul 22, 2009 at 2:05 PM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Hello,

 According to the XWork feature description,
 http://www.opensymphony.com/xwork/wikidocs/XWork%20Features.html, the
 ActionInvocation represents the execution state of an action holding
 the action instance and the interceptors.

 I have been looking at
 http://struts.apache.org/2.1.6/struts2-core/apidocs and examining an
 implementation of the ActionInvocation interface:
 DefaultActionInvocation and was wondering how does this class gets a
 hold of the action instance and the interceptors? It has relevant
 fields like action, interceptors and proxy with getters for the action
 and the proxy. But it is not straightforward to me how the action
 instance (and the interceptors) are injected to it.. I didn't see
 setter methods for the action.

 My motivation for this question comes also from wanting to unit test
 an interceptor's intercept(ActionInvocation actionInvocation) method.
 I will need to pass an ActionInvocation as a parameter, which then the
 interceptor will use to extract the actual action instance from.
 (Among other things, like the InvocationContext to get the session).

 So I was also wondering how to provide a mock-type of an
 ActionInvocation which will contain a mock action, a mock session etc.
 I mean I understand how to create a mock action and a mock session map
 with some parameters in it, but how do I bind those to a mock
 ActionInvocation? Would I need perhaps to start with a mock
 ActionProxy?

 Thanks for your advice. This will help me design the test case and
 also learn more about the struts2 mechanics.
 Regards!

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





 --
 Hey you! Would you help me to carry the stone? Pink Floyd

 -
 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: studying struts2 framework, ActionInvocation question

2009-07-22 Thread Dimitrios Christodoulakis
Dave Newton wrote:

 Won't help track action invocation initialization, methinks.


Is there a particular way you would recommend to go about doing it
actually? I am using eclipse for my ide, but I am not sure if
breakpoints can trace through the compiled classes in the jars.

Much appreciate the advice.

On Wed, Jul 22, 2009 at 7:44 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Martin Gainty wrote:

 does vi have breakpoints.. am i missing something?

 

 In this case you actually saw something nobody else did--a vi reference.

 or debug
 before craig and ted left (i wished they both stayed but thats another
 topic)
 a DebuggingInterceptor was coded and is activated by
 struts.devMode = true
 http://struts.apache.org/2.0.14/docs/debugging.html

 then address would contain ?debug=parameter in url should specifies
 either
 ?debug=xml or ?debug=console to the URL.

 Won't help track action invocation initialization, methinks.

 Dave

 -
 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: studying struts2 framework, ActionInvocation question

2009-07-22 Thread Dimitrios Christodoulakis
Thanks Dave and Martin. I learn something new every time!

I was able to attach the source to struts2-core-2.1.6.jar and
xwork-2.1.2.jar by first downloading the source code and pointing to
the it from within eclipse.

project-right click-properties-Java build path-Libraries-select
jar-Source Attachment-edit

I will try the breakpoint next. I hope eclipse can trace a breakpoint
all the way to at least classes within those jars. Attaching code to
each and every jar in the project sounds a bit tedious. I mean I
manually downloaded the source and attached it. So for all other jars,
spring, hibernate, commons, etc -- should take a long time. Unless it
could be done automatically by eclipse, but I am not sure. Probably
not

On Wed, Jul 22, 2009 at 8:11 PM, Martin Gaintymgai...@hotmail.com wrote:

 unless someone redesigned Eclipse breakpoint wont be able to see a class 
 packaged in the jar *at least with ganymede*
 stick with debug algorithm's mentioned earlier
 (main focus would be to debug action initialisation as dave mentioned)
 ...
 Martin
 __
 Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 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.




 Date: Wed, 22 Jul 2009 19:49:23 -0500
 Subject: Re: studying struts2 framework, ActionInvocation question
 From: dimi@gmail.com
 To: user@struts.apache.org

 Dave Newton wrote:
 
  Won't help track action invocation initialization, methinks.
 

 Is there a particular way you would recommend to go about doing it
 actually? I am using eclipse for my ide, but I am not sure if
 breakpoints can trace through the compiled classes in the jars.

 Much appreciate the advice.

 On Wed, Jul 22, 2009 at 7:44 PM, Dave Newtonnewton.d...@yahoo.com wrote:
  Martin Gainty wrote:
 
  does vi have breakpoints.. am i missing something?
 
  
 
  In this case you actually saw something nobody else did--a vi reference.
 
  or debug
  before craig and ted left (i wished they both stayed but thats another
  topic)
  a DebuggingInterceptor was coded and is activated by
  struts.devMode = true
  http://struts.apache.org/2.0.14/docs/debugging.html
 
  then address would contain ?debug=parameter in url should specifies
  either
  ?debug=xml or ?debug=console to the URL.
 
  Won't help track action invocation initialization, methinks.
 
  Dave
 
  -
  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


 _
 Windows Live™ Hotmail®: Celebrate the moment with your favorite sports pics. 
 Check it out.
 http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_photos_072009cat=sports

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



Re: unit testing Struts2 application (with Spring and Hibernate)

2009-07-21 Thread Dimitrios Christodoulakis
I have used this testing code to a certain extend, and seems to work
fine. So I am interested in making it work against a complete test
case scenario.

So, when trying to load a child entity after the parent is retrieved,
I get a LazyInitializationException Error. Sure enough, when the
system tries to load the dependent collection, it doesn't find a
session or thinks the session was closed.

During development this is solved by the
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
filter declared in the web.xml file.

So, I tried adding that file in the BaseStrutsTestCase in the
CONFIG_LOCATIONS String:
private static final String CONFIG_LOCATIONS =
/WEB-INF/applicationContext.xml, + .../WEB-INF/web.xml;

This time the error is:
ERROR ContextLoader:215 - Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate Spring NamespaceHandler for
XML schema namespace [http://java.sun.com/xml/ns/j2ee]
Offending resource: URL [file:/C:/./WebContent/WEB-INF/web.xml]

The CONFIG_LOCATIONS is used to initialize the servletContext which in
turn is used to initialize the applicationContext, right? So, I am not
sure where is the correct place to add the web.xml file, or how to
tell BaseStrutsTestCase to include OpenEntityManagerInViewFilter
during the recreation of the framework.

Is that a limitation of this test class, or I am trying to include my
web.xml file the wrong way?

I am not sure if other folks using this example code dealt with
something like this in the past and solved it. Haroon, I hope you
don't mind my asking you again about this :)

Also, a more general question: Can the proxy class be used to create
and run two actions sequentially? Let's say I want to test an action
in my secure namespace, meaning that some sort of login or
registration action comes first.
So, could I do something like this in my test method?:

@Test
public void testExecute() throws Exception{
Login testLogin = createAction(Login.class, /, Login);
//set my fields
testLogin.setPassword(...);
//execute proxy once
proxy.execute();
//Then create my secure action
UpdateProfile testUpdateProfile =
createAction(UpdateProfile.class, /secure, 
UpdateProfile);
//and then execute proxy again
proxy.execute();
}

This doesn't seem to work when I tried it. Could that be a violation
of the ActionProxy rules? Before digging any deeper I just thought to
ask this, in case there is another way to link and execute several
sequential actions within the same test?

Up until now I manually created mock objects to satisfy any
dependencies of the class under test: Created a user object and put in
on a Session map manually to simulate a successful login action. So
the motive here was to use this example test code to actually create
and execute a successful test of the predecessor action (so the login
action itself could add the logged in user to the session) before the
actual action that I am primarily testing (updateProfile).

Anyway, I sure hope I am not stretching this conversation too far by
experimenting a bit further with this example. Any suggestions are
appreciated.

Regards.


On Mon, Jul 20, 2009 at 5:02 PM, Haroon
Rafiqueharoon.rafi...@utoronto.ca wrote:
 On Today at 4:32pm, DC=Dimitrios Christodoulakis dimi@gmail.com wrote:

 DC Thanks Haroon for the handy advice. That seems to do the trick as far
 DC as the session object is concerned. The test passes now.
 DC

 Glad it worked out.

 DC
 DC Would it be easy for someone to extend your code to include actions
 DC that implement the -aware interfaces? If I wanted to take a shot at
 DC that, is there a particular point you would suggest I start with?
 DC

 Did you add that code in your Test class? I was actually suggesting that
 you modify the code inside BaseStrutsTestCase. So, I would recommend
 adding a private static HashMap variable called sessionMap in
 BaseStrutsTestCase. And then in the createAction method, issue the
 statement:
    proxy.getInvocation().getInvocationContext().setSession(sessionMap);

 Hope that helps.

 The only other fringe case that I have dealth with in our code, is when we
 have actions that implement Preparable and are used with a
 ParamsPrepareParams interceptor. I created a method to allow action
 parameters to be set.

 /**
  * Sets the action parameters
  * @param parameters Parameters to set
  */
 protected void setActionParameters(MapString, String
 parameters) {
   proxy.getInvocation().getInvocationContext().
           setParameters(parameters);
 }

 Then inside my Action Test class, I can issue:
  proxy.setActionParameters(...);
 before:
  proxy.execute();

 Cheers,
 --
 Haroon Rafique
 haroon.rafi...@utoronto.ca


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

Re: unit testing Struts2 application (with Spring and Hibernate)

2009-07-21 Thread Dimitrios Christodoulakis

 In your code below, where you say // and then execute proxy again, are you
 missing some stepls where you need to supply some parameters to the
 action?

Yes, that wasn't actual code, just the steps I was considering.

-In any case it's good to know the limitations of the example. You are
right, sometimes I need to test a broader unit of work, which can
include a couple of actions, rather than just one. So, in that sense,
I could be stepping into the functional testing area.

I appreciate all the helpful information. I've already learned a lot,
by the example code, and the discussions on this thread!


On Tue, Jul 21, 2009 at 3:31 PM, Haroon
Rafiqueharoon.rafi...@utoronto.ca wrote:
 On Today at 2:02pm, DC=Dimitrios Christodoulakis dimi@gmail.com wrote:

 DC [..snip..]
 DC
 DC The CONFIG_LOCATIONS is used to initialize the servletContext which in
 DC turn is used to initialize the applicationContext, right? So, I am not
 DC sure where is the correct place to add the web.xml file, or how to
 DC tell BaseStrutsTestCase to include OpenEntityManagerInViewFilter
 DC during the recreation of the framework.
 DC

 The CONFIG_LOCATIONS variable is used to initialize spring only. I don't
 use spring-orm, so I can't comment on how to tell BaseStrutsTestCase to
 include that particular filter (or any other filter for that matter).

 DC
 DC Is that a limitation of this test class, or I am trying to include my
 DC web.xml file the wrong way?
 DC

 Most probably a limitation.

 DC
 DC I am not sure if other folks using this example code dealt with
 DC something like this in the past and solved it. Haroon, I hope you
 DC don't mind my asking you again about this :)
 DC
 DC Also, a more general question: Can the proxy class be used to create
 DC and run two actions sequentially? Let's say I want to test an action
 DC in my secure namespace, meaning that some sort of login or
 DC registration action comes first.
 DC

 I think you're over-stepping the bounds of unit testing here. In any case,
 I have created multiple invocations of the same action in the same test
 method without any problems. E.g.,

 createAction(SomeAction.class, /namespace, actionName);
 //... set some parameters
 assertEquals(SUCCESS, proxy.execute());
 //create action again
 createAction(SomeAction.class, /namespace, actionName);
 //... set some *different* parameters so that we expect INPUT to be
 // returned
 assertEquals(INPUT, proxy.execute());

 There's nothing to prevent you from recreating another Action all
 together. You just have to remember that every time you execute
 createAction, it creates a new mock request and mock response, so you have
 to populate things properly.


 DC
 DC So, could I do something like this in my test method?:
 DC

 In your code below, where you say // and then execute proxy again, are you
 missing some stepls where you need to supply some parameters to the
 action?

 DC
 DC @Test
 DC public void testExecute() throws Exception{
 DC Login testLogin = createAction(Login.class, /, Login);
 DC //set my fields
 DC testLogin.setPassword(...);
 DC //execute proxy once
 DC proxy.execute();
 DC //Then create my secure action
 DC UpdateProfile testUpdateProfile =
 DC                     createAction(UpdateProfile.class, /secure, 
 UpdateProfile);
 DC //and then execute proxy again
 DC proxy.execute();
 DC }
 DC
 DC [..snip..]
 DC
 DC Up until now I manually created mock objects to satisfy any
 DC dependencies of the class under test: Created a user object and put in
 DC on a Session map manually to simulate a successful login action. So
 DC the motive here was to use this example test code to actually create
 DC and execute a successful test of the predecessor action (so the login
 DC action itself could add the logged in user to the session) before the
 DC actual action that I am primarily testing (updateProfile).
 DC

 Smells like functional testing to me.

 DC
 DC Anyway, I sure hope I am not stretching this conversation too far by
 DC experimenting a bit further with this example. Any suggestions are
 DC appreciated.
 DC
 DC Regards.

 Cheers,
 --
 Haroon Rafique
 haroon.rafi...@utoronto.ca


 -
 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 testing Struts2 application (with Spring and Hibernate)

2009-07-20 Thread Dimitrios Christodoulakis
Thanks Haroon for the handy advice. That seems to do the trick as far
as the session object is concerned. The test passes now. Would it be
easy for someone to extend your code to include actions that implement
the -aware interfaces? If I wanted to take a shot at that, is there a
particular point you would suggest I start with?

Also, many thanks to Wes, for pointing out a good starting point for
understanding Struts2 at a deeper level by examining the code!

Regards to all.

On Mon, Jul 20, 2009 at 9:26 AM, Haroon
Rafiqueharoon.rafi...@utoronto.ca wrote:
 On Yesterday at 9:16pm, DC=Dimitrios Christodoulakis dimi@gmail.com...:

 DC [..snip..]
 DC
 DC When testing (junit 4) an action implementing the Sessionaware
 DC interface (my login and register classes) I noticed that the session
 DC object is set to null by BaseStrutsTestCase. This was mentioned before
 DC in the author's blog, but not sure if ever addressed. I added a new
 DC comment over there but the discussion could be inactive.
 DC

 Hi Dimitrios,

 Don't think arsenalist is watching that blog dilligently any more.

 DC
 DC I was wondering if anyone who is using the BaseStrutsTestCase, or used
 DC it in the past, came across this issue and if by any chance managed to
 DC resolve it. Perhaps Haroon might have a comment on this?
 DC

 Not a whole lot at the moment as none of our Action classes implement
 those interfaces. How about something like:

 protected static HashMap sessionMap = new HashMap();

 // and further on later in the code

 proxy.getInvocation().getInvocationContext().setSession(sessionMap);


 DC
 DC Also, a couple of more general questions:
 DC
 DC 1) Is there a recommended way to check during testing which
 DC    interceptors are firing and when?
 DC

 Careful there. Haven't you now delved into the territory of testing the
 framework itself (rather than your own code)? IMHO, I would assume that
 it's the framework's responsibility to make sure that when a certain set
 of interceptors is configured, they better fire properly.

 DC
 DC [..snip..]
 DC
 DC Kind regards and I appreciate all the input.
 DC

 Cheers,
 --
 Haroon Rafique
 haroon.rafi...@utoronto.ca

 -
 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 testing Struts2 application (with Spring and Hibernate)

2009-07-20 Thread Dimitrios Christodoulakis
Thanks for clarifying Haroon,

Actually the additions you are mentioning sum up the original testing
code pretty well. Like I said,  from an educational point of view, I
think one can learn a lot about the framework itself by studying that
article and the comments. Thanks for the preparable bit too.

As other folks here mentioned, it depends on the testing requirements
of the project when it comes which test strategy to take, or which
tool to use. As a learner, I found it very useful to experiment with
that code.

I haven't tried Selenium yet, but I would be interested to see how it
catches the same errors in the same test cases.

On Mon, Jul 20, 2009 at 5:02 PM, Haroon
Rafiqueharoon.rafi...@utoronto.ca wrote:
 On Today at 4:32pm, DC=Dimitrios Christodoulakis dimi@gmail.com wrote:

 DC Thanks Haroon for the handy advice. That seems to do the trick as far
 DC as the session object is concerned. The test passes now.
 DC

 Glad it worked out.

 DC
 DC Would it be easy for someone to extend your code to include actions
 DC that implement the -aware interfaces? If I wanted to take a shot at
 DC that, is there a particular point you would suggest I start with?
 DC

 Did you add that code in your Test class? I was actually suggesting that
 you modify the code inside BaseStrutsTestCase. So, I would recommend
 adding a private static HashMap variable called sessionMap in
 BaseStrutsTestCase. And then in the createAction method, issue the
 statement:
    proxy.getInvocation().getInvocationContext().setSession(sessionMap);

 Hope that helps.

 The only other fringe case that I have dealth with in our code, is when we
 have actions that implement Preparable and are used with a
 ParamsPrepareParams interceptor. I created a method to allow action
 parameters to be set.

 /**
  * Sets the action parameters
  * @param parameters Parameters to set
  */
 protected void setActionParameters(MapString, String
 parameters) {
   proxy.getInvocation().getInvocationContext().
           setParameters(parameters);
 }

 Then inside my Action Test class, I can issue:
  proxy.setActionParameters(...);
 before:
  proxy.execute();

 Cheers,
 --
 Haroon Rafique
 haroon.rafi...@utoronto.ca


 -
 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 testing Struts2 application (with Spring and Hibernate)

2009-07-20 Thread Dimitrios Christodoulakis
The full article is here:
http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/

I think the author's explanations cover a lot. The comments and the
subsequent conversations are of value too.

On Mon, Jul 20, 2009 at 7:33 PM, Martin Gaintymgai...@hotmail.com wrote:

 can you show the code to obtain proxy?
 could you post the URL for article?



 Merci
 Martin Gainty
 __
 Note de déni et de confidentialité
 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.





 Date: Mon, 20 Jul 2009 19:07:09 -0500
 Subject: Re: unit testing Struts2 application (with Spring and Hibernate)
 From: dimi@gmail.com
 To: user@struts.apache.org

 Thanks for clarifying Haroon,

 Actually the additions you are mentioning sum up the original testing
 code pretty well. Like I said, from an educational point of view, I
 think one can learn a lot about the framework itself by studying that
 article and the comments. Thanks for the preparable bit too.

 As other folks here mentioned, it depends on the testing requirements
 of the project when it comes which test strategy to take, or which
 tool to use. As a learner, I found it very useful to experiment with
 that code.

 I haven't tried Selenium yet, but I would be interested to see how it
 catches the same errors in the same test cases.

 On Mon, Jul 20, 2009 at 5:02 PM, Haroon
 Rafiqueharoon.rafi...@utoronto.ca wrote:
  On Today at 4:32pm, DC=Dimitrios Christodoulakis dimi@gmail.com 
  wrote:
 
  DC Thanks Haroon for the handy advice. That seems to do the trick as far
  DC as the session object is concerned. The test passes now.
  DC
 
  Glad it worked out.
 
  DC
  DC Would it be easy for someone to extend your code to include actions
  DC that implement the -aware interfaces? If I wanted to take a shot at
  DC that, is there a particular point you would suggest I start with?
  DC
 
  Did you add that code in your Test class? I was actually suggesting that
  you modify the code inside BaseStrutsTestCase. So, I would recommend
  adding a private static HashMap variable called sessionMap in
  BaseStrutsTestCase. And then in the createAction method, issue the
  statement:
     proxy.getInvocation().getInvocationContext().setSession(sessionMap);
 
  Hope that helps.
 
  The only other fringe case that I have dealth with in our code, is when we
  have actions that implement Preparable and are used with a
  ParamsPrepareParams interceptor. I created a method to allow action
  parameters to be set.
 
  /**
   * Sets the action parameters
   * @param parameters Parameters to set
   */
  protected void setActionParameters(MapString, String
  parameters) {
    proxy.getInvocation().getInvocationContext().
            setParameters(parameters);
  }
 
  Then inside my Action Test class, I can issue:
   proxy.setActionParameters(...);
  before:
   proxy.execute();
 
  Cheers,
  --
  Haroon Rafique
  haroon.rafi...@utoronto.ca
 
 
  -
  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


 _
 Windows Live™ Hotmail®: Celebrate the moment with your favorite sports pics. 
 Check it out.
 http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_photos_072009cat=sports

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



Re: unit testing Struts2 application (with Spring and Hibernate)

2009-07-19 Thread Dimitrios Christodoulakis
Primarily for the sake of learning the inner mechanics of the struts2
framework, and unit testing, I took some time to study and experiment
with the code published at:
http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/

When testing (junit 4) an action implementing the Sessionaware
interface (my login and register classes) I noticed that the session
object is set to null by BaseStrutsTestCase. This was mentioned before
in the author's blog, but not sure if ever addressed. I added a new
comment over there but the discussion could be inactive.

I was wondering if anyone who is using the BaseStrutsTestCase, or used
it in the past, came across this issue and if by any chance managed to
resolve it. Perhaps Haroon might have a comment on this?

Also, a couple of more general questions:

1) Is there a recommended way to check during testing which
interceptors are firing and when?

2) If one with general knowledge of servlets  jsp wants to dive into
the struts2 source code, to get better understanding of the basic
mechanics, what would be the starting point? So should I start lets
say with the struts.core package?, which would be the entry point
class Despatcher, then ActionProxy? -- To the untrained eye (myself),
when looking the code from a distance
(http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/), it
looks somewhat like a ball of twine, so where should I look for the
piece of string that sticks out and will help me untangle it?

Well, the primary objective is testing our struts2 application, so I
will probably try other approaches mentioned in this discussion. So, I
would like to take a deeper look at Selenium next.

Kind regards and I appreciate all the input.


On Sun, Jul 19, 2009 at 4:35 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Paweł Wielgus wrote:

 Hi Dave,
 when i record my tests with selenium ide,
 all click or assert alements takes various loactor addresses,
 very often they contain DOM paths,
 so when layout is changed from tables to divs,
 all these addresses are no longer valid.

 On the rare occasions I use the IDE to generate the script I find I always
 modify it pretty heavily--since I am pretty good about marking up my HTML
 it's almost easier to just write the tests by hand so I can target only the
 most-specific elements I'm looking for.

 I'm rarely bitten by layout changes since the important stuff doesn't change
 much regardless of its surroundings.

 YMMV :)

 Dave

 -
 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 testing Struts2 application (with Spring and Hibernate)

2009-07-17 Thread Dimitrios Christodoulakis
Of course you're right Greg, it's not a contest... no right or wrong
here. I am glad to hear all the views coming from everyone and
commiters too.

Well, my original motivation was to learn how to do this kind of
tip-to-tail, all inclusive testing, with the interceptor stack
involved.

For example if I want to unit test an action within a secure package,
that action requires the authentication interceptor to execute first,
so, to do my testing I thought that the full fledged testing was
necessary, to include my required interceptors. But from what I have
been researching and hearing in this conversation, I believe there is
a way to provide a mock object acting like my authentication
interceptor and thus not need to include the interceptor stack.

Also, I am not sure about testing a class which implements other
struts interfaces like preparable, sessionaware, etc. Would that make
a special case?

Just a quick question to Wes: In your upcoming book, which is in the
MEAP phase, there is an appendix titled Unit testing with JUnit and
TestNG . Is there any plan to include some examples describing the
different kinds of unit testing that can be done? I am looking forward
to taking a look at it.

On Fri, Jul 17, 2009 at 1:00 PM, Greg Lindholmgreg.lindh...@gmail.com wrote:

  
   IMO that's outside the purview of unit testing, though--by definition
   this describes integration testing: the testing of an action along with
   the framework.
  
   There's nothing *wrong* with doing that testing, I just don't think
 it's
   the same thing as unit testing: independently testing the smallest bits
   of functionality.
  
   JUnit can be used for that kind of testing too (and I do, sometimes),
   but once I'm at that point I generally figure I might as well just be
   doing client-focused testing and testing the output of my results. I
   also use Selenium, although I may switch back to using a layer I wrote
   on top of Watir.
  
   Dave
  
 
  Not to throw weight around, but it is sort of curious to me that the
 three
  struts committers who chimed in all agreed that tip-to-tail integration
  testing in JUnit is not worth the effort. I only bring it up because,
 IMO,
  struts 2 is one of the best-unit-tested products I've ever worked on. I
 think
  Dave, Musachy and myself are biased against tip-to-tail in JUnit because
 in
  Struts 2, we have a guideline to unit test all bugfixes and new
 functionality.
  That being so, all three of us have probably come across situations where
  writing the unit test is 500x harder than writing the fix :)
 
  Dave does a good job of making the point I tried to make earlier,
 tip-to-tail
  testing is better looked at as an integration test and it becomes much
 easier
  to deal with as an integration test. If you are unfamiliar with selenium,
 it
  is worth learning. One of the posters earlier mentioned that he didn't
 want to
  learn another testing framework when he already knows JUnit. Selenium is
 nice
  because it runs right in the browser (IE and Firefox) and runs though a
 set of
  VB-like instructions... Things like - open this url, look for this text,
 click
  this link and then make sure this text exists. IMO, if you want to make
 sure
  that your action renders the appropriate result, this is way better than
  trying to coax the framework by bootstrapping it with mocks then figuring
 out a
  way to retrieve the rendered result. As an added bonus, it is possible to
 get
  maven to launch selenium tests, so you can get full unit and integration
  testing out of your CI if you are willing to put forth the effort.
 
  To drive the point home further, I would add that the Dojo plugin
 probably
  would have been more stable if we had taken the selenium approach (that
 is
  being employed with the slowly moving jquery plugin).
 
  -Wes
 


 Not to pick on anyone but this isn't really a popularity contest. Different
 situations have different needs and there is no reason to suggest that one
 solution will work best for everyone.

 At a large shop naming something unit testing vs integration testing
 maybe important as it can determined who's job it is to do the work.  But at
 a small shop, like I'm at, it makes no difference, it's all just testing and
 it's the developers job.  So for me, whatever way is easiest, quickest and
 gets the job done wins.

 It took some work at first to figure out how to tests actions with the full
 stack with junit but now that I have the plumbing figured out it's very easy
 to add tests as actions are added. With junit I can easily set the database
 to a know state before each test, or use mocks to simulate hard to setup
 edge conditions (how easy is that to do with selenium?)  Plus it's easy to
 jun junit with code coverage so I can see code isn't being covered. And, as
 another already pointed out, junit is fast and convienent, 2 clicks from
 inside Eclipse.

 I do think it is great to see that the industry (at least those on this
 list) recognizes 

unit testing Struts2 application (with Spring and Hibernate)

2009-07-16 Thread Dimitrios Christodoulakis
Hello,

I was hoping to hear the community's views about unit testing a
Struts2 application which is integrated with Spring and Hibernate. My
plan is to unit test the actions with the framework's interceptors
running, rather than each action class in a stand-alone isolated
fashion.

What approach do you usually follow? A highly regarded article:
http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
provides some useful hints and starting points.

I would like to use Junit 4 with Ant for this. Are there any other
resources, or documented steps to take as far as you know, or
recommend?

I found quite a few bits and pieces searching online, but would
appreciate any general guidance or advice on how to begin with this.

Many thanks and regards.

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



Re: unit testing Struts2 application (with Spring and Hibernate)

2009-07-16 Thread Dimitrios Christodoulakis
Thanks everyone for their opinions. I was indeed hoping to hear both
sides of this matter, with both bringing valid arguments and make good
points.

I was wondering with popular frameworks like struts, spring and
hibernate integrated together and the increasing adoption of test
driven, and agile development, there should be at least a couple of
comprehensive, and well documented strategies on how to perform such
kind of unit testing with the whole working stack included in the unit
tests.

I am somewhat curious in trying to do this and making it work, so if
anyone is aware of any other resources, or strategies in addition to
Greg's article, where Spring is involved, I'd be very interested in
taking a look at them.

Or, if someone has done such Struts testing before and wouldn't mind
sharing some high-level advice, or hints toward a good starting point,
that would be very helpful and I am sure others can find this
information of value too.

Again, thank you for your input.





On Thu, Jul 16, 2009 at 12:19 PM, Greg Lindholmgreg.lindh...@gmail.com wrote:
 Well everyone has an opinion so here mine:

 I want to unit test my Struts actions in the full Struts context which
 includes  the interceptor stack and validation. This way I know my actions
 and results are configured correctly since I test them. I also know my
 declarative validations are working correctly. I use junit and I really
 don't want or have time to have to learn another test tool for integration
 testing.

 So to do this type of testing I wrote a StrutsTestContext class to run my
 actions.
 For full info see:
 http://glindholm.wordpress.com/2008/06/30/unit-testing-struts-2-actions/

 I don't use Spring so this class would need to be tweaked for Spring but you
 are welcome to use this as a starting point.

 This gives me a lot of flexibility for testing, sometimes I test against an
 actual database (with hibernate) and sometimes I mock the services that the
 actions use.



 On Thu, Jul 16, 2009 at 10:43 AM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 Hello,

 I was hoping to hear the community's views about unit testing a
 Struts2 application which is integrated with Spring and Hibernate. My
 plan is to unit test the actions with the framework's interceptors
 running, rather than each action class in a stand-alone isolated
 fashion.

 What approach do you usually follow? A highly regarded article:

 http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
 provides some useful hints and starting points.

 I would like to use Junit 4 with Ant for this. Are there any other
 resources, or documented steps to take as far as you know, or
 recommend?

 I found quite a few bits and pieces searching online, but would
 appreciate any general guidance or advice on how to begin with this.

 Many thanks and regards.

 -
 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: problem with deleting objects from a collection

2009-07-13 Thread Dimitrios Christodoulakis
I think I might have an idea why the iterator or display tag do not
allow for working with collection items.

In the past I used form tags (like select) to prompt the user to make
a selection from a menu, my thought is that since I was using form
tags, by submitting the form, the property (item from the collection)
is passed to the valuestack and the action can work with it.

But an iterator or a display tag do not necessarily put properties on
the valuestack. Is this correct? I was wondering if I could use a set,
or push tag to either store the property to the scope or put it on the
top of the valuestack that way? Would you say this is a valid
strategy?

This has been troubling me for a few days, so I hope it is alright to
post my new thought on this. Thank you for any new input.

On Sun, Jul 12, 2009 at 5:16 PM, Dimitrios
Christodoulakisdimi@gmail.com wrote:
 Thanks Dave,

 Yes, the s:property.../ isn't supposed to be there  Thanks for
 pointing this out. Indeed, it has to be an object there, in order to
 do the remove from the collection. Since this value-type component
 (entry) does not have a primary key to look it up from, I am a bit at
 a loss how to continue from here.

 If you don't mind, could you explain a little bit further? I have
 successfully removed entity object from collections before because all
 I neede was the primary key to be passed to the delete action. Then
 inside the action I did the look up using the key and removed the
 object. But with this type of object I have hit a roadblock.

 I appreciate any further help.


 This is the class:

 @Embeddable
 public class JournalEntry {

       �...@org.hibernate.annotations.parent
        private GoalToAchieve goalToAchieve;

       �...@column(length = 255, nullable = false)
        private String entry;

       �...@temporal(TemporalType.TIMESTAMP)
       �...@column(nullable = false, updatable = false)
        private Date insertDate = new Date();


 plus the appropriate getters and setters..

 On Sun, Jul 12, 2009 at 5:03 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 I tried adding one more column like this, hoping the entry property
 will be available to the DeleteEntry action via the mini-form.

 display:column
 s:form action=DeleteEntry
    s:property value=entry/
    s:hidden name=id value=%{goalToAchieve.id} /
   s:submit value=Remove/
 /s:form
 /display:column

 What's that s:property.../ supposed to be doing?

 It's not a form field; there's no entry reference being passed back. Even if
 it *was* a form field it's still not passing a *reference* back--forms
 *only* submit strings. Always. If you want an actual *entry* object there
 either needs to be some type conversion, database retrieval, etc.

 Dave

 -
 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: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Thanks for the reply. Well, entry is an instance of a separate class:

@Embeddable
public class JournalEntry {
@org.hibernate.annotations.Parent
private GoalToAchieve goalToAchieve;
@Column(length = 255, nullable = false)
private String entry;

@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false, updatable = false)
private Date insertDate = new Date();

...plus the getters and setters

This being a value type embeddable component, it is represented with a
table with only a foreign key to the parent entity it belongs to:
goalToAchieve_id

So, if I pass the entry String as a parameter (I am not sure if it
would be convenient to have a a few sentences as url params), how can
I turn it into a reference to the object I want to actually remove
from the collection?

Thanks again

On Mon, Jul 13, 2009 at 8:17 AM, Greg Lindholmgreg.lindh...@gmail.com wrote:


 I have successfully used the display tag to iterate over a collection
 which is exposed in an action class. On each row in addition to the
 columns displaying the fields of each object in the collection, I
 embed two more struts-tag urls: Update and Remove.

 The objective is to have an extra two columns for every row in the
 table giving the ability to update or delete each record:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
        display:column property=entry /
        display:column property=date sortable=true
 defaultorder=ascending title=TimeStamp/
        display:columna href=s:url action='UpdateEntryForm'
                                s:param name=name
 value=%{goalToAchieve.owner.fullName} /
                        /s:url
                        Edit/a/display:column
        display:columna href=s:url action='DeleteEntryForm'
                                        s:param name=name
 value=%{goalToAchieve.owner.fullName} /
                                        s:property value=%{entry}/
                                       /s:url
                                       Remove/a/display:column
 /display:table

 I am having trouble passing the entry property, (or reference to it)
 to the url targeting the update or delete action. The entries
 collection consists of value type, embeddable objects. I am aware of
 how to pass parameters to the linking url, but my issue is passing a
 reference to the entry property of each row, to the update or delete
 action for the same row.


 You didn't say what 'entry' is, but if it is a String or some primitive you
 can just pass it as another parameter.

 s:url action='DeleteEntryForm'
          s:param name=name value=%{goalToAchieve.owner.fullName} /
           s:param name=entry value=%{entry} /
 /s:url

 Usually, every database entity object has an 'id' property (primary key) and
 you would just pass the id as a parameter so your action can find the object
 in the database.

 In you browser do a view source on the page to ensure the url is being
 generated correctly with the params you are expecting.


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



Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Yes, that is a great suggestion actually. What I did was to add a new
field based
System.currentTimeMillis(), but the problem is adding it as a url parameter.

For example, I am trying to add it as a url parameter below:

a href=s:url action='UpdateEntryForm'
s:param name=name value=%{goalToAchieve.owner.fullName} /
s:param name=mark value=%{mark} /
/s:url
 Edit/a

But, the only param passed is the fullName. The mark is not added to
the url string. I think this is because the only object available on
the valuestack is goalToAchieve, and using deeper notation I can
reference as deep as the entries collection. But not to fields of
each entry object. In other words, the display or iterator help me
view the collection objects, but not extract and use any of their
fields... I am not sure why this is happening, or if I am doing
something wrong.

On Mon, Jul 13, 2009 at 8:43 AM, Greg Lindholmgreg.lindh...@gmail.com wrote:

 Thanks for the reply. Well, entry is an instance of a separate class:

 @Embeddable
 public class JournalEntry {
 @org.hibernate.annotations.Parent
        private GoalToAchieve goalToAchieve;
 @Column(length = 255, nullable = false)
        private String entry;

       �...@temporal(TemporalType.TIMESTAMP)
       �...@column(nullable = false, updatable = false)
        private Date insertDate = new Date();

 ...plus the getters and setters

 This being a value type embeddable component, it is represented with a
 table with only a foreign key to the parent entity it belongs to:
 goalToAchieve_id

 So, if I pass the entry String as a parameter (I am not sure if it
 would be convenient to have a a few sentences as url params), how can
 I turn it into a reference to the object I want to actually remove
 from the collection?

 Thanks again

  You didn't say what 'entry' is, but if it is a String or some primitive
 you
  can just pass it as another parameter.
 
  s:url action='DeleteEntryForm'
           s:param name=name value=%{goalToAchieve.owner.fullName} /
            s:param name=entry value=%{entry} /
  /s:url
 
  Usually, every database entity object has an 'id' property (primary key)
 and
  you would just pass the id as a parameter so your action can find the
 object
  in the database.
 
  In you browser do a view source on the page to ensure the url is being
  generated correctly with the params you are expecting.
 


 You definitely do not want to pass 'entry' as a parameter on the url.
 Every database object needs some kind of unique key id just for situations
 like this.
 Maybe you could use the insertDate as a key (it's probably unique within
 this context) but it would be better to add a key, perhaps a sequence number
 so that goalToAchieve_id + seq is the PK.


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



Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Thanks for letting me know. Alright, so:

This is the parent class:

@Entity
public class GoalToAchieve {
@Id @GeneratedValue
private Long id;

@org.hibernate.annotations.CollectionOfElements
@JoinTable (name=GoalToAchieve_entry,
joincolum...@joincolumn(name=goalToAchieve_id))
private SetJournalEntry entries = new HashSetJournalEntry();

public SetJournalEntry getEntries() {
return entries;
}
public void setEntries(SortedSetJournalEntry entries) {
this.entries = entries;
}

public void addEntry(JournalEntry newEntry){
entries.add(newEntry);
}

public void deleteEntry(JournalEntry entry){
entries.remove(entry);
}
..plus some other standard fields with getters and setters

This is the child-class:

@Embeddable
public class JournalEntry {
@org.hibernate.annotations.Parent
private GoalToAchieve goalToAchieve;

@Column
private Long mark;
public Long getMark() {
return mark;
}
public void setMark(long mark){
this.mark = mark;
}

@Column(length = 255, nullable = false)
private String entry;

@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false, updatable = false)
private Date insertDate = new Date();

..plus the rest getters and setters

And this this the jsp part where I display the collection:

s:if test=goalToAchieve.entries.size  0
display:table name=goalToAchieve.entries requestURI= uid=thisGoal
display:column property=entry /
display:column property=date sortable=true
defaultorder=ascending title=TimeStamp/
display:column property=mark /
  display:column
a href=s:url action='UpdateEntryForm'
s:param name=name value=%{goalToAchieve.owner.fullName} /
s:param name=mark value=#mark /
/s:url
Edit/a
/display:column
display:column
a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
s:param name=name value=%{goalToAchieve.owner.fullName} /
s:param name=id value=%{goalToAchieve.id} /
s:param name=mark value=entry.mark /
s:property value=%{entry}/
/s:url
Remove/a
/display:column
/display:table
/s:if

..and the delete action, which should take an entry reference and
remove it from the collections looks like this:

public class DeleteEntry extends ActionSupport{
public String execute(){
goalToAchieve.deleteEntry(entry);

return SUCCESS;
}

private JournalEntry entry;
private GoalToAchieve goalToAchieve;
private long id;

... + getters and setters

I guess right now, my problem has become how to pass a parameter
referring to en entry (the mark field) to the delete action. Next, I
would do a lookup within the action to find the entry object and
remove it from the parent object collection, by calling
deleteEntry(JournalEntry entry)

On Mon, Jul 13, 2009 at 9:16 AM, Greg Lindholmgreg.lindh...@gmail.com wrote:
 You are not providing enough information for anyone to help you. Since you
 have changed your object and the jsp you had better include them with any
 request.


 On Mon, Jul 13, 2009 at 9:51 AM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 Yes, that is a great suggestion actually. What I did was to add a new
 field based
 System.currentTimeMillis(), but the problem is adding it as a url
 parameter.

 For example, I am trying to add it as a url parameter below:

 a href=s:url action='UpdateEntryForm'
 s:param name=name value=%{goalToAchieve.owner.fullName} /
 s:param name=mark value=%{mark} /
 /s:url
  Edit/a

 But, the only param passed is the fullName. The mark is not added to
 the url string. I think this is because the only object available on
 the valuestack is goalToAchieve, and using deeper notation I can
 reference as deep as the entries collection. But not to fields of
 each entry object. In other words, the display or iterator help me
 view the collection objects, but not extract and use any of their
 fields... I am not sure why this is happening, or if I am doing
 something wrong.



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



Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Thanks for the comments Martin, I will try it out!

On Mon, Jul 13, 2009 at 9:46 AM, Martin Gaintymgai...@hotmail.com wrote:

 @Table(name = TableNameGoesHere)

 //the java file would use ForeignKey annotation as described
 @org.hibernate.annotations.ForeignKey(name = FK_GOALTOACHIEVE_ID)

 public class WikiDocument extends WikiFileWikiDocument implements 
 Serializable {
    public String getHistoricalEntityName() {
        return HistoricalWikiDocument;
    }

 and the hibernate configuration file (DatabaseObjects.hbm.xml) would handle 
 the SequenceGeneration

 hibernate-mapping package=org.jboss.seam.wiki.core.model 
 default-access=field
    class name=WikiDocument entity-name=HistoricalWikiDocument 
 table=TABLE_NAME_GOES_HERE polymorphism=explicit
        id name=PrimaryKey_In_Java_File column=PRIMARY_KEY_ID
            generator 
 class=org.hibernate.id.enhanced.SequenceStyleGenerator
                param 
 name=sequence_nameTABLE_NAME_PRIMARY_KEY__SEQUENCE/param
            /generator
        /id

 WARNING: Despite (albeit brief) commentary offered
 any attempts to provide SEQUENCE generation to subvert SEQUENCE GENERATION by 
 DBA is discouraged ..you do'nt want 2 sequences on same Table
 i would encourage you to coordinate your SEQUENCE generation activity with DBA

 fwiw
 Martin Gainty
 __
 Verzicht und Vertraulichkeitanmerkung

 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.



 Date: Mon, 13 Jul 2009 09:43:15 -0400
 Subject: Re: updating or deleting a component from a collection through      
  display tag
 From: greg.lindh...@gmail.com
 To: user@struts.apache.org

 
  Thanks for the reply. Well, entry is an instance of a separate class:
 
  @Embeddable
  public class JournalEntry {
  @org.hibernate.annotations.Parent
         private GoalToAchieve goalToAchieve;
  @Column(length = 255, nullable = false)
         private String entry;
 
        �...@temporal(TemporalType.TIMESTAMP)
        �...@column(nullable = false, updatable = false)
         private Date insertDate = new Date();
 
  ...plus the getters and setters
 
  This being a value type embeddable component, it is represented with a
  table with only a foreign key to the parent entity it belongs to:
  goalToAchieve_id
 
  So, if I pass the entry String as a parameter (I am not sure if it
  would be convenient to have a a few sentences as url params), how can
  I turn it into a reference to the object I want to actually remove
  from the collection?
 
  Thanks again
 
   You didn't say what 'entry' is, but if it is a String or some primitive
  you
   can just pass it as another parameter.
  
   s:url action='DeleteEntryForm'
            s:param name=name value=%{goalToAchieve.owner.fullName} /
             s:param name=entry value=%{entry} /
   /s:url
  
   Usually, every database entity object has an 'id' property (primary key)
  and
   you would just pass the id as a parameter so your action can find the
  object
   in the database.
  
   In you browser do a view source on the page to ensure the url is being
   generated correctly with the params you are expecting.
  
 

 You definitely do not want to pass 'entry' as a parameter on the url.
 Every database object needs some kind of unique key id just for situations
 like this.
 Maybe you could use the insertDate as a key (it's probably unique within
 this context) but it would be better to add a key, perhaps a sequence number
 so that goalToAchieve_id + seq is the PK.

 _
 Lauren found her dream laptop. Find the PC that’s right for you.
 http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290

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



Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
I made the changes, but the view source indicates that the param
mark is not passed.

The url linked is formed like this:

/secure/DeleteEntryForm.action?name=firstName+lastNameid=1

The name and id params are fields of the parent object, the one
containing the collection.

Actually, I tried with all fields taken from the collection object,
like entry, and date but none gets passed as a param. Only properties
exposed by the parent object, goalToAchieve are passed, shouldn't I be
able to point to a field within a collection object too?

It looks like individual collection object properties can be viewed
using the iterator/display, but cannot be captured or passed as
parameters for any other uses... unless I am missing something, or
doing something wrong.


On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com wrote:
 Looks like you need to change entry.mark to just mark and remove the
 s:property value=%{entry}/. Also you probably don't need to pass both
 the name and id of the parent object.

 a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
       s:param name=id value=%{goalToAchieve.id} /
       s:param name=mark value=%{mark} /
   /s:url
 Remove/a


 On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 Thanks for letting me know. Alright, so:

 This is the parent class:

 @Entity
 public class GoalToAchieve {
 @Id @GeneratedValue
 private Long id;

 @org.hibernate.annotations.CollectionOfElements
 @JoinTable (name=GoalToAchieve_entry,
 joincolum...@joincolumn(name=goalToAchieve_id))
 private SetJournalEntry entries = new HashSetJournalEntry();

        public SetJournalEntry getEntries() {
                return entries;
        }
        public void setEntries(SortedSetJournalEntry entries) {
                this.entries = entries;
        }

        public void addEntry(JournalEntry newEntry){
                entries.add(newEntry);
        }

        public void deleteEntry(JournalEntry entry){
                entries.remove(entry);
        }
 ..plus some other standard fields with getters and setters

 This is the child-class:

 @Embeddable
 public class JournalEntry {
 @org.hibernate.annotations.Parent
 private GoalToAchieve goalToAchieve;

 @Column
 private Long mark;
 public Long getMark() {
        return mark;
 }
 public void setMark(long mark){
        this.mark = mark;
         }

 @Column(length = 255, nullable = false)
 private String entry;

 @Temporal(TemporalType.TIMESTAMP)
 @Column(nullable = false, updatable = false)
 private Date insertDate = new Date();

 ..plus the rest getters and setters

 And this this the jsp part where I display the collection:

 s:if test=goalToAchieve.entries.size  0
 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
        display:column property=entry /
        display:column property=date sortable=true
 defaultorder=ascending title=TimeStamp/
        display:column property=mark /
  display:column
 a href=s:url action='UpdateEntryForm'
        s:param name=name value=%{goalToAchieve.owner.fullName} /
        s:param name=mark value=#mark /
    /s:url
    Edit/a
 /display:column
 display:column
 a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
         s:param name=name value=%{goalToAchieve.owner.fullName} /
         s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=entry.mark /
        s:property value=%{entry}/
    /s:url
 Remove/a
 /display:column
 /display:table
 /s:if

 ..and the delete action, which should take an entry reference and
 remove it from the collections looks like this:

 public class DeleteEntry extends ActionSupport{
 public String execute(){
                goalToAchieve.deleteEntry(entry);

                return SUCCESS;
        }

        private JournalEntry entry;
        private GoalToAchieve goalToAchieve;
        private long id;

 ... + getters and setters

 I guess right now, my problem has become how to pass a parameter
 referring to en entry (the mark field) to the delete action. Next, I
 would do a lookup within the action to find the entry object and
 remove it from the parent object collection, by calling
 deleteEntry(JournalEntry entry)

 On Mon, Jul 13, 2009 at 9:16 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  You are not providing enough information for anyone to help you. Since
 you
  have changed your object and the jsp you had better include them with any
  request.
 
 
  On Mon, Jul 13, 2009 at 9:51 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  Yes, that is a great suggestion actually. What I did was to add a new
  field based
  System.currentTimeMillis(), but the problem is adding it as a url
  parameter.
 
  For example, I am trying to add it as a url parameter below:
 
  a href=s:url action='UpdateEntryForm'
  s:param name=name value=%{goalToAchieve.owner.fullName} /
  s:param name=mark value=%{mark} /
  /s:url
   Edit/a
 
  But, the only param passed

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Yes, that is exactly the case, hmm.. Although, how is the
display:table tag finds the collection in the first place?

Supposedly the display has some way of reaching the valuestack, it can
even resolve the deeper notation display:table
name=goalToAchieve.entries

However, I will switch back to s:iterator to test if the syntax
suggested will work. I mainly used the display tag as a quick way to
sort the collection, but if I can't access the properties of the
objects I am iterating over, it isn't of much use in this case

On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look up
 how to access the properties of the entities you are iterating over so as to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
        s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=%{mark} /
    /s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  Thanks for letting me know. Alright, so:
 
  This is the parent class:
 
  @Entity
  public class GoalToAchieve {
  @Id @GeneratedValue
  private Long id;
 
  @org.hibernate.annotations.CollectionOfElements
  @JoinTable (name=GoalToAchieve_entry,
  joincolum...@joincolumn(name=goalToAchieve_id))
  private SetJournalEntry entries = new HashSetJournalEntry();
 
         public SetJournalEntry getEntries() {
                 return entries;
         }
         public void setEntries(SortedSetJournalEntry entries) {
                 this.entries = entries;
         }
 
         public void addEntry(JournalEntry newEntry){
                 entries.add(newEntry);
         }
 
         public void deleteEntry(JournalEntry entry){
                 entries.remove(entry);
         }
  ..plus some other standard fields with getters and setters
 
  This is the child-class:
 
  @Embeddable
  public class JournalEntry {
  @org.hibernate.annotations.Parent
  private GoalToAchieve goalToAchieve;
 
  @Column
  private Long mark;
  public Long getMark() {
         return mark;
  }
  public void setMark(long mark){
         this.mark = mark;
          }
 
  @Column(length = 255, nullable = false)
  private String entry;
 
  @Temporal(TemporalType.TIMESTAMP)
  @Column(nullable = false, updatable = false)
  private Date insertDate = new Date();
 
  ..plus the rest getters and setters
 
  And this this the jsp part where I display the collection:
 
  s:if test=goalToAchieve.entries.size  0
  display:table name=goalToAchieve.entries requestURI=
 uid=thisGoal
         display:column property=entry /
         display:column property=date sortable=true
  defaultorder=ascending title=TimeStamp/
         display:column property=mark /
   display:column
  a href=s:url action='UpdateEntryForm'
         s:param name=name value=%{goalToAchieve.owner.fullName} /
         s:param name=mark value=#mark /
     /s:url
     Edit/a
  /display:column
  display:column
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
          s:param name=name value=%{goalToAchieve.owner.fullName} /
          s:param name=id value=%{goalToAchieve.id} /
         s:param name=mark value=entry.mark /
         s:property value=%{entry}/
     /s:url
  Remove/a
  /display:column
  /display:table
  /s:if
 
  ..and the delete action, which should take an entry reference and
  remove it from

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Thanks. So, if I wanted to access a particular property (say this
property is called mark) of an entry object which I am iterating
over, I would do something like the following:

display:table name=goalToAchieve.entries requestURI= uid=thisGoal
display:column property=entry /
display:column property=date sortable=true
defaultorder=ascending title=TimeStamp/
display:column property=mark /
display:column
a href=s:url action='DeleteEntryForm' escapeAmp=false
s:param name=name value=%{goalToAchieve.owner.fullName} /
s:param name=id value=%{goalToAchieve.id} /
s:param name=date value=#attr.entry.mark /
   /s:url
Remove/a
/display:column

So, I could pass mark as a url param via s:url within the display tag?

Thanks for the information!

On Mon, Jul 13, 2009 at 1:08 PM, Musachy Barrosomusa...@gmail.com wrote:
 Assuming that each entry is named entry by displayTag, you can
 access it using #attr.entry (or #attr['entry'])  to access it from
 the S2 tags.

 musachy

 On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look up
 how to access the properties of the entities you are iterating over so as to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
        s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=%{mark} /
    /s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  Thanks for letting me know. Alright, so:
 
  This is the parent class:
 
  @Entity
  public class GoalToAchieve {
  @Id @GeneratedValue
  private Long id;
 
  @org.hibernate.annotations.CollectionOfElements
  @JoinTable (name=GoalToAchieve_entry,
  joincolum...@joincolumn(name=goalToAchieve_id))
  private SetJournalEntry entries = new HashSetJournalEntry();
 
         public SetJournalEntry getEntries() {
                 return entries;
         }
         public void setEntries(SortedSetJournalEntry entries) {
                 this.entries = entries;
         }
 
         public void addEntry(JournalEntry newEntry){
                 entries.add(newEntry);
         }
 
         public void deleteEntry(JournalEntry entry){
                 entries.remove(entry);
         }
  ..plus some other standard fields with getters and setters
 
  This is the child-class:
 
  @Embeddable
  public class JournalEntry {
  @org.hibernate.annotations.Parent
  private GoalToAchieve goalToAchieve;
 
  @Column
  private Long mark;
  public Long getMark() {
         return mark;
  }
  public void setMark(long mark){
         this.mark = mark;
          }
 
  @Column(length = 255, nullable = false)
  private String entry

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Hey, this worked! Thanks Musachy, the tip you provided solved the
problem I was facing for the last 3 days.

I really appreciate your time to post this information. It looks like
the display tag packs much more functionality than it seems.

On Mon, Jul 13, 2009 at 2:03 PM, Musachy Barrosomusa...@gmail.com wrote:
 The current row used by displaytag is pushed under the name set in
 uid, so you could do this:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
 display:column
 a href=s:url action='DeleteEntryForm' escapeAmp=false
 s:param name=date value=#attr.thisGoal.mark /
  /s:url
 Remove/a
 /display:column

 musachy

 On Mon, Jul 13, 2009 at 11:17 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Thanks. So, if I wanted to access a particular property (say this
 property is called mark) of an entry object which I am iterating
 over, I would do something like the following:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
 display:column property=entry /
 display:column property=date sortable=true
 defaultorder=ascending title=TimeStamp/
 display:column property=mark /
 display:column
 a href=s:url action='DeleteEntryForm' escapeAmp=false
 s:param name=name value=%{goalToAchieve.owner.fullName} /
 s:param name=id value=%{goalToAchieve.id} /
 s:param name=date value=#attr.entry.mark /
   /s:url
 Remove/a
 /display:column

 So, I could pass mark as a url param via s:url within the display tag?

 Thanks for the information!

 On Mon, Jul 13, 2009 at 1:08 PM, Musachy Barrosomusa...@gmail.com wrote:
 Assuming that each entry is named entry by displayTag, you can
 access it using #attr.entry (or #attr['entry'])  to access it from
 the S2 tags.

 musachy

 On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru 
 the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look 
 up
 how to access the properties of the entities you are iterating over so as 
 to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass 
  both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
        s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=%{mark} /
    /s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  Thanks for letting me know. Alright, so:
 
  This is the parent class:
 
  @Entity
  public class GoalToAchieve {
  @Id @GeneratedValue
  private Long id;
 
  @org.hibernate.annotations.CollectionOfElements
  @JoinTable (name=GoalToAchieve_entry,
  joincolum...@joincolumn(name=goalToAchieve_id))
  private SetJournalEntry entries = new HashSetJournalEntry();
 
         public SetJournalEntry getEntries() {
                 return entries;
         }
         public void setEntries(SortedSetJournalEntry entries) {
                 this.entries = entries

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Thanks again for helping out Musachy,
I was wondering if there are any rules regarding when the notation you
suggested below can be used. it works perfectly for setting url
params.

I was trying to use it (with struts2 tags) within a form (which is
within the display:column tag) to pass the value to an action:

display:column
s:form action=UpdateEntryForm
s:hidden name=mark value=#attr.thisEntry.mark /
s:hiddenname=name value=%{goalToAchieve.name} /
s:submit value=Edit/
/s:form
/display:column

This creates an Edit button in each row for every object I iterate
over, and I hoped to use the s:hidden tag to populate the underlying
UpdateEntryForm action. I also try to test it by printing from the
execute method as listed below, but the console output is just the
literal for the mark and zero for the primitive:

This id is: 0
This name is: #attr.thisEntry.mark

My action class:

public class UpdateEntryForm extends ActionSupport{
public String execute(){
System.out.println(This id is: + getId());
System.out.println(This name is: + getMark());
return SUCCESS; 
}
private String name;
private long mark;
public String getName() {
return name;
}
public void setName(String name){
this.name = name;
}

public String getMark() {
return mark;
}
public void setMark(String mark){
this.mark = mark;
}
}

Is there something wrong with the code above? Thanks again!

On Mon, Jul 13, 2009 at 2:03 PM, Musachy Barrosomusa...@gmail.com wrote:
 The current row used by displaytag is pushed under the name set in
 uid, so you could do this:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
 display:column
 a href=s:url action='DeleteEntryForm' escapeAmp=false
 s:param name=date value=#attr.thisGoal.mark /
  /s:url
 Remove/a
 /display:column

 musachy

 On Mon, Jul 13, 2009 at 11:17 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Thanks. So, if I wanted to access a particular property (say this
 property is called mark) of an entry object which I am iterating
 over, I would do something like the following:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
 display:column property=entry /
 display:column property=date sortable=true
 defaultorder=ascending title=TimeStamp/
 display:column property=mark /
 display:column
 a href=s:url action='DeleteEntryForm' escapeAmp=false
 s:param name=name value=%{goalToAchieve.owner.fullName} /
 s:param name=id value=%{goalToAchieve.id} /
 s:param name=date value=#attr.entry.mark /
   /s:url
 Remove/a
 /display:column

 So, I could pass mark as a url param via s:url within the display tag?

 Thanks for the information!

 On Mon, Jul 13, 2009 at 1:08 PM, Musachy Barrosomusa...@gmail.com wrote:
 Assuming that each entry is named entry by displayTag, you can
 access it using #attr.entry (or #attr['entry'])  to access it from
 the S2 tags.

 musachy

 On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru 
 the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look 
 up
 how to access the properties of the entities you are iterating over so as 
 to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
 
 as to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg 
 Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass 
  both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry 
  escapeAmp=false
        s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=%{mark} /
    /s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  Thanks for letting me know. Alright, so:
 
  This is the parent class:
 
  @Entity
  public class GoalToAchieve {
  @Id @GeneratedValue
  private Long id;
 
  @org.hibernate.annotations.CollectionOfElements
  @JoinTable (name=GoalToAchieve_entry,
  joincolum...@joincolumn(name=goalToAchieve_id))
  private SetJournalEntry entries = new HashSetJournalEntry();
 
         public SetJournalEntry getEntries() {
                 return entries;
         }
         public void setEntries(SortedSetJournalEntry entries) {
                 this.entries = entries;
         }
 
         public void addEntry(JournalEntry newEntry){
                 entries.add(newEntry);
         }
 
         public void deleteEntry(JournalEntry entry){
                 entries.remove(entry);
         }
  ..plus some other standard fields with getters and setters
 
  This is the child-class:
 
  @Embeddable
  public class JournalEntry {
  @org.hibernate.annotations.Parent
  private GoalToAchieve goalToAchieve;
 
  @Column
  private Long mark;
  public Long getMark() {
         return mark;
  }
  public void setMark(long mark){
         this.mark = mark;
          }
 
  @Column(length = 255, nullable = false)
  private String entry;
 
  @Temporal(TemporalType.TIMESTAMP)
  @Column(nullable = false, updatable = false)
  private Date insertDate = new Date();
 
  ..plus the rest getters and setters
 
  And this this the jsp part where I display the collection:
 
  s:if test=goalToAchieve.entries.size  0
  display:table name=goalToAchieve.entries requestURI=
 uid=thisGoal
         display:column property=entry /
         display:column property=date sortable=true
  defaultorder=ascending title=TimeStamp/
         display:column property=mark /
   display:column
  a href=s:url action='UpdateEntryForm'
         s:param name=name value=%{goalToAchieve.owner.fullName} 
  /
         s:param name=mark value=#mark /
     /s:url
     Edit/a
  /display:column
  display:column
  a href=s:url action='DeleteEntryForm' var=entry 
  escapeAmp=false
          s:param name=name 
  value=%{goalToAchieve.owner.fullName} /
          s:param name=id value=%{goalToAchieve.id} /
         s:param name=mark value=entry.mark /
         s:property value=%{entry}/
     /s:url
  Remove/a
  /display:column
  /display:table
  /s:if
 
  ..and the delete action, which should take an entry reference and
  remove it from the collections looks like this:
 
  public class DeleteEntry extends ActionSupport{
  public String execute(){
                 goalToAchieve.deleteEntry(entry);
 
                 return SUCCESS;
         }
 
         private JournalEntry entry;
         private GoalToAchieve goalToAchieve;
         private long id;
 
  ... + getters and setters
 
  I guess right now, my problem has become how to pass a parameter
  referring to en entry (the mark field) to the delete action. Next, I
  would do a lookup within the action to find the entry object and
  remove it from the parent object collection, by calling
  deleteEntry(JournalEntry entry)
 
  On Mon, Jul 13, 2009 at 9:16 AM, Greg 
  Lindholmgreg.lindh...@gmail.com
  wrote:
   You are not providing enough information for anyone to help you. 
   Since
  you
   have changed your object and the jsp you had better include them 
   with
 any
   request.
  
  
   On Mon, Jul 13, 2009 at 9:51 AM, Dimitrios Christodoulakis 
   dimi@gmail.com wrote:
  
   Yes, that is a great suggestion actually. What I did was to add 
   a new
   field based
   System.currentTimeMillis(), but the problem

reachable valuestack properties exposed by previous actions?

2009-07-12 Thread Dimitrios Christodoulakis
Hello,

This is a quick question that I am having, more on the theory side.
So, what happens to properties exposed on the valuestack by some
action which was called in the past, meaning the application workflow
has progressed and other actions were called after that. Is that
property somehow still reachable on the stack (by other actions and
action results), or is it popped from the stack as soon as another
action is called?

For example, I need to access a property exposed a few actions back,
and was wondering what is the appropriate way to do that. Can I
somehow propagate (or carry over) this property through actions and
results (would like to avoid attaching it to url params) until I am
ready to use it, or can it just sit there and be retrieved by digging
deep into the valuestack? Is there a handy example somewhere?

At the same time I am consulting my struts 2 book to grasp the idea,
but any hint to help me understand this better would be greatly
appreciated.

Regards

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



Re: reachable valuestack properties exposed by previous actions?

2009-07-12 Thread Dimitrios Christodoulakis
Thanks, I will look into action chaining and see if it can help me in
this situation.

On Sun, Jul 12, 2009 at 8:22 AM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 This is a quick question that I am having, more on the theory side.
 So, what happens to properties exposed on the valuestack by some
 action which was called in the past, meaning the application workflow
 has progressed and other actions were called after that. Is that
 property somehow still reachable on the stack (by other actions and
 action results), or is it popped from the stack as soon as another
 action is called?

 If you're not using action chaining the stack is popped between requests.

 Dave

 -
 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: reachable valuestack properties exposed by previous actions?

2009-07-12 Thread Dimitrios Christodoulakis
Thanks for the warning. Actually, I thought it might help me solve
another issue I am facing: deleting objects from a collection. I tried
to explain in my previous thread but, I think I might have not
described the problem correctly.

On Sun, Jul 12, 2009 at 10:14 AM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 Thanks, I will look into action chaining and see if it can help me in
 this situation.

 Oh, please don't; it just leads to maintenance nightmares.

 Dave

 -
 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: reachable valuestack properties exposed by previous actions?

2009-07-12 Thread Dimitrios Christodoulakis
Appreciate the warning. Thanks, I'll try to avoid that then. Alright,
I'll take the chance to re-state my problem in a new thread.

On Sun, Jul 12, 2009 at 11:15 AM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 Thanks for the warning. Actually, I thought it might help me solve
 another issue I am facing: deleting objects from a collection. I tried
 to explain in my previous thread but, I think I might have not
 described the problem correctly.

 To paraphrase an old saying:

 I had a problem where I needed to delete objects from a collection. I
 decided to use action chaining. Then I had two problems.

 In other words, if action chaining is the solution, then chances are the
 problem isn't being stated very well--there is almost *always* a better,
 cleaner way to do it.

 Dave

 -
 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



problem with deleting objects from a collection

2009-07-12 Thread Dimitrios Christodoulakis
Good afternoon,

I am re-stating a problem I am facing, for which I provided a kind of
complicated description before: Deleting objects from a collection.
The owning, parent object is a hibernate persistent entity, which
contains a collection of components (value-type objects). Such
components don't have shared references, which means that removing a
component from the collection results in deleting the object from the
database.

I am calling an action which exposes the parent entity, goalToAchieve,
and the result page iterates over the collection
goalToAchieve.entries:

display:table name=goalToAchieve.entries requestURI= uid=thisGoal
display:column property=entry /
display:column property=date sortable=true
defaultorder=ascending title=TimeStamp/
/display:table

The above works, fine. Each row of the table is an instance of the
JournalEntry class displaying two fields: an entry of type String and
a date of type Date. My objective is to give the user the option to
update or delete each row right from the table view. So, I thought to
add two more columns in each row: Update or Delete. I have not been
able to implement this properly, I tried with a url, and with a form.
My guess is that I cannot pass a reference to the row back to the
action performing the delete or update. Am I making this more
complicated than it really is? What can I be missing?

I tried adding one more column like this, hoping the entry property
will be available to the DeleteEntry action via the mini-form.

display:column
s:form action=DeleteEntry
s:property value=entry/
s:hidden name=id value=%{goalToAchieve.id} /
   s:submit value=Remove/
/s:form
/display:column

The DeleteEntry action has all the getters and setters:

public String execute(){
goalToAchieve = getSubscriberService().getGoalToAchieve(id);
goalToAchieve.deleteEntry(entry);

return SUCCESS;
}

public void setEntry(JournalEntry entry){
this.entry = entry;
}

public JournalEntry getEntry(){
return entry;
}

But I get java.lang.NullPointerException: actions.DeleteEntry.execute

1) I am not sure if the reference to the entry is passing over to the
action, and
2) if it does, seems like there is no entry object instantiated. But
the entry was instantiated at the time of the insert.

Any ideas about this, and general guidelines on deleting objects from
collections?

Appreciate the help.

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



Re: problem with deleting objects from a collection

2009-07-12 Thread Dimitrios Christodoulakis
Thanks Dave,

Yes, the s:property.../ isn't supposed to be there  Thanks for
pointing this out. Indeed, it has to be an object there, in order to
do the remove from the collection. Since this value-type component
(entry) does not have a primary key to look it up from, I am a bit at
a loss how to continue from here.

If you don't mind, could you explain a little bit further? I have
successfully removed entity object from collections before because all
I neede was the primary key to be passed to the delete action. Then
inside the action I did the look up using the key and removed the
object. But with this type of object I have hit a roadblock.

I appreciate any further help.


This is the class:

@Embeddable
public class JournalEntry {

@org.hibernate.annotations.Parent
private GoalToAchieve goalToAchieve;

@Column(length = 255, nullable = false)
private String entry;

@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false, updatable = false)
private Date insertDate = new Date();


plus the appropriate getters and setters..

On Sun, Jul 12, 2009 at 5:03 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 I tried adding one more column like this, hoping the entry property
 will be available to the DeleteEntry action via the mini-form.

 display:column
 s:form action=DeleteEntry
    s:property value=entry/
    s:hidden name=id value=%{goalToAchieve.id} /
   s:submit value=Remove/
 /s:form
 /display:column

 What's that s:property.../ supposed to be doing?

 It's not a form field; there's no entry reference being passed back. Even if
 it *was* a form field it's still not passing a *reference* back--forms
 *only* submit strings. Always. If you want an actual *entry* object there
 either needs to be some type conversion, database retrieval, etc.

 Dave

 -
 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: problem with deleting objects from a collection

2009-07-12 Thread Dimitrios Christodoulakis
I am starting to think that using embeddable might be more hassle than
it sounds. i am considering switching to an entity object and dealing
with a collection of entities instead. Given that I will not have any
shared references anyway, it might solve the problem.

I tried attaching a unique field to each embeddable, like a
System.currentTimeMillis(), just to identify the entries, but although
I can display the properties of each object in the collection, since
the object actually exposed is the parent owning object, I can't
attach a specific component attribute as a url parameter:

a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
s:param name=name value=%{goalToAchieve.owner.fullName} /
s:param name=id value=%{goalToAchieve.id} /
s:param name=mark value=mark /
s:property value=%{entry}/
  /s:url
Remove/a

Now, I added the follow to the class:

   @Column
private Long mark;
public Long getMark() {
return mark;
}
public void setMark(long mark){  //set at each new instance
this.mark = mark;
}

But the parameter is not added to the url. Am I doing this wrong, or
is there another way before switching to entities?

Thanks again.

On Sun, Jul 12, 2009 at 5:03 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 I tried adding one more column like this, hoping the entry property
 will be available to the DeleteEntry action via the mini-form.

 display:column
 s:form action=DeleteEntry
    s:property value=entry/
    s:hidden name=id value=%{goalToAchieve.id} /
   s:submit value=Remove/
 /s:form
 /display:column

 What's that s:property.../ supposed to be doing?

 It's not a form field; there's no entry reference being passed back. Even if
 it *was* a form field it's still not passing a *reference* back--forms
 *only* submit strings. Always. If you want an actual *entry* object there
 either needs to be some type conversion, database retrieval, etc.

 Dave

 -
 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



Nothing found to display from display tag with struts 2

2009-07-11 Thread Dimitrios Christodoulakis
Hello list,

I am exposing a collection called entries in my action class
(SetJournalEntry entries;), with all the appropriate getters and
setters. In the result jsp of this action I am using the display tag
to output the content of the collection:

s:set name=entries value=entries scope=request/ 

display:table name=entries requestURI=
display:column property=entry/
display:column property=date sortable=true
defaultorder=ascending/
/display:table

But the message I get on the jsp page is: Nothing found to display.
(Its not an exception, this message is printed on the regulat html
output page). I am certain that the rows exist on the underlying db, I
am using mysql query browser to check.

So, I have followed instructions about struts2 and the display tag
found in different places:
http://www.nabble.com/Struts-2---DisplayTag-example-td17694341.html
http://www.manning-sandbox.com/thread.jspa?messageID=76885
http://appfuse.org/display/APF/Using+Struts+2

But I can't get this simple task to work. The objective is to simply
display the table. In contrast, using just the struts2 tags, the
following works fine:

table border=3
s:iterator value=entries
tr /
tds:property value=entry//td
tds:property value=date//td
/tr
/s:iterator
/table

However, since I wish to use the display tag for further formatting
and sorting, I was hoping if anyone had any thoughts as to why my code
above finds nothing to display. I can't tell if it finds just an empty
collection, or doesn't find the collection at all.

thanks for any advice.

Regards.

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



Re: Nothing found to display from display tag with struts 2

2009-07-11 Thread Dimitrios Christodoulakis
Yes, thanks for pointing out. The s:set / tag is not required so I
removed it and it works. Kind of wondering how the display tag reaches
the valuestack though, or does it access the first property it finds
in the scope?

Thanks

On Sat, Jul 11, 2009 at 12:26 PM, dustydustin_pea...@yahoo.com wrote:

 That sounds like a troubling one, based on what you describe it should work.
 Especially if the struts iterator works on the same JSP page.   What version
 of Struts and DisplayTag are you using.

 There was a time when you had to use the s:set / tag and a time when you
 did not.  Have you tried without the s:set tag?



 Dimitrios Christodoulakis wrote:

 Hello list,

 I am exposing a collection called entries in my action class
 (SetJournalEntry entries;), with all the appropriate getters and
 setters. In the result jsp of this action I am using the display tag
 to output the content of the collection:

 s:set name=entries value=entries scope=request/
               display:table name=entries requestURI=
                       display:column property=entry/
                       display:column property=date sortable=true
 defaultorder=ascending/
               /display:table

 But the message I get on the jsp page is: Nothing found to display.
 (Its not an exception, this message is printed on the regulat html
 output page). I am certain that the rows exist on the underlying db, I
 am using mysql query browser to check.

 So, I have followed instructions about struts2 and the display tag
 found in different places:
 http://www.nabble.com/Struts-2---DisplayTag-example-td17694341.html
 http://www.manning-sandbox.com/thread.jspa?messageID=76885
 http://appfuse.org/display/APF/Using+Struts+2

 But I can't get this simple task to work. The objective is to simply
 display the table. In contrast, using just the struts2 tags, the
 following works fine:

 table border=3
                       s:iterator value=entries
                               tr /
                                       tds:property value=entry//td
                                       tds:property value=date//td
                               /tr
                       /s:iterator
               /table

 However, since I wish to use the display tag for further formatting
 and sorting, I was hoping if anyone had any thoughts as to why my code
 above finds nothing to display. I can't tell if it finds just an empty
 collection, or doesn't find the collection at all.

 thanks for any advice.

 Regards.

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




 --
 View this message in context: 
 http://www.nabble.com/%22Nothing-found-to-display%22-from-display-tag-with-struts-2-tp24441738p24442243.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



updating or deleting a component from a collection through display tag

2009-07-11 Thread Dimitrios Christodoulakis
Hello list,

I have successfully used the display tag to iterate over a collection
which is exposed in an action class. On each row in addition to the
columns displaying the fields of each object in the collection, I
embed two more struts-tag urls: Update and Remove.

The objective is to have an extra two columns for every row in the
table giving the ability to update or delete each record:

display:table name=goalToAchieve.entries requestURI= uid=thisGoal
display:column property=entry /
display:column property=date sortable=true
defaultorder=ascending title=TimeStamp/
display:columna href=s:url action='UpdateEntryForm'
s:param name=name 
value=%{goalToAchieve.owner.fullName} /
/s:url
Edit/a/display:column
display:columna href=s:url action='DeleteEntryForm'
s:param name=name 
value=%{goalToAchieve.owner.fullName} /
s:property value=%{entry}/
   /s:url
   Remove/a/display:column
/display:table

I am having trouble passing the entry property, (or reference to it)
to the url targeting the update or delete action. The entries
collection consists of value type, embeddable objects. I am aware of
how to pass parameters to the linking url, but my issue is passing a
reference to the entry property of each row, to the update or delete
action for the same row.

I hope I am explaining this correctly. The update, or delete jsp forms
will simply display the same entry from the table row, prompting the
user to go ahead with updating or deleting. So these will be
pass-through empty actions to the jsp re-displaying the entry.
Submitting one of these forms will trigger the actual action. My
struts.xml looks like this:

action name=DeleteEntryForm 
result/pages/DeleteEntryForm.jsp/result
 /action

 action name=DeleteEntry class=actions.DeleteEntry
result/pages/DeleteEntrySuccess.jsp/result
result name=input/pages/DeleteEntryForm.jsp/result
/action

The way I am doing it right now, gives me a NoSuchMethod exception:

WARN OgnlValueStack:49 - Error setting value
ognl.MethodFailedException: Method setEntry failed for object
actions.deleteen...@e3404f [java.lang.NoSuchMethodException:
setEntry([Ljava.lang.String;)]

But in the DeleteEntry class, I have the getters and setters for
entry, and also do a remove from the collection within the execute
method.

Any help is much appreciated

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



Re: compatibility of various versions Tomcat, jdk, and struts2

2009-07-02 Thread Dimitrios Christodoulakis
Thanks Wes,

Latest versions are always better to use for up to date compatibility.

Are you using Struts 2.1.6, Spring 2.5.6 and the latest hibernate jpa
with the bit older versions of jdk1.5.0_17 and Tomcat5.5.27 and
Eclipse?

If there are no known issues (based on versioning only) I'd be very
glad to use the latest struts2,spring and hibernate with the slightly
older jdk and tomcat.

Thanks for your answer.

On Wed, Jul 1, 2009 at 10:00 PM, Wes Wannemacherw...@wantii.com wrote:
 On Wednesday 01 July 2009 21:56:17 Dimitrios Christodoulakis wrote:
 Hello,

 while doing development I am conforming to the versions provided by
 our hosting service. I am trying to select the most suitable version
 of the framework, java and tomcat so, just wanted to ask if there are
 known compatibility issues with the following combination:

 Fixed:
 jdk1.5.0_17
 Tomcat5.5

 Next I want to select Struts2, Spring and Hibernate. So before going
 ahead, downloading all the jar files, would you recommend specific
 versions to go with the given specification above?

 struts2.1.6 or struts2.0.14 ?

 would the current/latest version of spring and hibernate 3 work with
 the above tomcat and jdk? Or which versions are appropriate?

 struts 2 comes with the required spring jars (just for dependency
 injection only) included if I am not mistaken.
 Hibernate 3 ?
 Is there an online resource somewhere where there is such matching of
 versions discussed, with recommendations given just which versions of
 which components to select?

 If anyone could suggest a working combination, would help a lot.

 Thanks to all.


 Have you considered using apache maven? I mean, it sort of builds up a
 dependency graph for you, based on the artifacts you want. That being said, in
 today's world of loose coupling, most of these libraries work together through
 interfaces and such so that you can pretty much pick and choose which versions
 you want. I am currently using Struts 2.1.6, Spring 2.5.6 and whatever the
 latest versions of hibernate's JPA implementation was in early May.

 As far as the choice between 2.1 and 2.0 for Struts, I would suggest going
 with 2.1 if you are starting a new app. New plugins, etc. are likely to be
 built against 2.1, so you will be doing yourself a favor by starting with 2.1.

 -Wes


 --
 Wes Wannemacher
 Author - Struts 2 In Practice
 Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
 http://www.manning.com/wannemacher

 -
 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: compatibility of various versions Tomcat, jdk, and struts2

2009-07-02 Thread Dimitrios Christodoulakis
Thanks for the detailed information Wes, this was useful. I was able
to finally integrate Struts2.1.6, Spring2.5.3 and hibernate3.
WEB-INF/lib became quite bloated with all the jars though :) - I think
35 jars... is it too many perhaps?

I am not sure if there is a way around it, but during this effort to
simply integrate these frameworks I was getting exceptions of the kind
classNotFoundException, but the logs didn't give information which jar
containing the missing class was corrupt, or just not under the /lib
folder. So I had to do a search on the exception and find out which
jar the class is contained in, then download and include the jar in
the /lib folder.

Is there a tool, a quick way, or an eclipse specific trick (?) to tell
right-away which jar is missing from my dependencies just by looking
at the exception? Eclipse console provides a view of the Tomcat log,
so it would be nice to see something like: ClassNotFoundException:
org.blah.blah.class, you are probably missing this.jar

On Thu, Jul 2, 2009 at 8:50 AM, Wes Wannemacherw...@wantii.com wrote:
 I am using whatever version of Java 6 that ubuntu gives me. I'm pretty
 sure it bumped up a version since I started this project, but I point
 to /usr/lib/jvm/java-6-sun which symlinks to the specific version
 in-play.

 I am an IDEA user, but I hide those details behind apache maven. If
 you are unfamiliar with Maven, I would suggest you take a long, hard
 look at it now, especially since you are starting a project and you
 are bringing in Struts 2 / Spring / Hibernate. The details of which
 versions are compatible with what are handled for you by maven,
 eliminating an otherwise troublesome build process.

 Now that I'm at work, I can give you the specific versions -

 Struts 2  all plugins - 2.1.6
 Spring and all Spring modules - 2.5.6
 Hibernate -
    ejb3-persistence - 1.0.2.GA
    hibernate-annotations - 3.4.0.GA
    hibernate-commons-annotations - 3.1.0.GA
    hibernate-core - 3.3.1.GA
    hibernate-entity-manager - 3.4.0.GA

 Since I am using JPA, I am working hard to make the JPA provider a
 deployment detail. So, there is no hard dependency on hibernate
 (thanks to Spring).

 Although I am using the latest JDK, I have the target jvm set to 1.5.
 When I run in tomcat, I issue either tomcat:run to maven, which runs
 Tomcat 6.0.16. I have a server that I deploy to when I need to test a
 real deployment and it is running Tomcat 6.0.18. I have used Tomcat
 5.5.x before this project and I can assure you that Struts 2 / Spring
 / etc. work very well.

 Again though, if you haven't looked at maven, I strongly suggest you
 do so, learning maven will vastly speed up your dev time.

 -Wes


 On Thu, Jul 2, 2009 at 8:57 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Thanks Wes,

 Latest versions are always better to use for up to date compatibility.

 Are you using Struts 2.1.6, Spring 2.5.6 and the latest hibernate jpa
 with the bit older versions of jdk1.5.0_17 and Tomcat5.5.27 and
 Eclipse?

 If there are no known issues (based on versioning only) I'd be very
 glad to use the latest struts2,spring and hibernate with the slightly
 older jdk and tomcat.

 Thanks for your answer.

 On Wed, Jul 1, 2009 at 10:00 PM, Wes Wannemacherw...@wantii.com wrote:
 On Wednesday 01 July 2009 21:56:17 Dimitrios Christodoulakis wrote:
 Hello,

 while doing development I am conforming to the versions provided by
 our hosting service. I am trying to select the most suitable version
 of the framework, java and tomcat so, just wanted to ask if there are
 known compatibility issues with the following combination:

 Fixed:
 jdk1.5.0_17
 Tomcat5.5

 Next I want to select Struts2, Spring and Hibernate. So before going
 ahead, downloading all the jar files, would you recommend specific
 versions to go with the given specification above?

 struts2.1.6 or struts2.0.14 ?

 would the current/latest version of spring and hibernate 3 work with
 the above tomcat and jdk? Or which versions are appropriate?

 struts 2 comes with the required spring jars (just for dependency
 injection only) included if I am not mistaken.
 Hibernate 3 ?
 Is there an online resource somewhere where there is such matching of
 versions discussed, with recommendations given just which versions of
 which components to select?

 If anyone could suggest a working combination, would help a lot.

 Thanks to all.


 Have you considered using apache maven? I mean, it sort of builds up a
 dependency graph for you, based on the artifacts you want. That being said, 
 in
 today's world of loose coupling, most of these libraries work together 
 through
 interfaces and such so that you can pretty much pick and choose which 
 versions
 you want. I am currently using Struts 2.1.6, Spring 2.5.6 and whatever the
 latest versions of hibernate's JPA implementation was in early May.

 As far as the choice between 2.1 and 2.0 for Struts, I would suggest going
 with 2.1 if you are starting a new app. New plugins, etc

compatibility of various versions Tomcat, jdk, and struts2

2009-07-01 Thread Dimitrios Christodoulakis
Hello,

while doing development I am conforming to the versions provided by
our hosting service. I am trying to select the most suitable version
of the framework, java and tomcat so, just wanted to ask if there are
known compatibility issues with the following combination:

Fixed:
jdk1.5.0_17
Tomcat5.5

Next I want to select Struts2, Spring and Hibernate. So before going
ahead, downloading all the jar files, would you recommend specific
versions to go with the given specification above?

struts2.1.6 or struts2.0.14 ?

would the current/latest version of spring and hibernate 3 work with
the above tomcat and jdk? Or which versions are appropriate?

struts 2 comes with the required spring jars (just for dependency
injection only) included if I am not mistaken.
Hibernate 3 ?
Is there an online resource somewhere where there is such matching of
versions discussed, with recommendations given just which versions of
which components to select?

If anyone could suggest a working combination, would help a lot.

Thanks to all.

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



deploying struts2 at godaddy dedicated server - general question

2009-06-21 Thread Dimitrios Christodoulakis
Hello everyone,

I am having some issues deploying a struts2 application at godaddy and was
wondering if anyone has dealt with something similar in the past. The
application runs fine on my local machine with tomcat 6.0. My next step was
to upload and deploy at godaddy dedicated server which is running tomcat 5.5
- The underlying server is  Apache/2.2.8 (Fedora)

The upload of the war file and expansion works fine, and the static html
display fine too. But as soon as a struts2 action is called, I always get
the 404 not found error: The requested URL /Menu.action was not found on
this server.

Their customer service basically can help only if we buy their assisted
plan.

I'd like to start by asking this as a general question, and find out if
anyone had similar issues and how they resolved it. Is it a prticular
setting on the dedicated server that might help perhaps?

The hosting and development frameworks are fixed by the customer.

Thank you in advance.


Re: deploying struts2 at godaddy dedicated server - general question

2009-06-21 Thread Dimitrios Christodoulakis
Thanks for the input. I'll test it locally under 5.5. and  will dig deeper
in the logs and see what I can find. I will let you know.

Appreciate the insight.

On Sun, Jun 21, 2009 at 11:00 AM, Wes Wannemacher w...@wantii.com wrote:

 I'm with dave. Check the logs, in particular, look for messages about
 whether or not the filter started properly. Also check the httpd
 configuration. There are a few ways to integrate httpd and tomcat.
 Many people will use mod_jk but lately I am in favor of having tomcat
 listen on localhost and have httpd reverse proxy all requests. There
 was a belief for a while that httpd should serve static content and
 tomcat serve jsps only. But any more I find tomcat's performance to be
 good enough to serve the static content as well.

 On 6/21/09, Dave Newton newton.d...@yahoo.com wrote:
  Dimitrios Christodoulakis wrote:
  I am having some issues deploying a struts2 application at godaddy and
 was
  wondering if anyone has dealt with something similar in the past. The
  application runs fine on my local machine with tomcat 6.0. My next step
  was
  to upload and deploy at godaddy dedicated server which is running tomcat
  5.5
 
  Does it run locally under 5.5?
 
  The upload of the war file and expansion works fine, and the static html
  display fine too. But as soon as a struts2 action is called, I always
 get
  the 404 not found error: The requested URL /Menu.action was not found on
  this server.
 
  What's in the logs?
 
  Dave
 
  -
  To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
  For additional commands, e-mail: user-h...@struts.apache.org
 
 


 --
 Wes Wannemacher
 Author - Struts 2 In Practice
 Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
 http://www.manning.com/wannemacher

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




Re: deploying struts2 at godaddy dedicated server - general question

2009-06-21 Thread Dimitrios Christodoulakis
It seems that indeed the filters are not starting properly: The catalina.out
log indicates the following:

00:45:40,018 ERROR [/myapp]:3639 - Exception starting filter struts2
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
...
...

00:45:40,044 ERROR [/myapp]:3639 - Exception starting filter HibernateFilter
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
...
...

is it right to assume that bad verison number in .class file means Tomcat
5.5 is unable to run this struts2-hibernate combination? -- Any advice on
deciphering the above errors?

--I tried to run it locally on tomcat 5.5 using eclipse, but turns out I
cannot even assign this project to 5.5 because - according to eclipse: The
server does not support version 2.5 of the J2EE Web module specification.

 So, as a next step would you recommend I upgrade to Tomcat 6.0 on godaddy,
or try to integrate Apache with the existing tomcat 5.5 first to see what
happens?

Wes, you mentioned below your favorite way of integrating http + tomcat,
would you be able to provide a few general steps how to go about doing this?

Many thanks for any help



On Sun, Jun 21, 2009 at 12:09 PM, Dimitrios Christodoulakis 
dimi@gmail.com wrote:

 Thanks for the input. I'll test it locally under 5.5. and  will dig deeper
in the logs and see what I can find. I will let you know.

 Appreciate the insight.

 On Sun, Jun 21, 2009 at 11:00 AM, Wes Wannemacher w...@wantii.com wrote:

 I'm with dave. Check the logs, in particular, look for messages about
 whether or not the filter started properly. Also check the httpd
 configuration. There are a few ways to integrate httpd and tomcat.
 Many people will use mod_jk but lately I am in favor of having tomcat
 listen on localhost and have httpd reverse proxy all requests. There
 was a belief for a while that httpd should serve static content and
 tomcat serve jsps only. But any more I find tomcat's performance to be
 good enough to serve the static content as well.

 On 6/21/09, Dave Newton newton.d...@yahoo.com wrote:
  Dimitrios Christodoulakis wrote:
  I am having some issues deploying a struts2 application at godaddy and
was
  wondering if anyone has dealt with something similar in the past. The
  application runs fine on my local machine with tomcat 6.0. My next
step
  was
  to upload and deploy at godaddy dedicated server which is running
tomcat
  5.5
 
  Does it run locally under 5.5?
 
  The upload of the war file and expansion works fine, and the static
html
  display fine too. But as soon as a struts2 action is called, I always
get
  the 404 not found error: The requested URL /Menu.action was not found
on
  this server.
 
  What's in the logs?
 
  Dave
 
  -
  To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
  For additional commands, e-mail: user-h...@struts.apache.org
 
 


 --
 Wes Wannemacher
 Author - Struts 2 In Practice
 Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
 http://www.manning.com/wannemacher

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




Re: deploying struts2 at godaddy dedicated server - general question

2009-06-21 Thread Dimitrios Christodoulakis
Thanks! Everyone's suggestions are correct. The versions provided by godaddy
are:
ROOT/usr/java/jdk1.5.0_17, and
ROOT/usr/java/tomcat-5.5

Currently in dev I am using later versions for both. Wes, I think you are
right, I'd need to at least match at those versions mentioned above on my
local development. But, even after matching, do I still need integration
between apache and tomcat on godaddy side, or matching versions between dev
and prod take care of this?

Dave, that is correct, when starting the project on eclipse I am prompted to
select a dynamic web module version (2.2, 2.3, 2.4, 2.5) I am reading online
about the J2EE Web module specification, but can I quickly ask what is the
meaning of a web module? Is it possible to convert backwards between module
versions? Is it eclipse-related, tomcat-related or does it indicate which
servlet/jsp spec I can use?

Apparently older versions of tomcat support only earlier web module
versions. Other than that, are there other reasons of choosing one web
module version over another?

Thanks again for your responses.


On Sun, Jun 21, 2009 at 1:51 PM, Wes Wannemacher w...@wantii.com wrote:

 The error indicates that you compiled for a jvm newer than the tomcat
 runtime. For instance you compiled with 1.6 and you are trying to run
 on 1.5. Stick to tomcat 5.5 if that is what godaddy provides. The
 tomcat version doesn't indicate its newness as much as it indicates
 which servlet / jsp spec it implements. To save yourself a headache,
 match major/minor version numbers between your dev and production
 environments. To see the setup I was talking about earlier you can
 find patch files in svn somewhere that show how I set it up on the
 struts zone. The advantage is in its simplicity. I am sure it could be
 optimized for better performance, but I like to stick to simple over
 premature optimization. I am on my BlackBerry, so when I boot up my
 laptop I can send an example config.
 -W

 On 6/21/09, Dimitrios Christodoulakis dimi@gmail.com wrote:
  It seems that indeed the filters are not starting properly: The
catalina.out
  log indicates the following:
 
  00:45:40,018 ERROR [/myapp]:3639 - Exception starting filter struts2
  java.lang.UnsupportedClassVersionError: Bad version number in .class
file
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
  ...
  ...
 
  00:45:40,044 ERROR [/myapp]:3639 - Exception starting filter
HibernateFilter
  java.lang.UnsupportedClassVersionError: Bad version number in .class
file
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
  at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
  ...
  ...
 
  is it right to assume that bad verison number in .class file means
Tomcat
  5.5 is unable to run this struts2-hibernate combination? -- Any advice
on
  deciphering the above errors?
 
  --I tried to run it locally on tomcat 5.5 using eclipse, but turns out I
  cannot even assign this project to 5.5 because - according to eclipse:
The
  server does not support version 2.5 of the J2EE Web module
specification.
 
   So, as a next step would you recommend I upgrade to Tomcat 6.0 on
godaddy,
  or try to integrate Apache with the existing tomcat 5.5 first to see
what
  happens?
 
  Wes, you mentioned below your favorite way of integrating http + tomcat,
  would you be able to provide a few general steps how to go about doing
this?
 
  Many thanks for any help
 
 
 
  On Sun, Jun 21, 2009 at 12:09 PM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  Thanks for the input. I'll test it locally under 5.5. and  will dig
deeper
  in the logs and see what I can find. I will let you know.
 
  Appreciate the insight.
 
  On Sun, Jun 21, 2009 at 11:00 AM, Wes Wannemacher w...@wantii.com
wrote:
 
  I'm with dave. Check the logs, in particular, look for messages about
  whether or not the filter started properly. Also check the httpd
  configuration. There are a few ways to integrate httpd and tomcat.
  Many people will use mod_jk but lately I am in favor of having tomcat
  listen on localhost and have httpd reverse proxy all requests. There
  was a belief for a while that httpd should serve static content and
  tomcat serve jsps only. But any more I find tomcat's performance to be
  good enough to serve the static content as well.
 
  On 6/21/09, Dave Newton newton.d...@yahoo.com wrote:
   Dimitrios Christodoulakis wrote:
   I am having some issues deploying a struts2 application at godaddy
and
  was
   wondering if anyone has dealt with something similar in the past.
The
   application runs fine on my local machine with tomcat 6.0. My next
  step
   was
   to upload and deploy at godaddy dedicated server which is running
  tomcat
   5.5
  
   Does it run locally under 5.5?
  
   The upload of the war file and expansion works fine, and the static
  html
   display fine too. But as soon

Re: trouble retrieving a request parameter with struts2 tags

2009-06-07 Thread Dimitrios Christodoulakis
That is interesting. I tried using the escapeTick=true attribute
with the s:url, but got an exception:

org.apache.jasper.JasperException: /pages/list.jsp(26,6) Attribute
escapeTick invalid for tag url according to TLD

A further look at the struts 2 tag reference:
http://struts.apache.org/2.1.6/docs/url.html
Doesn't indicate that the url tag has such an attribute -- I am using
struts 2 version 2.1.6, was that attribute used in other versions?

Since you mentioned it, I tried an example, without the escapeTick
attribute and the URL now forms like this:
http://localhost/MyApp/edit.action?id=69firstName=colinlastName=o%27hara

Although the tick (or apostrophe) is not escaped, when I retrieve the
lastName parameter to have the field pre-populated, the name is
rendered correctly.

But, you made a good point, are there other ways to escape special
characters with attributes, or further manual coding are needed?

On Sat, Jun 6, 2009 at 10:26 PM, Martin Gaintymgai...@hotmail.com wrote:

 yes that works for john doe
 but those of us with irish names like patrick o'donnell would need the tick 
 mark escaped
  s:url action=edit var=editURL escapeAmp = false escapeTick=true
 ?
 Martin Gainty
 __
 Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 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.




 Date: Sat, 6 Jun 2009 13:13:08 -0500
 Subject: Re: trouble retrieving a request parameter with struts2 tags
 From: dimi@gmail.com
 To: user@struts.apache.org

 With a little bit more searching I found the escapeAmp attribute of
 the s:url tag. That did the trick:

 s:url action=edit var=editURL escapeAmp = false

 Thanks!

 On Sat, Jun 6, 2009 at 10:41 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
  Thank you for the information. That ofnl expression actually worked.
  The textfield is populated with the value taken from the URL
  parameter.
 
  But something strange happens when I try to put more parameters on the 
  request:
 
  s:url action=edit var=editURL
         s:param name=id value=%{id} /
         s:param name=firstName value=%{firstName} /
         s:param name=lastName value=%{lastName} /
  /s:url
 
  So the link forms like this:
 
  http://localhost/MyApp/edit.action?id=38firstName=johnlastName=doe
 
  Next, on the update page, I try to retrieve not only the id, but the
  first name and last name too from the URL (in order to pre-fill the
  textfields):
 
  s:form action=save
           s:textfield name=person.firstName
  value=%{#parameters.firstName} label=First Name/
           s:textfield name=person.lastName
  value=%{#parameters.lastName} label=Last Name/
           s:hidden name=person.id value=%{#parameters.id}
  label=Primary Key /
           s:submit/
  /s:form
 
  Although ognl correctly picks up the first parameter (id), takes its
  value and populates the hidden field, I get 2 ognl warnings: one for
  the first name and one for the last name:
 
  WARN OgnlValueStack:49 - Error setting value
  ognl.ExpressionSyntaxException: Malformed OGNL expression:
  amp;firstName [ognl.TokenMgrError: Lexical error at line 1, column 4.
  Encountered: ; (59), after : ]
 
  WARN OgnlValueStack:49 - Error setting value
  ognl.ExpressionSyntaxException: Malformed OGNL expression:
  amp;lastName [ognl.TokenMgrError: Lexical error at line 1, column 4.
  Encountered: ; (59), after : ]
 
  A look at how the URL forms confirms this: Instead of adding the
  parameters in URL using just a , parameters are separated by this:
  
 
  --Is that some sort of bug when evaluating multiple struts2 param tags
  with ognl, or do I have something wrong in the jsp code?
  The actual action ode works ok, I believe the issue is within that jsp 
  only.
 
  Again, I appreciate any further advice on this.
  Regards to everyone.
 
 
 
  On Fri, Jun 5, 2009 at 9:32 PM, Dave Newtonnewton.d...@yahoo.com wrote:
  Dimitrios Christodoulakis wrote:
 
  s:hidden name=person.id value=#attr.id label=Primary Key /
 
  I told you #attr.id on javaranch; I meant #parameters. This information is
  readily

Re: trouble retrieving a request parameter with struts2 tags

2009-06-06 Thread Dimitrios Christodoulakis
Thank you for the information. That ofnl expression actually worked.
The textfield is populated with the value taken from the URL
parameter.

But something strange happens when I try to put more parameters on the request:

s:url action=edit var=editURL
s:param name=id value=%{id} /
s:param name=firstName value=%{firstName} /
s:param name=lastName value=%{lastName} /
/s:url

So the link forms like this:

http://localhost/MyApp/edit.action?id=38amp;firstName=johnamp;lastName=doe

Next, on the update page, I try to retrieve not only the id, but the
first name and last name too from the URL (in order to pre-fill the
textfields):

s:form action=save  
  s:textfield name=person.firstName
value=%{#parameters.firstName} label=First Name/
  s:textfield name=person.lastName
value=%{#parameters.lastName} label=Last Name/
  s:hidden name=person.id value=%{#parameters.id}
label=Primary Key /
  s:submit/
/s:form   

Although ognl correctly picks up the first parameter (id), takes its
value and populates the hidden field, I get 2 ognl warnings: one for
the first name and one for the last name:

WARN OgnlValueStack:49 - Error setting value
ognl.ExpressionSyntaxException: Malformed OGNL expression:
amp;firstName [ognl.TokenMgrError: Lexical error at line 1, column 4.
Encountered: ; (59), after : ]

WARN OgnlValueStack:49 - Error setting value
ognl.ExpressionSyntaxException: Malformed OGNL expression:
amp;lastName [ognl.TokenMgrError: Lexical error at line 1, column 4.
Encountered: ; (59), after : ]

A look at how the URL forms confirms this: Instead of adding the
parameters in URL using just a , parameters are separated by this:
amp;

--Is that some sort of bug when evaluating multiple struts2 param tags
with ognl, or do I have something wrong in the jsp code?
The actual action ode works ok, I believe the issue is within that jsp only.

Again, I appreciate any further advice on this.
Regards to everyone.



On Fri, Jun 5, 2009 at 9:32 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 s:hidden name=person.id value=#attr.id label=Primary Key /

 I told you #attr.id on javaranch; I meant #parameters. This information is
 readily available via the S2 docs. [1, 2]

 IIRC the value attribute expects a literal; I'd wrap it in the OGNL
 escape, %{#parameters.id}, to make sure it's evaluated. Correct rendering
 is, of course, trivially verifiable by viewing the rendered source.

 The fact remains that if person.id isn't being filled correctly by your Java
 code something is still wrong with it.

 I have also tried unsuccessfully to retrieve the parameter value
 from the action code, but always get null.

 If I'm understanding what you're saying there then something is doubly wrong
 with either your config or your assumptions: there are several ways to
 retrieve URL parameters, and AFAIK they all work.

 Note that the result named SUCCESS will never be used if you're using the
 ActionSupport convenience result constants.

 Dave

 [1] OGNL
 http://struts.apache.org/2.x/docs/ognl.html

 [2] OGNL Basics
 http://struts.apache.org/2.x/docs/ognl-basics.html

 -
 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: trouble retrieving a request parameter with struts2 tags

2009-06-06 Thread Dimitrios Christodoulakis
With a little bit more searching I found the escapeAmp attribute of
the s:url tag. That did the trick:

s:url action=edit var=editURL escapeAmp = false

Thanks!

On Sat, Jun 6, 2009 at 10:41 AM, Dimitrios
Christodoulakisdimi@gmail.com wrote:
 Thank you for the information. That ofnl expression actually worked.
 The textfield is populated with the value taken from the URL
 parameter.

 But something strange happens when I try to put more parameters on the 
 request:

 s:url action=edit var=editURL
        s:param name=id value=%{id} /
        s:param name=firstName value=%{firstName} /
        s:param name=lastName value=%{lastName} /
 /s:url

 So the link forms like this:

 http://localhost/MyApp/edit.action?id=38amp;firstName=johnamp;lastName=doe

 Next, on the update page, I try to retrieve not only the id, but the
 first name and last name too from the URL (in order to pre-fill the
 textfields):

 s:form action=save
          s:textfield name=person.firstName
 value=%{#parameters.firstName} label=First Name/
          s:textfield name=person.lastName
 value=%{#parameters.lastName} label=Last Name/
          s:hidden name=person.id value=%{#parameters.id}
 label=Primary Key /
          s:submit/
 /s:form

 Although ognl correctly picks up the first parameter (id), takes its
 value and populates the hidden field, I get 2 ognl warnings: one for
 the first name and one for the last name:

 WARN OgnlValueStack:49 - Error setting value
 ognl.ExpressionSyntaxException: Malformed OGNL expression:
 amp;firstName [ognl.TokenMgrError: Lexical error at line 1, column 4.
 Encountered: ; (59), after : ]

 WARN OgnlValueStack:49 - Error setting value
 ognl.ExpressionSyntaxException: Malformed OGNL expression:
 amp;lastName [ognl.TokenMgrError: Lexical error at line 1, column 4.
 Encountered: ; (59), after : ]

 A look at how the URL forms confirms this: Instead of adding the
 parameters in URL using just a , parameters are separated by this:
 amp;

 --Is that some sort of bug when evaluating multiple struts2 param tags
 with ognl, or do I have something wrong in the jsp code?
 The actual action ode works ok, I believe the issue is within that jsp only.

 Again, I appreciate any further advice on this.
 Regards to everyone.



 On Fri, Jun 5, 2009 at 9:32 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 s:hidden name=person.id value=#attr.id label=Primary Key /

 I told you #attr.id on javaranch; I meant #parameters. This information is
 readily available via the S2 docs. [1, 2]

 IIRC the value attribute expects a literal; I'd wrap it in the OGNL
 escape, %{#parameters.id}, to make sure it's evaluated. Correct rendering
 is, of course, trivially verifiable by viewing the rendered source.

 The fact remains that if person.id isn't being filled correctly by your Java
 code something is still wrong with it.

 I have also tried unsuccessfully to retrieve the parameter value
 from the action code, but always get null.

 If I'm understanding what you're saying there then something is doubly wrong
 with either your config or your assumptions: there are several ways to
 retrieve URL parameters, and AFAIK they all work.

 Note that the result named SUCCESS will never be used if you're using the
 ActionSupport convenience result constants.

 Dave

 [1] OGNL
 http://struts.apache.org/2.x/docs/ognl.html

 [2] OGNL Basics
 http://struts.apache.org/2.x/docs/ognl-basics.html

 -
 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



trouble retrieving a request parameter with struts2 tags

2009-06-05 Thread Dimitrios Christodoulakis
Hello,

I am building a struts2-hibernate-mysql application. A user after
navigating through some pages reaches a pages where all the records on
the database are listed and can perform crud operations.

The jsp which iterates and displays the records is:

%@ taglib prefix=s uri=/struts-tags%

pPersons found on database/p
a href=s:url action='adduser'/Add new User/a
s:if test=persons.size  0  
table
s:iterator value=persons
tr id=row_s:property value=id/

td
s:property value=id /
/td
td
s:property value=firstName /
/td
td
s:property value=lastName /
/td
td
s:url action=remove 
var=remURL
s:param name=id 
value=id /
/s:url
a href=s:property value 
=remURL/Remove/a  
/td
td
s:url action=edit 
var=editURL
s:param name=id 
value=id /
/s:url
a href=s:property value 
=editURL/Edit/a
/td
td
a style=color: #FF 
href=AccountsView account details/a
/td
/tr
/s:iterator
/table
/s:if
a href=s:url action='admin'/Back to Administrator's homepage/a

---As you can see within the above jsp an edit link is generated for
every record and the record id is passed as a parameter to the URL,
with: s:param name=id value=id /

When the user follows the edit link, the URL forms like this:

http://localhost/MyApp/edit.action?id=38

The record identifier is passed as a parameter in the URL: ?id=38

The link brings the user to a new form to perform a simple edit of the
record; first name and last name:

The jsp with the edit form is the following:

%@ page contentType=text/html; charset=UTF-8 %
%@ taglib prefix=s uri=/struts-tags %
html

head
titleUpdate User/title
s:head/
/head

body
h4Edit information for selected user/h4
s:form action=save  
  s:textfield name=person.firstName
value=%{person.firstName} label=First Name/
  s:textfield name=person.lastName label=Last Name/
  s:hidden name=person.id value=#attr.id label=Primary Key /
  s:submit/
/s:form   

/body

/html

The aim is to have the hidden field pre-filled with the value taken
from the URL parameter as soon as the user clicks on the edit link
and reaches the new form to update a record. Unfortunately so far I
have not been able to retrieve that parameter and use its value to
fill that texfield. The id value is always null.

The consequence is that the code performs a new insert instead of an
update, it sees the null id and assumes a new record must be inserted.
Could anyone perhaps provide some advice how can I solve this?

If required my struts.xml file is:

?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE struts PUBLIC
-//Apache Software Foundation//DTD Struts Configuration 2.0//EN
http://struts.apache.org/dtds/struts-2.0.dtd;

struts
constant name=struts.enable.DynamicMethodInvocation value=false/
constant name=struts.devMode value=false/

package name=default namespace=/ extends=struts-default
action name=Menu
resultpages/firstpage.jsp/result
/action

 action name=user
resultpages/user/user_auth.jsp/result
/action

action name=admin
resultpages/admin/admin_auth.jsp/result
/action

action name=list method=execute class=org.user.PersonAction
result/pages/list.jsp/result
result name=inputpages/list.jsp/result
/action

action name=remove method=remove class=org.user.PersonAction 
result/pages/list.jsp/result
result name=inputpages/list.jsp/result
/action

action name=adduser
resultpages/user/Registration.jsp/result
/action

action name=save method=save class=org.user.PersonAction 
result/pages/list.jsp/result
result name=SUCCESSpages/list.jsp/result
/action

action name=edit