Author Login
Post Reply
user Digest 17 Jul 2009 10:18:13 -0000 Issue 8757
Topics (messages 200812 through 200841):
Design Practice question. Should I use same Action class for different functions?
200812 by: tsongwei
200825 by: Dave Newton
EJB Injection in Interceptor
200813 by: Nathan Schulte
200814 by: Nils-Helge Garli Hegvik
200815 by: Nathan Schulte
200828 by: Wes Wannemacher
200832 by: Nathan Schulte
Re: Setter in action triggers twice. Bug?
200816 by: Ritvars RundzÄns
200817 by: Musachy Barroso
200820 by: Ritvars RundzÄns
200826 by: Dave Newton
200838 by: Ritvars RundzÄns
struts1 and jasper reports
200818 by: Odelya YomTov
Re:
org.apache.jasper.JasperException: The Struts dispatcher cannot be found.
200819 by: Lukasz Lenart
Re: Plug-in creation and freemarker page location
200821 by: Musachy Barroso
200822 by: Musachy Barroso
struts 2 adoption/performance/scalability
200823 by: Musachy Barroso
200833 by: Wes Wannemacher
Re: unit testing Struts2 application (with Spring and Hibernate)
200824 by: Dave Newton
200829 by: Wes Wannemacher
200839 by: Pawe³ Wielgus
200840 by: musomesa.aol.com
Re: [Struts 2] Date conversion general bug!
200827 by: rsilva
200830 by: Zoran Avtarovski
in JSP: rounding values
200831 by: mathias-ewald
200835 by: Lukasz Lenart
200837 by: mathias-ewald
200841 by: Lukasz Lenart
Re: Freemarker and Select Tag
200834 by: Nitesh Jain
Re: Login with Struts2
200836 by: Nitesh Jain
Administrivia:
---------------------------------------------------------------------
To post to the list, e-mail: user@(protected)
To unsubscribe, e-mail: user-digest-unsubscribe@(protected)
For additional commands, e-mail: user-digest-help@(protected)
----------------------------------------------------------------------

Attachment:
user_200812.ezm (zipped)
Hi,
This is a general design practice question.
Say if I am designing User Account Management component that does the
following:
1) User Profile info update -- updates firs name, last name, etc,...
2) Change password. -- do password verification, and change password
3) User Payment info update. -- add credit card info.
My question is, since these three function requires similar info from user,
how many action class should I use?
Should I use one: "UserAccountAction.java"?
or three actions: "UserProfileAction.java", "UserPasswordAction.java", and
"UserPaymentInfoAction.java"?
The approach I took is using one actions: "UserAccountAction".
But the problem is I created many properties and getters setters that are
not used for all struts action mappings.
So I am wondering if this is good practice or not, or should I break it into
three action classes.
How would you design this?
Any suggestion is welcome.
Thanks a lot!!
ST
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_200825.ezm (zipped)tsongwei wrote:
> This is a general design practice question.
> Say if I am designing User Account Management component that does the
> following:
> 1) User Profile info update -- updates firs name, last name, etc,...
> 2) Change password. -- do password verification, and change password
> 3) User Payment info update. -- add credit card info.
>
> My question is, since these three function requires similar info from user,
> how many action class should I use?
> Should I use one: "UserAccountAction.java"?
> or three actions: "UserProfileAction.java", "UserPasswordAction.java", and
> "UserPaymentInfoAction.java"?
>
>
> The approach I took is using one actions: "UserAccountAction".
> But the problem is I created many properties and getters setters that are
> not used for all struts action mappings.
> So I am wondering if this is good practice or not, or should I break it into
> three action classes.
>
>
> How would you design this?
Personally I tend to use multiple actions, mostly to avoid having
unnecessary action properties. For me it's easier to deal with many
tightly-focused classes (as opposed to a small number of classes with
multiple responsibilities).
I don't think there's a right or wrong way, really--I just happen to
prefer keeping classes as light and lean as possible; they're easier for
me to read and understand that way. The negative is that I end up with a
lot of classes--but I'm okay with that.
Common functionality often gets broken out into super-classes. For
example a recent project now has a user admin action base class with a
bunch of services used across all user admin functionality, with a
number of sub-classes that handle specific tasks.
Bigger codespace, more lines of code. Lower cognitive overhead for each
class (although it's not always immediately obvious where shared
functionality is handled), more granularity making things easier to mock
and/or stub.
Ah, I miss Smalltalk.
Dave

