Re: Struts2 session concurrency issue ?
To answer, I think we need to know more about your utility program that triggers action 2. Sessions are tracked through a cookie containing a JSESSIONID. Does your utility retain cookies so that each page load will reference the same session? Also, does your utility wait for each page to complete before requesting again? You said "asynchronous" but your code does not look thread safe to me. (I have never used atomicinteger before so never mind if that class somehow handles thread safety for you) Aaron On Apr 25, 2012 5:11 AM, "Dionis Argiri" wrote: > What is the difference between using > ActionContext.getContext().getSession() vs implementing SessionAware > interface? Does it give some advantages? > > 25 апреля 2012 г. 12:01 пользователь Łukasz Lenart < > lukasz.len...@googlemail.com> написал: > > > Why don't you use SessesionAware interface ? > > > > > > Regards > > -- > > Łukasz http://www.lenart.org.pl/ > > mobile +48 606 323 122, office +27 11 0838747 > > Warszawa JUG conference - Confitura http://confitura.pl/ > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > >
Re: To create new session without invalidating existing one
This should be a whole new email thread, shouldn't it? Try naming the class variable "id" and making your method "getId". OGNL will try to make a guess what the pojo get method is and it often gets confused with all uppercase names. Aaron On Oct 3, 2011 6:34 AM, "Ganesh" wrote: > I tried setting the below hidden variable inside and outside the form. In both the case, Im not getting any value from request.getParameter. If i put inside the form then i am able to access it using form.getID. > > > > Regards > > Ganesh > > > > - Original Message - > From: "Dave Newton" > To: "Struts Users Mailing List" > Sent: Friday, September 30, 2011 6:33 PM > Subject: Re: To create new session without invalidating existing one > > >> On Fri, Sep 30, 2011 at 7:46 AM, Ganesh wrote: >> >>> Is there any way to retireve the form data using request.getParameter(); If >>> the ID is part of hidden variable then it is returning null. Any ways to >>> retrieve data without using Form object. >>> >> >> If it's part of the form, and you're setting it, but not able to retrieve >> it, it's likely you're doing something wrong. >> >> >>> First time, I will set the ID as part of the URL and my problem is the ID >>> has to be carried for every subsequet pages. How to achieve this? >>> >> >> URL rewriting. >> >> Dave >> > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
Re: Return text to jsp, plus image and imageMap from a single Data query?
The problem is really an html problem. You cannot embed an image in a web page, all you can do is embed a url reference to an image. The browser, if it is a graphical browser and not a text reader, will find that reference and execute another completely separate request for the image binary. This is the request that should trigger your binary stream, not the first request which only gets the base html for the page. Given this model, it doesn't make much sense to fetch the image from the db at the same time as the metadata you need to build the textual imagemap definition. You would either have to just throw away the binary data or else cache it in expectation of the second request. You've said the caching system doesn't work for you, so you're better off just fetching the binary image by itself, in its own dedicated action, when that seecond request comes in. - Aaron On Sep 5, 2011 6:10 AM, "AndyLaw" wrote: > > On 3 Sep 2011, at 15:07, Dave Newton-6 [via Struts] wrote: > >> Okay, so I guess my question is "Why do you want to deliver the result in >> three separate parts?" Without a clear understanding of what you're trying >> to do and why, it's difficult to answer in a helpful way. >> > > The results come back in a single hit which is defined in a JSP page. The JSP consists of a text table representation of the database results at the top of the page and a graphical clickable image of those results underneath. > > The struts1-based version of the code which I inherited has the action querying the database, drawing an image to a temporary file, which is then referenced from within the JSP. One of the problems that they had with the old version (which is being replaced for a huge number of reasons, not just this) was the management of "temporary" files broken down frequently resulting in file system chaos. I would rather avoid writing stuff to file that can be streamed and forgotten. > > I know how to get the stream returned and I can happily generate the image as a stream and return it. I don't have a clear picture in my head though about how to generate that image as a stream embedded within a JSP. > > My prototype has the jsp reference the graphic-drawing action as the source of an image. However, if I implement that, I'll need to extract the data into the action that presents the jsp text and generates the image and its source reference. I'll also need to extract the data into the action that generates the referenced image and still find a way to dump back the html imagemap coordinates and urls to make that image clickable. > > I'm clearly suffering a brain-fade here. Is the temporary file route the way to go or is there something smarter and more "self managing" that I can do? > > Later, > > Andy > > Yada, yada, yada... > > The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336 > Disclaimer: This e-mail and any attachments are confidential and intended solely for the use of the recipient(s) to whom they are addressed. If you have received it in error, please destroy all copies and inform the sender. > > > > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > > > -- > View this message in context: http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4769657.html > Sent from the Struts - User mailing list archive at Nabble.com.
Re: Where's ideal for this logic?
One possibility you could use to separate the code responsibility might be to collect your data into objects and dump those objects directly into the view as JSON, or even fetch the data AJAX style using a separate action/view. Since your chart renders are different from page to page and are being handled by javascript already, you could just dump the data straight into javascript space at the outset and handle the different chart views completely in javascript instead of in the action or the view. I don't know if this is the best way, necessarily, but I've often found that when I need lots of javascript access to application data, it helps to just get that data into JSON as soon as possible so all the cards are on the table and I'm free to add new javascript functionality without much (or any) change to the java side of the picture. - Aaron On Tue, Aug 9, 2011 at 12:36 PM, Jeff Black wrote: > Hey Chris -- Can you utilize an interceptor(s) for any of your biz-logic? > > jb > / > > From: "CRANFORD, CHRIS" > To: user@struts.apache.org > Sent: Tuesday, August 9, 2011 8:51 AM > Subject: Where's ideal for this logic? > > > I have several actions that instantiate a business service to query KPI > statistics from our database. The KPI statistics are gathered using > projection-based Hibernate queries on several domain entity objects. > We are representing the KPIs in the view using a jQuery-based chart > library. > > Does it make sense to constrain the business service layer to simply > retrieving the summary data information and leave the action class to > inspecting the summary data and generating the chart DTO objects used in > the JSP for rendering needs or would others have specialized methods in > the business service to create the chart DTO objects too really keeping > the action lean? > > There are ways to minimize code bloat regardless of where I place the > logic, but I'm looking for the most ideal place. Since each graphs > render is unique and specific to the report parameters and > configurations of that specific report, one action may simple generate a > single bar chart where the next may generate a bar chart with a spline > overlay and an additional pie chart all in a single view. > > Lastly, has anyone else looked at the library from Highcharts and have > any input, thoughts, or suggestions on your past use? > > > > > > > ----- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where to put non action associated data
If I were coding the search part, I'd probably place the secondary piece inside a searching business service. Your action would instantiate a search business service and ask it to get search results based on a query string. The business service would do that and also (based on whatever business logic you like) would do whatever extra things were appropriate. The action never knows or cares about it, and your low-level data access piece doesn't know either. It's the service layer's job to understand the complexities and related activities that go with the basic requests from the Action. My two cents. - Aaron On Sun, Jul 31, 2011 at 12:50 PM, Marcus Bond wrote: > Hi, > > > > Say I have a form where user can carry out a product search which hits an > action and returns a list of results - easy.. however in response to the > user changing their search criteria I want to also generate some search > terms which would be passed through to Ebay, google ads etc.. but not within > my action which is designed with one purpose in mind - to search my db (the > action doesn't know about google ads, ebay, AWS or any other thing that > comes along). Gut reaction here is to fire an event (say product changed) > and have some listeners do the work of generating the relevant google / ebay > stuff and storing this in the users session. > > > > Firstly, is this how most of you would go about it? > > > > Secondly in terms of the view side of things, whilst normally my action > would simply return 'success' I may want to tweak the view depending upon > which external source returned the best results (currently I use tiles but I > don't think I can or should dynamically switch the result after my action > has processed).. How would you tackle this? By adding logic to the tile / > template jsp or some other means? > > > > Can any of you share experiences of using Struts in apps like this and how > you tackled similar scenarios or if maybe another framework is more suited? > You'll have to bear with me here since all my work thus far has had no need > to collaborate data from multiple sources in one page. > > > > Regards and thanks in advance, > > Marcus > > -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Submit image button sends coordinates
You may be able to write an interceptor that strips X and Y from your cgi parameters. You would need to set the interceptor prior to the default interceptor that assigns params to your action set methods. On Jul 26, 2011 5:50 AM, "Maurizio Cucchiara" wrote: > Hi Christian, > unfortunately IIRC there is no way to avoid that OGNL tries to find the > property accessor. > > Adding this row in your log4j.xml (properties) should mute this log message > (which it should not be a warning message) > > > > > > > On 26 July 2011 11:27, Christian Grobmeier wrote: > >> Hi, >> >> using: >> > name="submit" /> >> >> Sends the following to my action: >> submit => [ Submit ] submit.x => [ 40 ] submit.y => [ 7 ] >> >> x / y are coordinates of my click, defined by w3c. Now they are sent >> to my action, and OGNL tries to set it. Which leads to: >> >> > Error setting expression 'submit.x' with value >> '[Ljava.lang.String;@a53ed8f' >> > ognl.NoSuchPropertyException: java.lang.String.x >> >> Of course, ognl, sets a string "submit", then tries to find the getX >> method on my string which does not exist. >> >> How can I deal with that? >> >> Cheers >> Christian >> >> - >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > > > -- > Maurizio Cucchiara
Re: Failed validation returns Action.NONE instead of Action.INPUT in Struts 2.2.3
The source for 2.2.3 that appears to apply to this situation can be read here: http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts.xwork/xwork-core/2.2.3/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java#144 I referenced line 144 because that's where the doIntercept method is defined, and this is where the processing logic is that returns the result string. A few lines up you can see "inputResultName" defined with a default of Action.INPUT as expected. However, inside doIntercept, that result name can be overridden by settings within the action or annotations on the action. I suspect there may be a version difference in the processing of your annotations, but I could be wrong. It looks as if, when annotations are present on an action method, the doIntercept method expects to find a result string defined with that action/method. I suppose if it's null, you'd get Action.NULL back. There's a DEBUG level log statement inside that, any time hasErrors is true, should drop a log entry about finding errors. Are you seeing that error? I don't know if struts is distributed with source included in the jar, but if so you could try setting a breakpoint in this method to see what it's thinking. You could try removing your annotation setup and wiring your actions with a struts.xml file instead? Probably a quicker check than reading through all the annotation processing code. - Aaron -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts File Upload Issue
Are you certain the action class is not being called at all? Are you logging when the action method executes to be sure? Is your user a Mac user? I have seen occasional problems with Mac files (especially fonts) having a null data fork that break the upload process. On May 26, 2011 1:01 AM, wrote: > Hi, > > > > I have a query regarding file upload functionality in Struts. I am > having a screen from where I can upload multiple files. When files are > browsed and submit button is clicked, it will first hit a filter, > validate the user and calls the action method where uploading the files > to the repository is done. It happens fine normally. But rarely when > submit is clicked in UI, it goes to the filter, validates the user and > doesn't call the action method. It fails somewhere between the filter > and the action class. It doesn't throw any exceptions from the framework > too. > > > > First we thought, it happens when big files are uploaded. Then we found > even for small files, this happens occasionally. Below is the JRE > details being used. > > Java version = J2RE 1.5.0 IBM J9 2.3 Linux x86-32 j9vmxi3223ifx-20080811 > (JIT enabled) > > > > I couldn't figure out why this is happening. Any suggestion regarding > this is most welcome. > > > > Thanks in advance, > > Vijay S > > > This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. > If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. > Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful.
Re: Struts2 Validation w/ModelDriven
Generally speaking, I don't advocate for client-side data validation (javascript) since in most cases it's intended to be used instead of server side validation, which is a Bad Thing. In this case, however, perhaps some basic client-side validation would be appropriate, just to prevent the user from submitting data that is impossible to store in your model. Then you can let server validation check the appropriateness of the data according to business rules, etc. - Aaron On Thu, May 19, 2011 at 1:16 PM, CRANFORD, CHRIS wrote: > Not that I am aware. The paramsPrepareParamsStack to my knowledge > handles validation at the very end; so by the time validation has > happened; the model has already been prepared by the prepare() method. > > -Original Message- > From: Eric Lentz [mailto:eric.le...@sherwin.com] > Sent: Thursday, May 19, 2011 11:58 AM > To: Struts Users Mailing List > Subject: Re: Struts2 Validation w/ModelDriven > >> So when this error condition is met and the user redirected back to > the > INPUT form; the >> field where they had entered "xyz" is now the original default >> initialized value. > > Can't you check the action error and not refresh the model when there is > > an error? > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Select collection not found only when validation xml file is used
On Wed, Apr 13, 2011 at 11:27 AM, Eric Lentz wrote: > Thanks for the help. My problem appears to be solved! prepare() is my > friend. One subtle gotcha you should be aware of in case it bites you later: In the default interceptor stack, the prepare method is set to execute BEFORE the params from your form are read and processed into your action class. If you are relying on those form params in your prepare method to initialize values or whatever, you may get errors that look mysterious unless you step through the whole stack. There is a separate interceptor stack, "paramsPrepareParamsStack", defined to help with this problem - it has an extra Params processor that fires before Prepare to make sure all your form data is available when Prepare runs. You can see it here: http://struts.apache.org/2.2.1/docs/struts-defaultxml.html (edit the version number to fit your implementation). The stack definition is near the end, just do a search for "paramsPrepareParams". - Aaron -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: display data of action class on jsp in struts2
You declare myList again inside create method, so the data is never stored in the class-level myList. When the jsp asks for the list, it's empty. On Mar 5, 2011 8:59 AM, "shekhar16" wrote: > > i m new to struts2,rest plugin and i m tring to retrieve data from database > through jpa and display it on jsp. > my action class successfully running and retrieving the data but unable to > show it on my jsp page.so if any body have idea about it please help me > my action class is > > [code] > > package com.action; > > import java.util.Iterator; > import java.util.List; > > import javax.persistence.EntityManager; > import javax.persistence.EntityManagerFactory; > import javax.persistence.EntityTransaction; > import javax.persistence.Persistence; > import javax.persistence.Query; > > import org.apache.struts2.convention.annotation.*; > import org.apache.struts2.rest.DefaultHttpHeaders; > > import com.opensymphony.xwork2.ActionSupport; > > @ParentPackage(value="default") > @Namespace("/") > @ResultPath(value="/") > > > public class noOfUsers extends ActionSupport { > /** > * > */ > private static final long serialVersionUID = 1L; > > private String firstname; > List myList; > > private String user; > > @SuppressWarnings("unchecked") > @Action(value="usersn",results={ > @Result(name="create",type="tiles",location="users") > }) > > public static DefaultHttpHeaders create(){ > EntityManagerFactory emf=Persistence.createEntityManagerFactory("tujpa"); > EntityManager em=emf.createEntityManager(); > EntityTransaction entr=em.getTransaction(); > entr.begin(); > Query query=em.createQuery("select u.firstname from User u "); > List myList=query.getResultList(); > System.out.println(myList); > entr.commit(); > em.close(); > return new DefaultHttpHeaders("create"); > } > > public List getMyList(){ > return myList; > } > } > > [/code ] > > > thanks in advance > -- > View this message in context: http://old.nabble.com/display-data-of-action-class-on-jsp-in-struts2-tp31075171p31075171.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 >
Re: struts2, jasper reports, nested List error
I was able to find a workaround for my problem. The solution is in two parts: 1) This blog entry from Bruce Phillips who gives a walkthrough on solving exactly this problem: http://www.brucephillips.name/blog/index.cfm/2008/7/12/Using-The-JasperReports-Struts2-Plugin-A-Main-Report-And-A-Subreport 2) Unfortunately, the tutorial only works correctly for an older version of iReport. I'm using the newest, version 4.0.0 from January 2011 and I ran into a classDef exception that I couldn't resolve when I tried to compile the report from within iReport Designer: java.lang.NoClassDefFoundError: Could not initialize class org.apache.struts2.views.jasperreports.ValueStackDataSource It is NOT complaining about finding the struts2 jasperreports plugin jar, that's already in the classpath. It's missing something else, and I couldn't figure out what. Luckily, I was able to work around this issue by compiling the report from within the Struts2 action, as described here: http://struts.apache.org/2.1.8/docs/jasperreports-tutorial.html Note that the comments in the sample code clearly (and correctly) warn against compiling on every action request, so I'll need to make sure I keep my app from executing that task every time the action runs. - Aaron On Wed, Feb 16, 2011 at 12:28 PM, Dave Newton wrote: > That it works in JSP is meaningless--the two mechanisms are nothing > alike. The error message describes exactly what the problem is; you're > passing a list, not something that JR can use. > > Tragically, I don't actually remember what I did to fix this, although > I thought I had changed the plugin to handle that. Perhaps I never > checked it in, which would be too bad, because I no longer have access > to that code :( > > Dave > > On Wed, Feb 16, 2011 at 12:11 PM, Aaron Brown > wrote: >> I'm learning how to use Jasper reports, in this case as a result from >> a Struts2 (2.1.8) web app. I'm sending a List (ArrayList) of objects >> to a report and when the case is that simple, I have things working >> just fine. >> >> Next, I need to report a hierarchy of data like this example: >> List parents; >> >> Parent: >> String name; >> List children; >> >> Child: >> String name; >> >> So I want to send the list of Parent objects to report A. This report >> includes a subreport, B, which should iterate over the list of Child >> objects for each Parent. Like: >> for (Parent p : parents) { >> for (Child c : p.children) { >> // report >> } >> } >> >> My problem is that my report, which compiles cleanly, cannot be >> "filled" by the Struts action. I instead get a stack trace about not >> being able to evaluate the expression $F{children}, and the end of the >> stack trace says: >> >> Caused by: java.lang.ClassCastException: >> org.apache.struts2.views.jasperreports.ValueStackDataSource >> incompatible with java.util.List >> >> I use hibernate and lazy loading on the back end, so I added a loop to >> pre-fetch and initialize all the "children" lists for each parent, >> just to make sure it wasn't an issue with lazy loading and sessions >> and such. The problem still occurs. >> >> I'm also making sure each "children" ArrayList is either full of data >> or initialized as an empty ArrayList, so there should not be any Null >> references. >> >> It appears from the stack trace error that Struts is not allowing >> Jasper to access the nested property of the Parent object. I'm doing >> the same kind of operation in a dozen places in .jsps, so I know my >> object model is solid. >> >> Does anyone have experience with this kind of Struts 2 reporting in >> Jasper who could lend me a hand learning how to do this? >> >> thanks, >> - Aaron >> >> -- >> Aaron Brown : aa...@thebrownproject.com >> >> - >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
struts2, jasper reports, nested List error
I'm learning how to use Jasper reports, in this case as a result from a Struts2 (2.1.8) web app. I'm sending a List (ArrayList) of objects to a report and when the case is that simple, I have things working just fine. Next, I need to report a hierarchy of data like this example: List parents; Parent: String name; List children; Child: String name; So I want to send the list of Parent objects to report A. This report includes a subreport, B, which should iterate over the list of Child objects for each Parent. Like: for (Parent p : parents) { for (Child c : p.children) { // report } } My problem is that my report, which compiles cleanly, cannot be "filled" by the Struts action. I instead get a stack trace about not being able to evaluate the expression $F{children}, and the end of the stack trace says: Caused by: java.lang.ClassCastException: org.apache.struts2.views.jasperreports.ValueStackDataSource incompatible with java.util.List I use hibernate and lazy loading on the back end, so I added a loop to pre-fetch and initialize all the "children" lists for each parent, just to make sure it wasn't an issue with lazy loading and sessions and such. The problem still occurs. I'm also making sure each "children" ArrayList is either full of data or initialized as an empty ArrayList, so there should not be any Null references. It appears from the stack trace error that Struts is not allowing Jasper to access the nested property of the Parent object. I'm doing the same kind of operation in a dozen places in .jsps, so I know my object model is solid. Does anyone have experience with this kind of Struts 2 reporting in Jasper who could lend me a hand learning how to do this? thanks, - Aaron -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Why do we need the set/push tag?
On Thu, Jan 6, 2011 at 9:41 AM, maven apache wrote: > 2011/1/6 Aaron Brown > > Well,is it the action's **responsibility to prepare the data which to be > used in the view/page? > Yes, but in some cases it's desirable to write view code (JSP, for example) which is not tied tightly to the underlying data. You may want to write a generic view that works the same for many different classes, perhaps because they're all subclasses of the same superclass, sharing several properties in common. In this scenario, you can have an action and a jsp that's specific to a subclass but factor out some of the code into a generic fragment. This only works if you can use a struts tag in the fragment without explicitly referencing its name or type, and the easiest way to accomplish that reliably is to push the desired object onto the top of the stack. You certainly don't have to do it this way. None of it is required. But this is one of many popular methodologies for creating view code that's disconnected from the underlying controllers, and struts2 has included things like the push tag to help support this kind of use. Ruby on Rails has a similar construct allowing you to reference a view fragment by passing in the default object as a parameter. Whether you choose to do it this way or not is up to you, struts's job is just to make this option possible. - Aaron -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Why do we need the set/push tag?
Generally speaking, when you use a struts tag and you do NOT specify an object, the tag will default to using the object at the top of the stack. The push tag lets you force a specific object to be at the top of the stack, so you can write generic, reusable jsp code (like fragments, etc.) that doesn't reference the object name directly and instead operates only on its generic properties. - Aaron On Thu, Jan 6, 2011 at 5:54 AM, maven apache wrote: > Hi > I am learning the struts tag,however I can't understand why we need the > set/push/bean tag? > In my opinion,the views like jsp just need to pull data from the > Actioncontext and render them. What's the advantage of pushing new data to > context? > I am using my phone to ask this question,so I can't express more,hope you > guys know what I am talking about.^_^ > -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: JSON Property
Have you considered using an include? You can call a json-result-type action with it or switch to some other fragment result if needed. Perhaps it's quick and dirty compared with creating a custom tag but it seems to me it would be a lot easier to implement. - Aaron On Jan 3, 2011 6:50 AM, "Jim Talbut" wrote: > Hi, > > I keep needing to put the JSON equivalent of an expression into a JSP page to be used by client side javascript. > This is done during the evaluation of the JSP, it's not AJAX. > > At the moment I'm doing it by creating a special "get" method on the action, but that's not nice - the action shouldn't need to know that I want the representation in JSON. > > I've started looking at creating an alternative tag to do the job, but it would be pretty much a complete copy of the property tag, but with an additional "escape"-type property to specify that the result should be JSON. > It's slightly more complicated than that because the normal escapes should be applied afterwards too. > > Question: Is this something that should be implemented in the base property tag as an enhancement to struts itself, or should I just copy the property tag and get on with my life? > > Thanks > Jim
Re: Problem with browser or Struts file upload code.
--- >>>>> public class UploadForm extends org.apache.struts.action.ActionForm { >>>>> >>>>> private static Log log = LogFactory.getLog("UploadForm"); >>>>> >>>>> private String trans_name; >>>>> private List testFile; >>>>> >>>>> public UploadForm() { >>>>> super(); >>>>> testFile = new ArrayList(); >>>>> } >>>>> >>>>> public FormFile getTestFile(int i) { >>>>> System.out.println("FormFile is: " + testFile.get(i)); >>>>> return (testFile.size()> i) ? (FormFile) testFile.get(i) : null; >>>>> } >>>>> >>>>> public List getList() { >>>>> System.out.println("List of files: " + testFile.toString()); >>>>> return testFile; >>>>> } >>>>> >>>>> public void setTestFile(int i, FormFile f) { >>>>> >>>>> if (f.getFileSize()<= 0) { >>>>> System.out.println("No file to add."); >>>>> f.destroy(); >>>>> } else { >>>>> System.out.println("Adding new file."); >>>>> testFile.add(f); >>>>> } >>>>> } >>>>> >>>>> public int getFileCount() { >>>>> System.out.println("Number of files: " + testFile.size()); >>>>> return testFile.size(); >>>>> } >>>>> >>>>> public String getTrans_name() { >>>>> System.out.println("Transcation name is: " + trans_name); >>>>> return trans_name; >>>>> } >>>>> >>>>> public void setTrans_name(String trans_name) { >>>>> this.trans_name = trans_name; >>>>> System.out.println("Set transaction name as " + this.trans_name); >>>>> } >>>>> >>>>> /** >>>>> * This is the action called from the Struts framework. >>>>> * @param mapping The ActionMapping used to select this instance. >>>>> * @param request The HTTP Request we are processing. >>>>> * @return set of errors. >>>>> */ >>>>> @Override >>>>> public ActionErrors validate(ActionMapping mapping, >>>>> HttpServletRequest request) { >>>>> ActionErrors errors = new ActionErrors(); >>>>> >>>>> if (getTrans_name() == null || getTrans_name().length()< 1) { >>>>> errors.add("error", new >>>>> ActionMessage("error.transactionName")); >>>>> } >>>>> >>>>> return errors; >>>>> } >>>>> } >>>>> >>>>> Observation: >>>>> - >>>>> 1. I can get to blank page if try to load small file (tested up to >>>>> 267MB >>>>> file) >>>>> 2. No response for larger file(trrie with 2.85GB file) >>>>> >>>>> What am I doing wrong? >>>>> >>>>> Anjib >>>>> >>>>> On 12/28/2010 3:32 PM, Dave Newton wrote: >>>>> >>>>>> Both commons-fileupload and Tomcat usually have a maximum file upload >>>>>> >>>>> size; >>>>> configure one or both. >>>>>> >>>>>> Dave >>>>>> On Dec 28, 2010 2:30 PM, "Anjib Mulepati" >>>>>> wrote: >>>>>> >>>>>>> I am writing an app to upload file using Struts 1.3.8. >>>>>>> >>>>>>> It works fine if I upload small file. But when I try to upload >>>>>>> lager(>200MB) file it doesn't response correctly. >>>>>>> For larger file my form validation get null for all field even I have >>>>>>> value in it. >>>>>>> This is happening to all browser IE,FF and chrome. >>>>>>> >>>>>>> Anjib >>>>>>> >>>>>>> >>>>>>> >>>>>>> - >>>>>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>>>>> For additional commands, e-mail: user-h...@struts.apache.org >>>>>>> >>>>>>> >>>>> - >>>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>>> For additional commands, e-mail: user-h...@struts.apache.org >>>>> >>>>> >>> - >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>> For additional commands, e-mail: user-h...@struts.apache.org >>> >>> > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Help... My url grows...
After I saw the next chunk of code you posted, it looks like it really is a namespace problem: you're referring to your action as "struts/actionName", which will continue to add "struts" subdirectory to whatever URL you're currently using. Instead, try "/struts/actionName". Alternately, and probably cleaner, if you're calling an action in the same namespace (aka subdirectory) as the current action, you don't need any prefix at all. You can just say: action="actionName" ...and leave it at that. - Aaron On Tue, Dec 14, 2010 at 4:48 PM, Ellson, Jared L wrote: > Nope... namespace didn't help... I was thinking it was maybe because I was > doing the submit via javascript but it happens when I use the it > happens also. > > > > -Original Message- > From: Aaron Brown [mailto:aa...@thebrownproject.com] > Sent: Tuesday, December 14, 2010 2:34 PM > To: Struts Users Mailing List > Subject: Re: Help... My url grows... > > Every time I've had a URL with an extra path element that I didn't > intend, it was always because I messed up the namespace for the action > - I have a bad habit of forgetting the leading "/" on my namespaces. > > I see you don't have a namespace defined for your package, that's part > of the stock package tag: > namespace="/" > ...is the typical assignment for the default package. So, something like: > > > > See if that helps. > > - Aaron > > On Tue, Dec 14, 2010 at 4:24 PM, Ellson, Jared L wrote: >> Hey anybody have a quick idea what would cause my URL to grow. >> >> First time I hit the page: >> >> http://localhost:8080//struts/locationAssign >> >> submit the page then: >> >> http://localhost:8080//struts/struts/locationAssign >> >> then submit again: >> >> http://localhost:8080//struts/struts/struts/locationAssign >> >> Here is my struts.xml: >> >> >> >> >> >> >> >> > class="gov.usbr.etas.web.struts.StrutsTestAction" method="execute"> >> /struts/test.jsp >> /struts/test.jsp >> >> > class="gov.usbr.etas.web.struts.LocationAssignAction" method="execute"> >> /struts/locationAssign.jsp >> /struts/locationAssign.jsp >> >> >> >> >> >> And my web.xml: >> >> >> struts2 >> >> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter >> >> >> >> struts2 >> /struts/* >> >> >> Thank you for your help!!! >> >> > > > > -- > Aaron Brown : aa...@thebrownproject.com > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Help... My url grows...
Every time I've had a URL with an extra path element that I didn't intend, it was always because I messed up the namespace for the action - I have a bad habit of forgetting the leading "/" on my namespaces. I see you don't have a namespace defined for your package, that's part of the stock package tag: namespace="/" ...is the typical assignment for the default package. So, something like: See if that helps. - Aaron On Tue, Dec 14, 2010 at 4:24 PM, Ellson, Jared L wrote: > Hey anybody have a quick idea what would cause my URL to grow. > > First time I hit the page: > > http://localhost:8080//struts/locationAssign > > submit the page then: > > http://localhost:8080//struts/struts/locationAssign > > then submit again: > > http://localhost:8080//struts/struts/struts/locationAssign > > Here is my struts.xml: > > > > > > > > class="gov.usbr.etas.web.struts.StrutsTestAction" method="execute"> > /struts/test.jsp > /struts/test.jsp > > class="gov.usbr.etas.web.struts.LocationAssignAction" method="execute"> > /struts/locationAssign.jsp > /struts/locationAssign.jsp > > > > > > And my web.xml: > > > struts2 > > org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter > > > > struts2 > /struts/* > > > Thank you for your help!!! > > -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2, convention plugin, websphere 6.1
Gently bringing this thread back to the topic in the subject line... Does anyone have any ideas about why my WebSphere 6.1 server would be ignoring the convention plugin and not loading any of my struts2 annotations into the context? I did see some references in the websphere patch info to fixing some broken annotation processing with respect to web services, but I'm not using any web services in this particular app (SOAP, etc.). Is this a patch that I need to apply anyway? I hadn't done it yet since it's clear my server IS processing annotations for other things like hibernate and spring (@Autowire, for example, works like a charm). Anyway, I'm stumped. -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2, convention plugin, websphere 6.1
Thanks for the quick reply. Here is my full struts.properties: = = = = = = = = = = = = = = = = = = struts.enable.DynamicMethodInvocation = true struts.devMode = true struts.convention.classes.reload = true struts.ui.theme = simple struts.convention.action.disableScanning = false struts.convention.action.packages = com.mycompany.myapp.action = = = = = = = = = = = = = = = = = = Here are the relevant snippets from log4j.xml: And yes, I have the special filter flag set in websphere config. I believe that was patched at websphere 13, and I'm patched to 11 at the moment. Struts is working - I can see the config-browser/index.action for example, and when I use xml config all my normal actions are behaving normally. So the websphere filter issue doesn't appear to be the problem in this case. Just for fun, at the end of this message, I'll append a copy of the console log that websphere generates when it loads my app. - Aaron On Wed, Nov 17, 2010 at 12:17 PM, Dave Newton wrote: > Without further information it'll be difficult to help; is devMode > turned on? Do you have DEBUG set for *everything*, or just s2 > packages, or xwork, or...? It shouldn't matter, but do you have the > WebFear filter compatibility flag set (or don't need it due to patch > level)? > -- Aaron Brown : aa...@thebrownproject.com debug log follows, sorry for any text wrapping. This log opens with the server completing its startup cycle ("open for e-business"). I then requested a url to an action configured with annotations, causing the app server to load all the app contexts. At the end of the log you can see struts processing that as an unknown action and dealing with it. [11/17/10 13:32:41:731 EST] 000a WsServerImpl A WSVR0001I: Server server1 open for e-business [11/17/10 13:32:56:715 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loading action configurations from: struts-default.xml [11/17/10 13:32:56:747 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.util.FileManager - Creating revision for URL: wsjar:file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/nw897628Node01Cell/tsbOne.ear/tsb.war/WEB-INF/lib/struts2-core-2.1.8.jar!/struts-default.xml [11/17/10 13:32:56:825 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded action configuration from: struts-default.xml [11/17/10 13:32:56:856 EST] 0019 SystemOut O INFO : com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Parsing configuration file [struts-default.xml] [11/17/10 13:32:56:856 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded type: name:xwork impl:com.opensymphony.xwork2.ObjectFactory [11/17/10 13:32:56:872 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded type:com.opensymphony.xwork2.ObjectFactory name:struts impl:org.apache.struts2.impl.StrutsObjectFactory [11/17/10 13:32:56:872 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded type:com.opensymphony.xwork2.ActionProxyFactory name:xwork impl:com.opensymphony.xwork2.DefaultActionProxyFactory [11/17/10 13:32:56:887 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded type:com.opensymphony.xwork2.ActionProxyFactory name:struts impl:org.apache.struts2.impl.StrutsActionProxyFactory [11/17/10 13:32:56:903 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded type:com.opensymphony.xwork2.conversion.ObjectTypeDeterminer name:tiger impl:com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer [11/17/10 13:32:56:903 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded type:com.opensymphony.xwork2.conversion.ObjectTypeDeterminer name:notiger impl:com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer [11/17/10 13:32:56:903 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded type:com.opensymphony.xwork2.conversion.ObjectTypeDeterminer name:struts impl:com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer [11/17/10 13:32:56:903 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded type:com.opensymphony.xwork2.util.PatternMatcher name:struts impl:com.opensymphony.xwork2.util.WildcardHelper [11/17/10 13:32:56:903 EST] 0019 SystemOut O DEBUG: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider - Loaded type:com.
Struts2, convention plugin, websphere 6.1
I've been working on implementing Struts 2.1.8 on WebSphere 6.1 and I'm having trouble with the convention plugin and annotation-based configuration. It appears that none of my struts configs are being scanned and/or processed from the annotations. Here's what I know: 1) Struts2 and WebSphere is an ugly partnership. There are lots of outstanding issues, so I'm wondering if this particular one has been solved and if there's anything I can do. 2) I know WebSphere is scanning other annotations, since my spring/hibernate annotations are working as expected. 3) Config browser tells me that my annotated packages/namespaces have no actions defined. When I load the action configs into .xml files instead, the actions are correctly loaded and working. 4) I tried tossing in some extra struts convention constants just to prod things, but no help: struts.convention.action.disableScanning = false struts.convention.action.packages = com.mycompany.myapp.action 5) This app with all its annotations is working perfectly in Tomcat, just not in WebSphere. 6) I have log4j set to DEBUG and I don't see any information about actions being defined by the convention plugin - it's as if it isn't even executing. I have a workaround - the xml config works - but would prefer to use annotations if I can. Anyone else run into this and solved it? thanks, - Aaron -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
convention plugin and unit testing
I'm using Struts 2.1.8 with the convention plugin to configure struts2 with annotations instead of xml files. When I write unit tests for actions using StrutsSpringTestCase or StrutsTestCase, it appears that the convention plugin isn't scanning my java packages for action classes when the rest of the struts framework is loaded. As a result, all the tests fail because struts doesn't know about any of my actions. Has this been fixed in more recent versions of struts2 ? Or is there a way I can explicitly cause the plugin to initiate its package scan and load up the configuration so the unit test can proceed? - Aaron -- Aaron Brown : aa...@thebrownproject.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: ObjectFactory.buildResult not correctly configuring Result instance properties
Patch submitted for bug https://issues.apache.org/struts/browse/WW-2170. Thanks for confirming the bug Don. aaron -Original Message- From: Don Brown [mailto:[EMAIL PROTECTED] Sent: Monday, September 10, 2007 10:51 PM To: Struts Users Mailing List Subject: Re: ObjectFactory.buildResult not correctly configuring Result instance properties This is a bug and will definitely be fixed for 2.1, although I think we should do something for 2.0.11. Patches are always welcome... :) Don On 9/11/07, Aaron Brown <[EMAIL PROTECTED]> wrote: > Hi, I think I have stumbled across a bug in the ObjectFactory. Has > anyone else noticed the following behavior? > > ObjectFactory.buildResult() invokes OgnlUtil.setProperties() to populate > a Result instance with a parameter map. In addition, the call to > OgnlUtil.setProperties forces exceptions to be thrown when necessary. If > an exception is thrown, it is caught by the ObjectFactory and logged > with a level of DEBUG. Further, in the ObjectFactory.buildResult() > method the following comment appears: "ognl exceptions could be thrown > and be ok if, for example, the result uses parameters in ways other than > as properties for the result object." > > However, throwing exceptions is not ok. The Ognl.setProperties method > will stop execution if an exception is thrown. As such, it is possible > that not all properties specified in the ResultConfig parameter map will > be set on the Result instance. > > For example, I am trying to set a property on a JSONResult class. > However, the ResultConfig parameter map has a 'location' property in > addition to the property in my Result action annotation. This property > is the first thing that is set, yet an error is thrown. The rest of the > properties in the map are ignored and the Result class is incorrectly > configured. > > If all you want to do is log an erroneous attempt to set a property, why > are you throwing exceptions? The OgnlUtil.internalSetProperty class will > do that for you if it told not to throw exceptions. > > Thanks, > Aaron brown > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ObjectFactory.buildResult not correctly configuring Result instance properties
Hi, I think I have stumbled across a bug in the ObjectFactory. Has anyone else noticed the following behavior? ObjectFactory.buildResult() invokes OgnlUtil.setProperties() to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary. If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object." However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. This property is the first thing that is set, yet an error is thrown. The rest of the properties in the map are ignored and the Result class is incorrectly configured. If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty class will do that for you if it told not to throw exceptions. Thanks, Aaron brown - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem in ObjectFactory.buildResult? OGNLExceptions can halt setting of valid properties
Hi, I am attempting to configure a Result implementation using the @Result class annotation. As part of this configuration I am sending in a parameters list which contains a single property. Here is my annotation and simple class file: @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) public class DealJsonAction extends ActionSupport { @SMDMethod public String getName(String client) { return "testName"; } } My problem is that the'enableSMD' property is not being set to true on the JSONResult. I have discovered this is happening because the ResultConfig object that is passed to ObjectFactory.buildResult() has a 'location' parameter in it. I am not sure where/why this location parameter is being stuck into the ResultConfig. Further, the buildResult() method calls OgnlUtil.setProperties and sets the 'throwPropertyExceptions' parameter to true. This is problematic. The JSONResult does not posses a field named 'location'. Therefore, the call to OgnlUtil.setProperties is throwing an exception when it attempts to set the location property. This exception causes the iteration over properties to stop (lines 71-77), and as a result the 'enableSMD' property is never set on the JSONResult. There is a large comment in ObjectFactory, lines 227 - 232, that comments on catching OGNL exceptions and logging them. The comment implies there is no issue catching these thrown exceptions and the code should be rethought in the future. In my case, however, the throwing of exceptions is subverting setting valid properties on the target object. I am relatively new to Struts 2, so perhaps I am simply overlooking a simple configuration step that might remove the 'location' parameter from the ResultConfig parameters map. Otherwise, it seems the handling of OGNL property setting needs some attention? Any help would be greatly appreciated. Thanks, Aaron Brown - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]