Author Login
Post Reply
user Digest 19 Jul 2009 14:44:49 -0000 Issue 8760
Topics (messages 200881 through 200889):
Re: Struts w/Ajax with Struts again
200881 by: Martin Gainty
200887 by: cpanon
200888 by: Nils-Helge Garli Hegvik
200889 by: Martin Gainty
Re: XML data in request parameter gotchas?
200882 by: Musachy Barroso
Re: unit testing Struts2 application (with Spring and Hibernate)
200883 by: musomesa.aol.com
200884 by: Pawe³ Wielgus
200886 by: Dave Newton
Re: Tags as template parameters?
200885 by: Pascal
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_200881.ezm (zipped)
better off setting it in the action
then access it thru ognl e.g.
#session.setSeeMe
http://struts.apache.org/2.0.14/docs/ognl-basics.html
if you want to see a bean described as
package package;
public class bean {
private String BeanParamName;
public void setBeanParamName(String BeanParamName){
this.BeanParamName =BeanParamName ;
}
public String getBeanParamName(){
return BeanParamName;
}
}
in your jsp use s:bean as here
<%@(protected)" %>
<html>
<body>
<s:bean name="package.bean" id="id">
<s:param name="BeanParamName">BeanParam</s:param>
<s:property value="%{BeanParamName}" /><br>
</s:bean>
</body>
</html>
http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/components/Bean.html
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: Sat, 18 Jul 2009 19:07:26 -0700
> From: cpanon@(protected)
> Subject: RE: Struts w/Ajax with Struts again
> To: user@(protected)
>
> Hi Martin
> Thank you. So I may be misunderstanding something. If I return to the Ajax call with mapping.getInputForward() for the defined input attribute of that action processing the Ajax call, should I see changes in the session objects displayed? Because before I return I set an element in the actionForm.setSeeMe("hi"), set the session.setAttribute("actionForm", modified) and I do not see it in the display. I am accessing that element with the ${seeMe} syntax. I am seeing the json results, but not what I put in the actionForm. That is what I would "organically" expect to see. Can you clarify this? tia.
>
> --- On Sat, 7/18/09, Martin Gainty <mgainty@(protected):
>
> From: Martin Gainty <mgainty@(protected)>
> Subject: RE: Struts w/Ajax with Struts again
> To: "Struts Users Mailing List" <user@(protected)>
> Date: Saturday, July 18, 2009, 9:32 PM
>
>
> ajax's responsibility is to return either json or html formatted text to innerHtml attribute of div tag identified in ajax call
>
>
>
> other activity such as refreshing session attributes would need to take place
>
> in the action class..upon return from action all tags of the jsp would re-display the content based on the refreshed state for those session attributes
>
>
>
> another strategy is to create and/or modify a jsp in the action and on return forwards to a result *which will forward to the just created or modified jsp*
>
>
> you're welcome
> 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: Fri, 17 Jul 2009 18:45:18 -0700
> > From: cpanon@(protected)
> > Subject: Struts w/Ajax with Struts again
> > To: user@(protected)
> >
> > Hello
> > I am able to use an Ajax call to a struts action and with getInputForward() get the get the data back. (With prototpye and json, very, very elegant). I am now realizing that I have cases where I want to reprocess all components, i.e. I want the actionForm to be updated and the jsp recalculated, I want the session objects to be reprocessed so my iterate tags will show the updates, etc. I understand how with getInputForward it doesnt happen. If I setAttribute(), the original value that was processed when the form first generated is all that ever shows. A simple findForward() does not force the reprocessing,ie still the original values of the actionsForm members. Is there a way to force a complete reprocessing the jsp from within an action? tia.
>
> _________________________________________________________________
> Windows Live™ Hotmail®: Search, add, and share the web’s latest sports videos. Check it out.
> http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_videos_072009&cat=sports
_________________________________________________________________
Windows Live™ SkyDrive™: Store, access, and share your photos. See how.
http://windowslive.com/Online/SkyDrive?ocid=TXT_TAGLM_WL_CS_SD_photos_072009