Attachment:
user_200813.ezm (zipped)This may be more related to XWork2, but I'll start by asking here.
I'm creating a custom Interceptor to handle user permissions for an application.
Rather than redirecting to an action to actually process a login attempt
(requiring a custom result type), the Interceptor itself will process the login
attempt. However, in order for this to work, the Interceptor needs access to a
session bean that is the interface to the persistence layer.
Is it possible to use the Java EE 5 @EJB annotation to inject an EJB, or even
the Inject EJB Plugin? I've tried both, and neither seem to work (both result
in a null object reference). I realize I can use a JNDI lookup to get a
reference to the bean, but I would much rather use injection if possible, as
that's why it's there.
Thanks!
-Nate

Attachment:
user_200814.ezm (zipped)The short answer - You have to do the lookup yourself.
The long answer - There's a similar discussion going on that pretty
much covers the topic:
http://www.nabble.com/Struts2-Action-Class-and-EJB-Injection-td24497801.html
Nils-H
On Thu, Jul 16, 2009 at 10:03 PM, Nathan Schulte<nathan.schulte@(protected):
> This may be more related to XWork2, but I'll start by asking here.
>
> I'm creating a custom Interceptor to handle user permissions for an application.
> Rather than redirecting to an action to actually process a login attempt
> (requiring a custom result type), the Interceptor itself will process the login
> attempt. However, in order for this to work, the Interceptor needs access to a
> session bean that is the interface to the persistence layer.
>
> Is it possible to use the Java EE 5 @EJB annotation to inject an EJB, or even
> the Inject EJB Plugin? I've tried both, and neither seem to work (both result
> in a null object reference). I realize I can use a JNDI lookup to get a
> reference to the bean, but I would much rather use injection if possible, as
> that's why it's there.
>
> Thanks!
> -Nate
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment:
user_200815.ezm (zipped)Nils-Helge Garli Hegvik <nilsga <at> gmail.com> writes:
> The short answer - You have to do the lookup yourself.
:/
> The long answer - There's a similar discussion going on that pretty
> much covers the topic:
> http://www.nabble.com/Struts2-Action-Class-and-EJB-Injection-td24497801.html
Yes, I'm familiar with this issue. I guess, in order to resolve it in an
Interceptor as opposed to an Action (the method of using an Interceptor and
reflection to do the injection), one would have to do the same for the
Interceptors...
Oh well, you can't win all of the time.
Thanks for the speedy reply!

Attachment:
user_200828.ezm (zipped)On Thursday 16 July 2009 04:20:05 pm Nathan Schulte wrote:
> Nils-Helge Garli Hegvik <nilsga <at> gmail.com> writes:
> > The short answer - You have to do the lookup yourself.
> >
> :/
> :
> > The long answer - There's a similar discussion going on that pretty
> > much covers the topic:
> > http://www.nabble.com/Struts2-Action-Class-and-EJB-Injection-td24497801.h
> >tml
>
> Yes, I'm familiar with this issue. I guess, in order to resolve it in an
> Interceptor as opposed to an Action (the method of using an Interceptor and
> reflection to do the injection), one would have to do the same for the
> Interceptors...
>
> Oh well, you can't win all of the time.
>
> Thanks for the speedy reply!
Seems to me that my idea to create an ObjectFactory based plugin (rather than
the existing interceptor-based plugins) needs to pick up some steam. I only
have one question for the EJB users out there... Do you guys need Spring
integration as well? Currently, the spring plugin is the only plugin (I know
of) that is based on a replacement ObjectFactory. If you don't need Spring, I
could probably put one together pretty quick. If you need Spring, it would
take a little longer, or it could be a separate plugin...
-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

Attachment:
user_200832.ezm (zipped)Wes Wannemacher <wesw <at> wantii.com> writes:
> Seems to me that my idea to create an ObjectFactory based plugin ... needs to
pick up some steam.
> I only have one question for the EJB users out there... Do you guys need
Spring integration as well?
To answer your question, _I_ personally don't need Spring integration. I've
never used Spring, and for this project, it was too much overhead to learn (on
top of Java EE, the JPA, Hibernate intricacies, Struts2...), and from what I
understand, it seemed like using it and S2 together provided duplicate
functionality (another topic altogether...).
On another note, I find it awesome that the community (or whatever group you're
part of) is so willing to provide support. I mean, in my eyes, this is
something that I could see myself writing to make my coding easier, it's just
that given my situation, it's easier to use the "workaround." Admittedly, I'm
not very familiar with JEE5. Some of this is still black magic, and I don't
fully understand the issue, I just know enough to understand that the
architecture permits it as an issue (and not everyone is just blowing smoke my
way) and can leave all of the intricate details be, as they don't directly
affect my project.
-Nate

