Re: read the source code
debugging is a great tool to understanding code. try to debug the blank application bundled with struts. Put a breakpoint in Dispatcher.serviceAction (double check name, off the top of my head) and debug all the way down. There is also some tools that generate sequence diagrams at runtime, but they are kind of hard to set up. musachy On Wed, Oct 28, 2009 at 7:20 PM, Wendy Smoak wrote: > On Wed, Oct 28, 2009 at 6:50 PM, mark lu wrote: >> Thank you very much for your reply! >> I have read some code of xwork.however,i am a littel lazy,so i want to find >> a book to introduce . >> now that there is no book,I'll follow what you said. > > It would be great if you could write up your experience as you explore > the source code. Maybe you'll write that book you're looking for, :) > or a series of blog posts would be fabulous. > > -- > Wendy > > - > 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: Getting result of JSP before sending to client
you can use the embeddedjsp plugin to process a jsp as a template library without using the container. another alternative is to create your own filter and create a response object which will have a writer to capture what is written to it, so you can modify it and then write it to the real output stream. Can you tell us what you are trying to do? maybe you don't need a jsp and could use freemarker or velocity. musachy On Wed, Oct 28, 2009 at 6:28 PM, Steven Yang wrote: > Hi > > I am wondering is there a way in Struts2 to get the result of JSP before > returning the composed HTML back to client? > > for example > > public String execute() { > ...do my logic and prepare my data > > ...then using the data, compose a HTML file from existing jsp > > ... then i need to save the HTML file somewhere > > ...then > return SUCCESS; --> maybe to same HTML or other JSP > } > > Thanks > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: read the source code
On Wed, Oct 28, 2009 at 6:50 PM, mark lu wrote: > Thank you very much for your reply! > I have read some code of xwork.however,i am a littel lazy,so i want to find > a book to introduce . > now that there is no book,I'll follow what you said. It would be great if you could write up your experience as you explore the source code. Maybe you'll write that book you're looking for, :) or a series of blog posts would be fabulous. -- Wendy - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: read the source code
Thank you very much for your reply! I have read some code of xwork.however,i am a littel lazy,so i want to find a book to introduce . now that there is no book,I'll follow what you said. Wes Wannemacher wrote: > > As far as I know, there are no books that specifically analyze the > source code for Struts 2. I would suggest starting by reading the > source code to Xwork. To really get a handle on what is going on, > first try to get a solid understanding of the command pattern design > pattern. Then, take a look at the xwork source to see how it is > implemented there. Once you feel comfortable at that level, take a > good look at the Servlet and JSP specifications. Then you can take a > look at the source for Struts 2. It also wouldn't hurt to take a look > at Google Guice. Although we aren't using Guice, we branched it early > on and have been using it for internal dependency injection (both in > Xwork and in Struts 2). > > As you get further along, feel free to post questions on the > d...@struts.apache.org list. > > -Wes > > On Wed, Oct 28, 2009 at 3:09 AM, mark lu wrote: >> >> I want to read struts2's source code,but i found it's too complicated. >> so,i want to find a book that analysis the soure code. >> who can give me some suggestions?recommend some books to me? >> thanks very much!! >> -- >> View this message in context: >> http://www.nabble.com/read-the-source-code-tp26090230p26090230.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 >> >> > > > > -- > Wes Wannemacher > > Head Engineer, WanTii, Inc. > Need Training? Struts, Spring, Maven, Tomcat... > Ask me for a quote! > > - > 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/read-the-source-code-tp26090230p26105034.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
Getting result of JSP before sending to client
Hi I am wondering is there a way in Struts2 to get the result of JSP before returning the composed HTML back to client? for example public String execute() { ...do my logic and prepare my data ...then using the data, compose a HTML file from existing jsp ... then i need to save the HTML file somewhere ...then return SUCCESS; --> maybe to same HTML or other JSP } Thanks
Re: Convention Plugin - Setting dynamic parameter values
On Friday 16 October 2009 19:29:05 Musachy Barroso wrote: > when you declare a result using annotations, the param values can > contain OGNL values, just like in xml,: > > @Action(value="/different/url", > result...@result(name="success", type="httpheader", > params={"status", "%{status}", "errorMessage", "%{error}"})} > ) > public String execute() { > return SUCCESS; > } Is this true only for result annotations, or does this apply to other annotations as well? > > > > I'm tying to define a stream result using the convention plugin. The > > values for the contentLength and inputName require dynamic values. For future reference. providing a getContentLength() and getInputName() method works as well. Regards - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: [S2] Jsp not loading bean from superclass static method
Lukasz: > struts.ognl.allowStaticMethodAccess=true I will try that. Neil -- Neil Aggarwal, (281)846-8957, http://www.JAMMConsulting.com CentOS 5.4 KVM VPS $55/mo, no setup fee, no contract, dedicated 64bit CPU 1GB dedicated RAM, 40GB RAID storage, 500GB/mo premium BW, Zero downtime - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] Jsp not loading bean from superclass static method
You have to define constant as below in struts.xml or in struts.properties - from some version is set to false by default struts.ognl.allowStaticMethodAccess=true Regards -- Lukasz http://www.lenart.org.pl/ http://dailylog.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
[S2] Jsp not loading bean from superclass static method
Hello: I jut upgraded from Struts 2.0.14 to 2.1.8 and noticed I am now getting this error: SEVERE: Servlet.service() for servlet jsp threw exception The requested list key 'accountManagerMap' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} I have this in my JSP code: The method getAccountManagerMap is in a superclass and is static. This worked fine in 2.0.14, did something change in 2.1.8? Thanks, Neil -- Neil Aggarwal, (281)846-8957, http://www.JAMMConsulting.com CentOS 5.4 KVM VPS $55/mo, no setup fee, no contract, dedicated 64bit CPU 1GB dedicated RAM, 40GB RAID storage, 500GB/mo premium BW, Zero downtime - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: deserializable ActionSupport
2009/10/28 Musachy Barroso : > The people who made that decision are by now long gone, and I can't > think of any good reason myself. As I know, ActionSupport is a part of XWork (common purpose action framework) that is used by example in WebLogic 8.1 to manage multiple tasks with WorkManager - they can be queued and distributed over the network - maybe that was the reason Regards -- Lukasz http://www.lenart.org.pl/ http://dailylog.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: deserializable ActionSupport
The people who made that decision are by now long gone, and I can't think of any good reason myself. musachy On Wed, Oct 28, 2009 at 7:26 AM, Greg Lindholm wrote: > I believe the short answer is you can ignore this warning. If really > inclined you could create your own base class that extends from > ActionSupport and implements readObject(). > > It's very common in web frameworks to use Serializable objects for a couple > or reasons, such as being able to preserve state across a server restart and > for shipping objects around in a cluster. > > With that said, (IMHO) I believe it was a design mistake to have > ActionSupport implement Serializable. I don't believe that either of the > above really apply to Action objects since they are short-lived. The choice > of making Actions Serializable should have been left to the developer and > not "forced" by the framework. > (Of course I realize that no one is truly forced to use ActionSupport and > you can reimplement your own version that is not Serializable, but why > should you need to.) > > Any committers care to comment on the reasons for having ActionSupport > implement Serializable? > > > On Wed, Oct 28, 2009 at 1:11 AM, Lee Clemens wrote: > >> Hello, >> >> I (my IDE) noticed a warning showing that my Struts 2 Actions (they extend >> com.opensymphony.xwork2.ActionSupport) may be deserialized, compromising >> security. >> >> The IDE (IntelliJ 8.1) further states that the class may be deserializable >> as it supports the Serializable interface (ActionSupport does) and its >> readObject() method is not defined to immediately throw an error. >> >> Please excuse my naivety or if this is off-topic, but is this safe? >> Furthermore, how can I override the readObject() method as suggested and >> throw an error without compromising functionality within Struts? >> >> As an aside, if this warning can safely be addressed, why doesn't >> ActionSupport override readObject() to avoid this? >> >> Thanks, >> Lee >> >> >> >> - >> 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: deserializable ActionSupport
I believe the short answer is you can ignore this warning. If really inclined you could create your own base class that extends from ActionSupport and implements readObject(). It's very common in web frameworks to use Serializable objects for a couple or reasons, such as being able to preserve state across a server restart and for shipping objects around in a cluster. With that said, (IMHO) I believe it was a design mistake to have ActionSupport implement Serializable. I don't believe that either of the above really apply to Action objects since they are short-lived. The choice of making Actions Serializable should have been left to the developer and not "forced" by the framework. (Of course I realize that no one is truly forced to use ActionSupport and you can reimplement your own version that is not Serializable, but why should you need to.) Any committers care to comment on the reasons for having ActionSupport implement Serializable? On Wed, Oct 28, 2009 at 1:11 AM, Lee Clemens wrote: > Hello, > > I (my IDE) noticed a warning showing that my Struts 2 Actions (they extend > com.opensymphony.xwork2.ActionSupport) may be deserialized, compromising > security. > > The IDE (IntelliJ 8.1) further states that the class may be deserializable > as it supports the Serializable interface (ActionSupport does) and its > readObject() method is not defined to immediately throw an error. > > Please excuse my naivety or if this is off-topic, but is this safe? > Furthermore, how can I override the readObject() method as suggested and > throw an error without compromising functionality within Struts? > > As an aside, if this warning can safely be addressed, why doesn't > ActionSupport override readObject() to avoid this? > > Thanks, > Lee > > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: read the source code
As far as I know, there are no books that specifically analyze the source code for Struts 2. I would suggest starting by reading the source code to Xwork. To really get a handle on what is going on, first try to get a solid understanding of the command pattern design pattern. Then, take a look at the xwork source to see how it is implemented there. Once you feel comfortable at that level, take a good look at the Servlet and JSP specifications. Then you can take a look at the source for Struts 2. It also wouldn't hurt to take a look at Google Guice. Although we aren't using Guice, we branched it early on and have been using it for internal dependency injection (both in Xwork and in Struts 2). As you get further along, feel free to post questions on the d...@struts.apache.org list. -Wes On Wed, Oct 28, 2009 at 3:09 AM, mark lu wrote: > > I want to read struts2's source code,but i found it's too complicated. > so,i want to find a book that analysis the soure code. > who can give me some suggestions?recommend some books to me? > thanks very much!! > -- > View this message in context: > http://www.nabble.com/read-the-source-code-tp26090230p26090230.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 > > -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: RE: Adding Json to existing action
Hi, whis is the mapping for the action as it is currently used in the application. No json here: /jsp/crr_Asset_Calendar_Daily_Report.jsp This is the mapping I have created which points to the same action but with json enabled: jsonData The only method I have added to the action is this: public String getJsonData() throws Exception { return getDailyAssetUtilizationReport(); } Do you need any additional information? Original-Nachricht > Datum: Tue, 27 Oct 2009 13:00:42 -0700 > Von: Musachy Barroso > An: Struts Users Mailing List > Betreff: Re: RE: Adding Json to existing action > can you show us your action mapping and the relevant parts of your code? > > musachy > > On Tue, Oct 27, 2009 at 8:50 AM, Michael Varlik wrote: > > I just noticed a mistake I made. When adding the parameter to the result > I also have to add a getJsonData() method to the action, right? > > I have added this method which actually calls execute(). Now I don't get > "null" as a result anymore but I get "success" which is also not what I > expected. > > > > I guess I have missed something. Since this is the first time I use > struts, I have no idea what I did wrong. Any hints are appreciated. > > > > Cheers, > > Markus > > > > Original-Nachricht > >> Datum: Tue, 27 Oct 2009 16:09:25 +0100 > >> Von: "Michael Varlik" > >> An: "Struts Users Mailing List" , > user@struts.apache.org > >> Betreff: Re: RE: Adding Json to existing action > > > >> Thanks for that hint. I have extended my mapping by adding " >> name=root>jsonData" to my action mapping's result tag. Now I > don't get any > >> Exception and the server log looks just fine. However, the value > returned > >> by the action is just "null". > >> Do you have any idea what could be wrong here? > >> > >> Cheers, > >> Markus > >> > >> Original-Nachricht > >> > Datum: Tue, 27 Oct 2009 09:39:01 -0400 > >> > Von: "Mike Baranski" > >> > An: "\'Struts Users Mailing List\'" > >> > Betreff: RE: Adding Json to existing action > >> > >> > I do this to pass parameters, using prototype js: > >> > > >> > > >> > > >> > > >> > > >> > > >> > name="door.id" > >> > value="door.id"/> > >> > id="%{#form_name}" > >> > onsubmit="return false;"> > >> > > >> > > >> > >> > value="/pages/door-control/images/locked.png" /> > >> > >> > src="%{locked_image}" onclick="%{'new Ajax.Updater(\\'' + #foo +'\\', > >> \\'' > >> > + > >> > #door_url + '\\', {evalScripts: true}); return false;'}"/> > >> > > >> > > >> > > >> > > >> > >-Original Message- > >> > >From: Struts Two [mailto:struts...@yahoo.ca] > >> > >Sent: Tuesday, October 27, 2009 9:24 AM > >> > >To: Struts Users Mailing List > >> > >Subject: Re: Adding Json to existing action > >> > > > >> > >You can either use Json plugin or write your own customized result > type > >> > >that return JSON. > >> > > > >> > >--- On Tue, 10/27/09, Michael Varlik wrote: > >> > > > >> > >> From: Michael Varlik > >> > >> Subject: Adding Json to existing action > >> > >> To: user@struts.apache.org > >> > >> Received: Tuesday, October 27, 2009, 1:07 PM > >> > >> Hi, > >> > >> > >> > >> I need to call an existing struts action within my > >> > >> application from a > >> > >> JavaScript function. I thought it might be possible to > >> > >> create an additional entry in the struts mapping file like > >> > >> this: > >> > >> > >> > >> >> > >> class="com.mypackage.MyAction" method="getData"> > >> > >> > >> > >> > >> > >> > >> > >> and then call the action with "getDataJson.action". > >> > >> Unfortunately, when I try this a NullPointerException > >> > >> occurs in the action code. It seems, some parameters are not > >> > >> properly initialized. > >> > >> > >> > >> What I'd like to know is: what is the recommendet way of > >> > >> calling an existing action to get JSON results? Is it a good > >> > >> idea to do this at all? > >> > >> > >> > >> Cheers, > >> > >> Markus > >> > >> -- > >> > >> Neu: GMX DSL bis 50.000 kBit/s und 200,- Euro > >> > >> Startguthaben! > >> > >> http://portal.gmx.net/de/go/dsl02 > >> > >> > >> > >> > - > >> > >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >> > >> For additional commands, e-mail: user-h...@struts.apache.org > >> > >> > >> > >> > >> > > > >> > > > >> > > > >> __ > >> > >Looking for the perfect gift? Give the gift of Flickr! > >> > > > >> > >http://www.flickr.com/gift/ > >> > > > >> > > >- > >> > >To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >> > >For additional commands, e-mail: user-h...@struts.apache.org > >> > > >> > > >> > -
Re: RE: Adding Json to existing action
Hi, I already use the json plugin. I have written a new action to test the plugin and it works fine - I get my json result. But for some reason it doesn't work with the existing action (I didn't write this action). Here's what I did: * Installed the json plugin by copying it into WEB-INF/lib * Added a mapping to struts.xml which refers to the existing action but has a json result type and a different name. * Added the getJsonData() method to the action with "return execute();" in the body. Now I can call the action by it name "myJsonData.action" but it only returns "success". Original-Nachricht > Datum: Tue, 27 Oct 2009 12:56:51 -0700 (PDT) > Von: Struts Two > An: Struts Users Mailing List > Betreff: Re: RE: Adding Json to existing action > What I meant was either to use Json Plugin for struts 2. Read the > following Wiki page: > > http://cwiki.apache.org/WW/json-plugin.html > > The JSON plugin is bundled with Struts since 2.1.7. Or you can write your > customized Struts 2 Result type for JSON and register it in your > struts2.xml for use [does not make sense to do that if you are using 2.1.7+]. > > To learn how to do that, take a look at the a sample provided in struts 2 > in action. That should do it as well. > > Hope this helps. > > > > > --- On Tue, 10/27/09, Michael Varlik wrote: > > > From: Michael Varlik > > Subject: Re: RE: Adding Json to existing action > > To: "Struts Users Mailing List" > > Received: Tuesday, October 27, 2009, 3:50 PM > > I just noticed a mistake I made. When > > adding the parameter to the result I also have to add a > > getJsonData() method to the action, right? > > I have added this method which actually calls execute(). > > Now I don't get "null" as a result anymore but I get > > "success" which is also not what I expected. > > > > I guess I have missed something. Since this is the first > > time I use struts, I have no idea what I did wrong. Any > > hints are appreciated. > > > > Cheers, > > Markus > > > > Original-Nachricht > > > Datum: Tue, 27 Oct 2009 16:09:25 +0100 > > > Von: "Michael Varlik" > > > An: "Struts Users Mailing List" , > > user@struts.apache.org > > > Betreff: Re: RE: Adding Json to existing action > > > > > Thanks for that hint. I have extended my mapping by > > adding " > > name=root>jsonData" to my action > > mapping's result tag. Now I don't get any > > > Exception and the server log looks just fine. However, > > the value returned > > > by the action is just "null". > > > Do you have any idea what could be wrong here? > > > > > > Cheers, > > > Markus > > > > > > Original-Nachricht > > > > Datum: Tue, 27 Oct 2009 09:39:01 -0400 > > > > Von: "Mike Baranski" > > > > An: "\'Struts Users Mailing List\'" > > > > Betreff: RE: Adding Json to existing action > > > > > > > I do this to pass parameters, using prototype > > js: > > > > > > > > > > > > > value="%{'form_door' + door.id}"/> > > > > > > > > > name="door_description" value="getText(#foo)"/> > > > > > > > > > id="door_url" action="unlock"> > > > value="door.id"/> > > > > > method="POST" action="unlock" id="%{#form_name}" > > > > onsubmit="return false;"> > > > > > > > > > > > > > > > > > > > > > value="/pages/door-control/images/locked.png" > > /> > > > > > > > > > src="%{locked_image}" onclick="%{'new > > Ajax.Updater(\\'' + #foo +'\\', > > > \\'' > > > > + > > > > #door_url + '\\', {evalScripts: true}); return > > false;'}"/> > > > > > > > > > > > > > > > > > > > > > > >-Original Message- > > > > >From: Struts Two [mailto:struts...@yahoo.ca] > > > > >Sent: Tuesday, October 27, 2009 9:24 AM > > > > >To: Struts Users Mailing List > > > > >Subject: Re: Adding Json to existing action > > > > > > > > > >You can either use Json plugin or write your > > own customized result type > > > > >that return JSON. > > > > > > > > > >--- On Tue, 10/27/09, Michael Varlik > > wrote: > > > > > > > > > >> From: Michael Varlik > > > > >> Subject: Adding Json to existing action > > > > >> To: user@struts.apache.org > > > > >> Received: Tuesday, October 27, 2009, > > 1:07 PM > > > > >> Hi, > > > > >> > > > > >> I need to call an existing struts action > > within my > > > > >> application from a > > > > >> JavaScript function. I thought it might > > be possible to > > > > >> create an additional entry in the struts > > mapping file like > > > > >> this: > > > > >> > > > > >> > > > >> class="com.mypackage.MyAction" > > method="getData"> > > > > >> > > > > >> > > > > >> > > > > >> and then call the action with > > "getDataJson.action". > > > > >> Unfortunately, when I try this a > > NullPointerException > > > > >> occurs in the action code. It seems, > > some parameters are not > > > > >> properly initialized. > > > > >> > > > > >> What I'd like to know is: what is the > > recommendet way of > > > > >> calling an existing actio
read the source code
I want to read struts2's source code,but i found it's too complicated. so,i want to find a book that analysis the soure code. who can give me some suggestions?recommend some books to me? thanks very much!! -- View this message in context: http://www.nabble.com/read-the-source-code-tp26090230p26090230.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