Attachment:
user_200887.ezm (zipped)Hi Martin
Thanks, however I havnt migrate to Struts2 yet. What I was hoping for was a technique to get all the session objects reprocessed upon return from the Ajax call. I am unclear that if I do the mapping.getInputForward(), does that force tomcat to reprocess and the jsp reprocess all the session objects? I have also tried returning from the Ajax call with a forward to the page and that doesnt force a redisplay of updated values. That should, correct, it is no different than any other usage and with the json result being stored in the header it will not matter for that processing.
--- On Sat, 7/18/09, Martin Gainty <mgainty@(protected):
From: Martin Gainty <mgainty@(protected)>
Subject: RE: Struts w/Ajax with Struts again
To: "Struts Users Mailing List" <user@(protected)>
Date: Saturday, July 18, 2009, 11:37 PM
better off setting it in the action
then access it thru ognl e.g.
#session.setSeeMe
http://struts.apache.org/2.0.14/docs/ognl-basics.html
if you want to see a bean described as
package package;
public class bean {
private String BeanParamName;
public void setBeanParamName(String BeanParamName){
this.BeanParamName =BeanParamName ;
}
public String getBeanParamName(){
return BeanParamName;
}
}
in your jsp use s:bean as here
<%@(protected)" %>
<html>
<body>
<s:bean name="package.bean" id="id">
<s:param name="BeanParamName">BeanParam</s:param>
<s:property value="%{BeanParamName}" /><br>
</s:bean>
</body>
</html>
http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/components/Bean.html
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: Sat, 18 Jul 2009 19:07:26 -0700
> From: cpanon@(protected)
> Subject: RE: Struts w/Ajax with Struts again
> To: user@(protected)
>
> Hi Martin
> Thank you. So I may be misunderstanding something. If I return to the Ajax call with mapping.getInputForward() for the defined input attribute of that action processing the Ajax call, should I see changes in the session objects displayed? Because before I return I set an element in the actionForm.setSeeMe("hi"), set the session.setAttribute("actionForm", modified) and I do not see it in the display. I am accessing that element with the ${seeMe} syntax. I am seeing the json results, but not what I put in the actionForm. That is what I would "organically" expect to see. Can you clarify this? tia.
>
> --- On Sat, 7/18/09, Martin Gainty <mgainty@(protected):
>
> From: Martin Gainty <mgainty@(protected)>
> Subject: RE: Struts w/Ajax with Struts again
> To: "Struts Users Mailing List" <user@(protected)>
> Date: Saturday, July 18, 2009, 9:32 PM
>
>
> ajax's responsibility is to return either json or html formatted text to innerHtml attribute of div tag identified in ajax call
>
>
>
> other activity such as refreshing session attributes would need to take place
>
> in the action class..upon return from action all tags of the jsp would re-display the content based on the refreshed state for those session attributes
>
>
>
> another strategy is to create and/or modify a jsp in the action and on return forwards to a result *which will forward to the just created or modified jsp*
>
>
> you're welcome
> 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: Fri, 17 Jul 2009 18:45:18 -0700
> > From: cpanon@(protected)
> > Subject: Struts w/Ajax with Struts again
> > To: user@(protected)
> >
> > Hello
> > I am able to use an Ajax call to a struts action and with getInputForward() get the get the data back. (With prototpye and json, very, very elegant). I am now realizing that I have cases where I want to reprocess all components, i.e. I want the actionForm to be updated and the jsp recalculated, I want the session objects to be reprocessed so my iterate tags will show the updates, etc. I understand how with getInputForward it doesnt happen. If I setAttribute(), the original value that was processed when the form first generated is all that ever shows. A simple findForward() does not force the reprocessing,ie still the original values of the actionsForm members. Is there a way to force a complete reprocessing the jsp from within an action? tia.
>
> _________________________________________________________________
> Windows Live™ Hotmail®: Search, add, and share the web’s latest sports videos. Check it out.
> http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_videos_072009&cat=sports
_________________________________________________________________
Windows Live™ SkyDrive™: Store, access, and share your photos. See how.
http://windowslive.com/Online/SkyDrive?ocid=TXT_TAGLM_WL_CS_SD_photos_072009