Attachment:
user_200816.ezm (zipped)Look carefully! As you can see, BOTH setters origin from static params
interceptor (1st: line 129, 2nd - line 148).
And i do not have set it up somewhere - look @ war. Config is as simple as
possible.

Attachment:
user_200817.ezm (zipped)uh? This is from the 2nd stack:
ParametersInterceptor.doIntercept(ActionInvocation) line: 187
ParametersInterceptor(MethodFilterInterceptor).intercept(ActionInvocation)
musachy
On Thu, Jul 16, 2009 at 1:33 PM, Ritvars Rundzāns<rrundzans@(protected):
> Look carefully! As you can see, BOTH setters origin from static params
> interceptor (1st: line 129, 2nd - line 148).
> And i do not have set it up somewhere - look @ war. Config is as simple as
> possible.
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd

Attachment:
user_200820.ezm (zipped)Yes, 2nd one contains ParametersInterceptor call, but both of them contains
StaticParametersInterceptor call. You mentioned, that "static param
interceptor, so you have that set up
somewhere". There are no explicitly defined interceptors @ my-super-app.
Ok, whatewer, this is irrelevant. Just deploy war and see it all for
yourself. Sources are included, so feel free to compile them for yourself,
if u think this is neccessary.

Attachment:
user_200826.ezm (zipped)Ritvars Rundza-ns wrote:
> Yes, 2nd one contains ParametersInterceptor call, but both of them contains
> StaticParametersInterceptor call. You mentioned, that "static param
> interceptor, so you have that set up
> somewhere". There are no explicitly defined interceptors @ my-super-app.
The default stack contains the static params interceptor.
Dave

Attachment:
user_200838.ezm (zipped)Ok, this is all great, but problem still is not solved.
You can see configs provided @ war.
I will put this simple:
My app`s config is taken from struts-blank, so its minimal, and there are no
explicit changes in interceptor stack for any of actions. Why this crap
happens then? I really dont care what calls who - what matters here - why
this even happens on such minimalistic configuration?

Attachment:
user_200818.ezm (zipped)Hi!
I would like to implement JASPER and my struts1 appliction
I have list of orders and items and I would like to use it .
I am new to JASPER. Does anyone know of an example for it?
Thanks

Attachment:
user_200819.ezm (zipped)2009/7/16 jayadevan <jayadevan.m@(protected)>:
> xwork-2.0.4.jar,
> ognl-2.6.11.jar,
> jsp-api-2.0.jar,freemarker-2.3.8.jar,
> commons-logging-1.0.4.jar
> these are other jars
And struts2-core.jar, which version? Do you have some other exception
when you're starting Tomcat?
Regards
--
Lukasz
http://www.lenart.org.pl/
http://dailylog.lenart.org.pl/
Stephen Leacock - "I detest life-insurance agents: they always argue
that I shall some day die, which is not so." -
http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html

Attachment:
user_200821.ezm (zipped)there is no magic there, remove the first "/" and give it a try.
musachy
On Thu, Jul 16, 2009 at 12:29 PM, stanlick<stanlick@(protected):
>
> I am working on a plug-in and having trouble getting the runtime to find my
> freemarker pages. I have a folder named pages in my plugin.jar where my
> freemarker pages reside. My struts-plugin.xml is referring to the pages as
> follows:
>
> <result type="freemarker">/pages/config.ftl</result>
>
> However, I am receiving a runtime
>
>
java.io.FileNotFoundException: Template /config/pages/config.ftl not found.
> at
freemarker.template.Configuration.getTemplate (
Configuration.java:489)
>
> I have studied the struts2-config-browser-plugin and I'm now starting to
> wonder if there is some magic with respect to the freemarker folder being
> called config-browser which happens to be the same namespace of the plugin.
>
> Does anyone know the mechanics of these names?
>
> Peace,
> Scott
> --
> View this message in context: http://www.nabble.com/Plug-in-creation-and-freemarker-page-location-tp24522925p24522925.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd

Attachment:
user_200822.ezm (zipped)Well, actually I am wrong about that and yes, if there is no "/", it
will use the namespace name:
if (!locationArg.startsWith("/")) {
ActionContext ctx = invocation.getInvocationContext();
HttpServletRequest req = (HttpServletRequest)
ctx.get(ServletActionContext.HTTP_REQUEST);
String base = ResourceUtil.getResourceBase(req);
locationArg = base + "/" + locationArg;
}
musachy
On Thu, Jul 16, 2009 at 3:36 PM, Musachy Barroso<musachy@(protected):
> there is no magic there, remove the first "/" and give it a try.
>
> musachy
>
> On Thu, Jul 16, 2009 at 12:29 PM, stanlick<stanlick@(protected):
>>
>> I am working on a plug-in and having trouble getting the runtime to find my
>> freemarker pages. I have a folder named pages in my plugin.jar where my
>> freemarker pages reside. My struts-plugin.xml is referring to the pages as
>> follows:
>>
>> <result type="freemarker">/pages/config.ftl</result>
>>
>> However, I am receiving a runtime
>>
>>
java.io.FileNotFoundException: Template /config/pages/config.ftl not found.
>> at
freemarker.template.Configuration.getTemplate (
Configuration.java:489)
>>
>> I have studied the struts2-config-browser-plugin and I'm now starting to
>> wonder if there is some magic with respect to the freemarker folder being
>> called config-browser which happens to be the same namespace of the plugin.
>>
>> Does anyone know the mechanics of these names?
>>
>> Peace,
>> Scott
>> --
>> View this message in context: http://www.nabble.com/Plug-in-creation-and-freemarker-page-location-tp24522925p24522925.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd

Attachment:
user_200823.ezm (zipped)I am trying to "sell" the idea of using Struts 2 to my employer, and I
know these questions will come up:
1. Who is using it?
2. How does it perform, compared to plain servlets and jsps?
3. How well does it scale?
4. Has anyone benchmark it under load? numbers?
2-4 are somewhat related. I am sure many of you have gone through this
before, so if you can share some info with me I would appreciate it
(believe it or not I haven't built a production application with
struts 2 yet)
thanks
musachy
--
"Hey you! Would you help me to carry the stone?" Pink Floyd

Attachment:
user_200833.ezm (zipped)On Thursday 16 July 2009 07:12:25 pm Musachy Barroso wrote:
> I am trying to "sell" the idea of using Struts 2 to my employer, and I
> know these questions will come up:
>
> 1. Who is using it?
> 2. How does it perform, compared to plain servlets and jsps?
> 3. How well does it scale?
> 4. Has anyone benchmark it under load? numbers?
>
> 2-4 are somewhat related. I am sure many of you have gone through this
> before, so if you can share some info with me I would appreciate it
> (believe it or not I haven't built a production application with
> struts 2 yet)
>
> thanks
> musachy
I could be wrong, but aren't quite a few Atlassian tools built with either
struts 2 or webwork? I remember a few months back Al Sutton worked on a high-
traffic site for selling Android Apps... http://andappstore.com ?
Also, wasn't roller moved to struts 2 a while ago? I think, if I remember
correctly, that means the blogs on http://blogs.sun.com/ are powered by
struts2. You might want to verify, but those are the ones I remember off the
top of my head.
-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

Attachment:
user_200824.ezm (zipped)Haroon Rafique wrote:
> We like to test against the complete struts context include the relevant
> interceptor stack. This gives us the ability to test for all kinds of
> combinations of compelte and partially incomplete input.
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

Attachment:
user_200829.ezm (zipped)On Thursday 16 July 2009 07:14:30 pm Dave Newton 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
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

Attachment:
user_200839.ezm (zipped)Hi all,
while i do selenium tests and i do prefer it for integration tests,
i'm feeling obligated to point out one disadvantage,
while being very easy and fun to write or record,
they tend to take a lot more time to run in comparison to unit tests.
My case is tons of selenium tests which takes about 45 minutes when
run in paralel.
But that's just my case which is very special,
i test whole stories on many apps at the same time.
On the pros side i have confidence that all my business processes are
doing well.
Best greetings,
Paweł Wielgus.
2009/7/17 Wes Wannemacher <wesw@(protected)>:
> On Thursday 16 July 2009 07:14:30 pm Dave Newton 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
>
> --
> 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-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment:
user_200840.ezm (zipped)JWebUnit integrates? nicely with eclipse. I fall in the?'unit tests are for small? units' group.
If your validation is configured wrong you won't fix it in the action so you are not really unit
testing the action at that point. I prefer separate JUnit unit tests and JWebUnit tests to test
the whole enchilada.
Chris
-----Original Message-----
From: Wes Wannemacher <wesw@(protected)>
To: Struts Users Mailing List <user@(protected)>
Sent: Fri, Jul 17, 2009 10:59 am
Subject: Re: unit testing Struts2 application (with Spring and Hibernate)
On Thursday 16 July 2009 07:14:30 pm Dave Newton 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
--
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-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment:
user_200827.ezm (zipped)Hi,
I think this link can help.
http://jira.opensymphony.com/browse/XW-670
Aloha,
Rafael Sobral
Milan Milanovic wrote:
>
> I'm sorry, but I finally got what is the problem. I'm sending in this
> thread and I want people on the list know what I have find. It very bad
> that nobody from Struts team want to help with this simple problem and
> that people get stuck with their projects for weeks because of such
> things. It is not acceptable in real-world use.
>
>
> Jim Kiley <jhkiley@(protected):
> It is possible that sending your complete step-by-step development
> process
> as responses to yourself on the mailing list is not the most productive
> way
> to solve this problem.
>
> On Wed, May 21, 2008 at 10:50 AM, Milan Milanovic
> wrote:
>
>> No, Struts 2 only support MM/dd/yyyy date format and accepts it, when I
>> change to dd.MM.yyyy I got that error:
>>
>> ERROR
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204 -
>> ParametersInterceptor - [setParameters]: Unexpected Exception caught
>> setting...
>>
>> --
>> Thx.
>>
>> Milan Milanovic wrote:
>> Yes, this was the same problem with too. All dates must be in this format
>> to work: MM.dd.yyyy! How can I change this ?
>>
>> I tried with displayFormat attribute and to define it in
>> package.properties, but it doesn't work. Can this be done for complete
>> application ?
>>
>> --
>> Thx in advance, milan Milanovic
>>
>>
>> Milan Milanovic wrote:
>> The wierd thing, even if my date is wrote in dd.MM.yyyy format in
>> textfield, if I enter date in dd/MM/yyyy format then it works without
>> this
>> error ?
>>
>> What is the problem ? Maybe the same problem is with datetimepicker ?
>>
>> --
>> Thx in advance, Milan
>>
>> Milan Milanovic wrote:
>> Regarding this theme:
>> http://www.nabble.com/-Struts-2--Datetimepicker-tag-Bug--%21-td17322058.html
>>
>> I must reply in this way, because when I give reply to the message above
>> struts mailing list returns that my e-mail is SPAM?!
>>
>> No, the thing is very simple. I have in my jsp that is
>> connected to Date object in my action class, as it is shown in Struts
>> documentation, but I still got that error. No, I have set displayFormat
>> attribute like this: displayFormat="dd.MM.yyyy", and it read good from
>> my Date object in action class, but when I sumbit the form it
>> generates that ParametersException ERROR. It seems that Struts 2 doesn't
>> know
>> how to convert String value from to Date field. I tried
>> everything! Even 3 different browsers, multiple locale settings, etc.
>>
>> I now tried to do the same thing but with , in this way, I defined in
>> package.properties:
>>
>> format.date = {0,date,dd.MM.yyyy}
>>
>> and then I my .jsp page:
>>
>>
>>
>>
>>
>>
>>
>>
>> And it reads good my date (of type
java.util.Date from action class)
>> field,
>> but when I submit the form I got the same error:
>>
>> ERROR
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204 -
>> ParametersInterceptor - [setParameters]: Unexpected Exception caught
>> setting
>> 'date' on 'class com.myProject.test.MyAction: Error setting expression
>> 'date' with value '[Ljava.lang.String;@(protected)'
>>
>> I have get/set methods for date, and everything else works fine. What is
>> the problem with Date conversion in this Struts 2.0.1.11 ?
>>
>> --
>> Please help!
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
>
> --
> Jim Kiley
> Technical Consultant | Summa
> [p] 412.258.3346 [m] 412.445.1729
> http://www.summa-tech.com
>
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_200830.ezm (zipped)I agree that date conversion is a real problem for S2, especially in multi
lingual applications.
We¹ve had to implement our own converter which either looks for a format
value with the date string or picks up a list of default prioritised date
formats and tries each one successively until success or failure with all.
Ideally it would be good if we could configure S2 out of the box (so to
speak) to perform the same functionality. By that I mean that in struts.xml
or by convention file you could specify locale or a comma separated list of
date formats to try for both short (date only) and long (date and time)
values.
Z.

Attachment:
user_200831.ezm (zipped)
Hi,
I want to round a value during an interation:
------------------------------------------
<s:sort comparator="mapComparator" source="statsMap">
<s:iterator>
<tr>
<td><s:property value="key.name" /><br>(Min: <s:property value="key.min"
/>, Max: <s:property value="key.max" />)</td>
<td>
<s:set name="average" value="value.average" />
<%
int val = 0;
%>
<s:property value="val" />
</td>
</tr>
</s:iterator>
</s:sort>
------------------------------------------
As you can see, I iterate over a map. The value element of the map contains
a field named "averate". This average is a Float which I want to round
(Math.round()). I don't really know how to do that. I can find out how to
access the value from within <% %>. Once I have access to it, how can I
print that value? I never actually used <% %> tags.
Or ist there an easier way?
The whole idea if this code is to display ratings of serveral criteria where
a rating has a minimum value of key.min, a maximum of key.max and the
average rating is value.average. I want these values to be displays using
star icons. I am telling you this hoping there is a much easier way ;)
cu
mathias
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_200835.ezm (zipped)2009/7/17 mathias-ewald <nitehoaxxer@(protected)>:
> I want to round a value during an interation:
Maybe it will be better to prepare a list on server side with rounded
values and iterate over them?
Regards
--
Lukasz
http://www.lenart.org.pl/
http://dailylog.lenart.org.pl/
Pablo Picasso - "Computers are useless. They can only give you
answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html

Attachment:
user_200837.ezm (zipped)
I don't think so - I want the exact value to be shown, too, so it's more a UI
thing.
Lukasz Lenart wrote:
>
> 2009/7/17 mathias-ewald <nitehoaxxer@(protected)>:
>> I want to round a value during an interation:
>
> Maybe it will be better to prepare a list on server side with rounded
> values and iterate over them?
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
> http://dailylog.lenart.org.pl/
>
> Pablo Picasso - "Computers are useless. They can only give you
> answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_200841.ezm (zipped)2009/7/17 mathias-ewald <nitehoaxxer@(protected)>:
> I don't think so - I want the exact value to be shown, too, so it's more a UI
> thing.
As you thing, but that's the business logic and even such simple
operation shouldn't be performed in UI. Maybe it will be simpler to
create TransferObject with original value and rounded value and put it
on the list.
Regards
--
Lukasz
http://www.lenart.org.pl/
http://dailylog.lenart.org.pl/
Pablo Picasso - "Computers are useless. They can only give you
answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html

Attachment:
user_200834.ezm (zipped)Hi Robin,
Select tag expects an list object in the list attribute but in your
case you are providing an Map that's why it is not behaving correctly.
I suggest create an object called UserType with two fields id and name. And
put these objects into a list (lets say usertypes). Now use following tag to
display a select box.
<s:select name="userTypes" headerKey="-1" theme="ajax"
headerValue="-- Please Select --" list="#application.usertypes" listKey="id"
listValue="name" label="Select User Type"/>
Hope it will help you.
Regards,
Nitesh Jain
-----Original Message-----
From: Robin Mannering [mailto:robin@(protected)]
Sent: 16 July 2009 20:36
To: Struts Users Mailing List
Subject: Freemarker and Select Tag
Hello,
Platform : Struts 2, EJB 3.0, Glassfish 2.1
I'm having trouble using the Freemarker equivalent of the JSP Struts 2
Select Tag.
I need to convert:
<s:select list="application.userTypes" />
into the Freemarker equivalent.
userTypes is an application defined attribute. I have checked the
existence of the attribute within the page and it is shown as expected.
My List/Map is defined as
Map<Integer, String> userTypes = new HashMap<Integer, String>();
userTypes.put(1, "AGENCY_USER");
userTypes.put(2, "SHOP_USER");
userTypes.put(3, "TOUR_OPERATOR_USER");
I have tried the following, none of which work (or work correclty).
<@(protected)
the select box, but are valued as 1=AGENCY_USER, 2=SHOP_USER
The following produce empty select boxes (or errors)
<@(protected)"/>
<@(protected)}"/>
Does anybody have any ideas ?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment:
user_200836.ezm (zipped)Hi,
I have also implemented login mechanism but I have used Servlet
filter to check the user login status.
I have applied filer on the restricted URI of my application by just a small
configuration in web.xml.
Regards,
Nitesh Jain
-----Original Message-----
From: Robin Mannering [mailto:robin@(protected)]
Sent: 17 July 2009 01:18
To: Struts Users Mailing List
Subject: Re: Login with Struts2
Hi,
I recently implemented a login mechanism but did it slightly differently
after recommendations from this mailing list to use an interceptor.
Each action/page that requires a validated login is directed via a
Interceptor.
The sole purpose of the interceptor is to verify the existence of an
object in the session. Here is the guts of the method:
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext ac = invocation.getInvocationContext();
Map session = ac.getSession();
// retrieve the login status from the session by key name.
User user = (User) session.get(Constants.USER_SESSION_SCOPE);
// if the user object is non null, the user is logged in.
if (user != null) {;
return invocation.invoke();
}
return "notLoggedIn";
}
It is then necessary to create a new interceptor stack:
<interceptor-stack name="my.validationWorkflowStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="amr.validation"/>
</interceptor-stack>
I also defined a global-result as follows to take care of directing the
client when not logged in.
<global-results>
<result name="notLoggedIn" type="redirectAction">
<param name="actionName">showLogin</param>
</result>
</global-results>
Finally, here is an example of a protected action using the new
interceptor stack:
<action name="showControlPanel">
<!-- Include our validation stack to ensure user is logged
in -->
<interceptor-ref name="my.validationWorkflowStack"/>
<result type="freemarker">/controlPanel.ftl</result>
</action>
You then simply need a regular action to take of the "login" which will
place a valid object/flag in the session.
Hope this helps
mathias-ewald wrote:
> Hi,
>
> I am trying to implement a login mechanism. I will now explain what I did
> and what error I get but in case there is a more sophisticated way to do
> that - please tell me!
>
> I created a BaseAction which is the parent of all my Actions. The
BaseAction
> is supposed to be responsible for displaying a login page if there is no
> User object in session scope. Then the login form should put the username
> and password into the BaseAction. The BaseAction then tries to find a
match
> in the database and places the User object into session scope:
>
> ---------------------
> public abstract class BaseAction {
>
> private String username;
>
> private String password;
>
> protected Log log;
>
> private Boolean loginStatus;
>
>
> public String execute() {
> if(log == null) {
> log = LogFactory.getLog(getClass());
> }
>
> if(isProtected()) {
> Map<String, Object> session =
ActionContext.getContext().getSession();
> Object o = session.get("user");
> if(o instanceof User) {
> loginStatus = true;
> } else {
> return "login";
> }
> }
>
>
> return executeAction();
> }
>
>
> public abstract String executeAction();
>
> public abstract Boolean isProtected();
>
>
> public Boolean getLoginStatus() {
> return loginStatus;
> }
>
> public void setLoginStatus(Boolean loginStatus) {
> this.loginStatus = loginStatus;
> }
>
> public String getUsername() {
> return username;
> }
>
> public void setUsername(String username) {
> this.username = username;
> }
>
> public String getPassword() {
> return password;
> }
>
> public void setPassword(String password) {
> this.password = password;
> }
> }
> ---------------------
>
> An Action that wants to be password protected must implement
#isProtected()
> to return "true". This is my JSP file that is shown if #isProtected() ==
> true and there's no User in session scope:
>
> ---------------------
> ...
> <s:form>
> <s:textfield label="Username"
name="userData.username"></s:textfield>
> <s:password label="Password" name="userData.password"></s:password>
> <s:submit></s:submit>
> </s:form>
> ...
> ---------------------
>
> This is the error I get
>
> ---------------------
> 20:35:42,179 WARN OgnlValueStack:49 - Error setting value
> ognl.OgnlException: target is null for setProperty(null, "password",
> [Ljava.lang.String;@(protected))
> at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651)
> at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
> at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
> at ognl.SimpleNode.setValue(SimpleNode.java:246)
> at ognl.ASTChain.setValueBody(ASTChain.java:172)
> at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
> at ognl.SimpleNode.setValue(SimpleNode.java:246)
> at ognl.Ognl.setValue(Ognl.java:476)
> ...
> ---------------------
>
>
> Why is that happening?
>
> cu
> mathias
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.387 / Virus Database: 270.13.16/2240 - Release Date: 07/15/09
17:58:00
>
>