Attachment:
user_200888.ezm (zipped)The form will not be updated unless you refresh the values or the part
of the page that displays the values you want to be updated. So you
would have to "manually" do this processing some returned updated
values in a json result, or by returning the result of a "partial" jsp
which re-renders the part of the page that you want to be updated, and
then replace the existing html (using innerHTML).
Nils-H
On Sat, Jul 18, 2009 at 3:45 AM, cpanon<cpanon@(protected):
> Hello
> I am able to use an Ajax call to a struts action and with getInputForward() get the get the data back. (With prototpye and json, very, very elegant). I am now realizing that I have cases where I want to reprocess all components, i.e. I want the actionForm to be updated and the jsp recalculated, I want the session objects to be reprocessed so my iterate tags will show the updates, etc. I understand how with getInputForward it doesnt happen. If I setAttribute(), the original value that was processed when the form first generated is all that ever shows. A simple findForward() does not force the reprocessing,ie still the original values of the actionsForm members. Is there a way to force a complete reprocessing the jsp from within an action? tia.
>

Attachment:
user_200889.ezm (zipped)
apologies as i thought you were uptodate on the latest version
i assume you are implementing
public ActionForward execute(ActionMapping mapping,
ActionForm form,
ServletRequest request,
ServletResponse response)
throws Exception;
the ActionMapping mapping will call findForward which will
Return an appropriate ActionForward object that identifies the presentation page to be used to generate this response, based on the newly updated beans. Typically, you will acquire a reference to such an object by calling findForward on either the ActionMapping object you received (if you are using a logical name local to this mapping), or on the controller servlet itself (if you are using a logical name global to the application).
its important to declare local variables in Action specifically:
controller servlet creates only one instance of your Action class, and uses this one instance to service all requests. Thus, you need to write thread-safe Action classes. Follow the same guidelines you would use to write thread-safe Servlets.
Only Use Local Variables - The most important principle that aids in thread-safe coding is to use only local variables, not instance variables , in your Action class. Local variables are created on a stack that is assigned (by your JVM) to each request thread, so there is no need to worry about sharing them. An Action can be factored into several local methods, so long as all variables needed are passed as method parameters. This assures thread safety, as the JVM handles such variables internally using the call stack which is associated with a single Thread.
For each request made of the controller, the method process(HttpServletRequest, HttpServletResponse) will be called.
so keep the guts of the request processing in the Action process method
http://struts.apache.org/1.x/userGuide/building_controller.html
ActionMapping considerations:
use RequestActionMapping instead of SessionActionMapping
http://struts.apache.org/1.x/apidocs/org/apache/struts/action/RequestActionMapping.html
hth
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet ezen üzenet tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> Date: Sun, 19 Jul 2009 05:34:00 -0700
> From: cpanon@(protected)
> Subject: RE: Struts w/Ajax with Struts again
> To: user@(protected)
>
> Hi Martin
> Thanks, however I havnt migrate to Struts2 yet. What I was hoping for was a technique to get all the session objects reprocessed upon return from the Ajax call. I am unclear that if I do the mapping.getInputForward(), does that force tomcat to reprocess and the jsp reprocess all the session objects? I have also tried returning from the Ajax call with a forward to the page and that doesnt force a redisplay of updated values. That should, correct, it is no different than any other usage and with the json result being stored in the header it will not matter for that processing.
>
> --- On Sat, 7/18/09, Martin Gainty <mgainty@(protected):
>
> From: Martin Gainty <mgainty@(protected)>
> Subject: RE: Struts w/Ajax with Struts again
> To: "Struts Users Mailing List" <user@(protected)>
> Date: Saturday, July 18, 2009, 11:37 PM
>
>
> better off setting it in the action
>
> then access it thru ognl e.g.
> #session.setSeeMe
>
> http://struts.apache.org/2.0.14/docs/ognl-basics.html
>
>
>
> if you want to see a bean described as
>
> package package;
> public class bean {
>
> private String BeanParamName;
>
> public void setBeanParamName(String BeanParamName){
> this.BeanParamName =BeanParamName ;
> }
> public String getBeanParamName(){
> return BeanParamName;
> }
> }
>
> in your jsp use s:bean as here
>
> <%@(protected)" %>
>
> <html>
>
> <body>
>
> <s:bean name="package.bean" id="id">
> <s:param name="BeanParamName">BeanParam</s:param>
> <s:property value="%{BeanParamName}" /><br>
> </s:bean>
>
> </body>
>
> </html>
>
> http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/components/Bean.html
>
>
> 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: Sat, 18 Jul 2009 19:07:26 -0700
> > From: cpanon@(protected)
> > Subject: RE: Struts w/Ajax with Struts again
> > To: user@(protected)
> >
> > Hi Martin
> > Thank you. So I may be misunderstanding something. If I return to the Ajax call with mapping.getInputForward() for the defined input attribute of that action processing the Ajax call, should I see changes in the session objects displayed? Because before I return I set an element in the actionForm.setSeeMe("hi"), set the session.setAttribute("actionForm", modified) and I do not see it in the display. I am accessing that element with the ${seeMe} syntax. I am seeing the json results, but not what I put in the actionForm. That is what I would "organically" expect to see. Can you clarify this? tia.
> >
> > --- On Sat, 7/18/09, Martin Gainty <mgainty@(protected):
> >
> > From: Martin Gainty <mgainty@(protected)>
> > Subject: RE: Struts w/Ajax with Struts again
> > To: "Struts Users Mailing List" <user@(protected)>
> > Date: Saturday, July 18, 2009, 9:32 PM
> >
> >
> > ajax's responsibility is to return either json or html formatted text to innerHtml attribute of div tag identified in ajax call
> >
> >
> >
> > other activity such as refreshing session attributes would need to take place
> >
> > in the action class..upon return from action all tags of the jsp would re-display the content based on the refreshed state for those session attributes
> >
> >
> >
> > another strategy is to create and/or modify a jsp in the action and on return forwards to a result *which will forward to the just created or modified jsp*
> >
> >
> > you're welcome
> > 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: Fri, 17 Jul 2009 18:45:18 -0700
> > > From: cpanon@(protected)
> > > Subject: Struts w/Ajax with Struts again
> > > To: user@(protected)
> > >
> > > Hello
> > > I am able to use an Ajax call to a struts action and with getInputForward() get the get the data back. (With prototpye and json, very, very elegant). I am now realizing that I have cases where I want to reprocess all components, i.e. I want the actionForm to be updated and the jsp recalculated, I want the session objects to be reprocessed so my iterate tags will show the updates, etc. I understand how with getInputForward it doesnt happen. If I setAttribute(), the original value that was processed when the form first generated is all that ever shows. A simple findForward() does not force the reprocessing,ie still the original values of the actionsForm members. Is there a way to force a complete reprocessing the jsp from within an action? tia.
> >
> > _________________________________________________________________
> > Windows Live™ Hotmail®: Search, add, and share the web’s latest sports videos. Check it out.
> > http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_videos_072009&cat=sports
>
> _________________________________________________________________
> Windows Live™ SkyDrive™: Store, access, and share your photos. See how.
> http://windowslive.com/Online/SkyDrive?ocid=TXT_TAGLM_WL_CS_SD_photos_072009
_________________________________________________________________
Windows Live™ Hotmail®: Search, add, and share the web’s latest sports videos. Check it out.
http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_videos_072009&cat=sports

Attachment:
user_200882.ezm (zipped)>
> If a client is sending us XML via HTTP POST, are there any gotcha's with
> struts2?
>
I cant think of anything.
> Also, what is a great way to send test XML data using an HTTP POST; just
> populate a form field and submit it?
>
If you are submitting from a web browser, yes.
musachy
--
"Hey you! Would you help me to carry the stone?" Pink Floyd

Attachment:
user_200883.ezm (zipped)
[The standard?diclaimer that it is not a popularity contest and nothing that does the job for you is wrong.]
Would you not agree that if you are going to mock up the framework the simulation of S2 of highest fidelity is S2 itself.
IMHO?you are digging a swimming pool by the ocean to test your yatch.
I am not familiar with Selenium but anything you can do with JUnit you can do in JWebUnit since it is just
JUnit with more libraries.
I took your route or instantiating parts of S2 in standard JUnit tests and run into trouble when I moved
from 2,0,x to 2,1,x due to changes in the framework. It is a bummer when you switch versions and find
the tests are dead.
Chris
-----Original Message-----
From: Greg Lindholm <greg.lindholm@(protected)>
To: Struts Users Mailing List <user@(protected)>
Sent: Sat, Jul 18, 2009 3:00 am
Subject: Re: unit testing Struts2 application (with Spring and Hibernate)
>
> > >
> > > 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
> > th
at 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 the importance of automated testing and that with Struts
you have ability to test at the isolated pojo detail level all the way
through full blow integration testing.

Attachment:
user_200884.ezm (zipped)Hi all,
[the standard disclaimer ... ;-) ]
migrating from one version of struts to another is not a trouble for
selenium or such a tool,
actually it even helps You to be sure that the migration didn't break anything.
But You will hit the same scale of problems when You will change
layout - all selenium tests are dead,
of course one may argue that he is able to write selenium tests that way
that it will stay alive but that will be extra effort to cope with that.
Every solution have it's own set of troubles involved.
The is no better way, i think.
We can point out pros and cons of solutions we use,
so that others could make theirs decisions based on our experiences.
Best greetings,
Paweł Wielgus.
2009/7/19 <musomesa@(protected)>:
>
> [The standard?diclaimer that it is not a popularity contest and nothing that does the job for you is wrong.]
> Would you not agree that if you are going to mock up the framework the simulation of S2 of highest fidelity is S2 itself.
> IMHO?you are digging a swimming pool by the ocean to test your yatch.
> I am not familiar with Selenium but anything you can do with JUnit you can do in JWebUnit since it is just
> JUnit with more libraries.
>
> I took your route or instantiating parts of S2 in standard JUnit tests and run into trouble when I moved
> from 2,0,x to 2,1,x due to changes in the framework. It is a bummer when you switch versions and find
> the tests are dead.
> Chris
>
>
>
> -----Original Message-----
> From: Greg Lindholm <greg.lindholm@(protected)>
> To: Struts Users Mailing List <user@(protected)>
> Sent: Sat, Jul 18, 2009 3:00 am
> Subject: Re: unit testing Struts2 application (with Spring and Hibernate)
>
>
>
>>
>> > >
>> > > 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
>> > th
> at 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 the importance of automated testing and that with Struts
> you have ability to test at the isolated pojo detail level all the way
> through full blow integration testing.
>
>

Attachment:
user_200886.ezm (zipped)Paweł Wielgus wrote:
> But You will hit the same scale of problems when You will change
> layout - all selenium tests are dead,
I haven't really found that to be the case--I only rarely test deep
structure with Selenium, but instead look for the presence of specific
CSS selectors containing text etc.
That type of change is (generally) under my control, unlike a framework
change that breaks *my* tests.
Dave

Attachment:
user_200885.ezm (zipped)I just had a look at Sitemesh and it looks like what I want. There is one
thing that disturbs me, though, it looks as if sitemesh will build the page
every request, which causes quite some overhead, or am I mistaken there?
Pascal
On Fri, 17 Jul 2009 20:44:59 -0400, Wes Wannemacher <wesw@(protected)>
wrote:
> I'm on my phone so I only skimmed your message. If I read correctly,
> you should take a look at sitemesh.
>
> -W
>
> On 7/17/09, Pascal <pascal@(protected):
>> Hello list,
>>
>> in Struts2 it is possible to do something like
>>
>> <html>
>> <body>
>> <s:myMainNavigationMenu />
>>
>> <h1>A page</h1>
>> <p>Some content</p>
>> </body>
>> </html>
>>
>> This works ok, but my problem is that I have to change every single
>> page, if i would like to have a custom footer for every page, for
>> example.
>>
>> Now my question is: Is it possible to do something like this?
>>
>> <s:useTemplate name="myCommonTemplate">
>> <s:setTemplateTag name="body">
>> <h1>A page</h1>
>> <p>Some content</p>
>> </s:setTemplateTag>
>> </s:useTemplate>
>>
>> And as template definition say
>>
>> <!-- Main menu -->
>> <table>...</table>
>>
>> <s:insertTemplateTag name="body" />
>>
>> <!-- Footer -->
>> <p>This is the footer</p>
>>
>> I know it is possible to use parameters for templates, but they
>> obviously have huge limitations as I can't just put the tags there as I
>> did in my example.
>>
>> Also, I could do something like
>>
>> <s:myMainTemplate>
>> <s:param name="bodyPage" value="page1.jsp" />
>> </s:myMainTemplate>
>>
>> which I also don't want because I would have an extra (unnecessary)
page.
>>
>> So, is it possible to pass whole XML-Structures to templates? Maybe you
>> have some reasons why I shouldn't want what I'm suggesting here, I would
>> be eager to hear them! :-)
>>
>> Pascal
>>