Re: detecting session timeout
I use an HttpSessionAttributeListenen to get a callback when a session times out. There's a method called attributeRemoved, which gets called when something is removed from someones session. I look for a standard value (username) that should never get removed from the users session (until it either timesout, or they logout). I use this and attributeAdded to maintain a list, so I can tell who's logged in to my site. public class SessionLister implements HttpSessionAttributeListener { public void attributeAdded(HttpSessionBindingEvent ev) { // add user to static list if (ev.getName().equals(username)){ users.put(ev.getValue(), ev.getValue()); } } public void attributeRemoved(HttpSessionBindingEvent ev) { if (ev.getName().equals(username)){ log.info(SESSION LOGGED OUT OR EXPIRED: + ev.getName() + = + ev.getValue()); users.remove(ev.getValue()); } } private HashMap getList(HttpSessionEvent hse) { HttpSession session = hse.getSession(); ServletContext context = session.getServletContext(); HashMap users = (HashMap) context.getAttribute(com.app.userlist); if (users == null) { users = new HashMap(); context.setAttribute(com.bzzagent.userlist, users); } return users; } } ...then put this into your web.xml listener listener-classcom.app.SessionLister/listener-class /listener ...so you could use this to build and maintain a list of people who started the flow (put something in their session) and do something else with the user if they time out (decrement a counter, etc). Hope this helps. /kurt [EMAIL PROTECTED] wrote: We have done a similar thing with filter. You put a check in the filter to redirect to an error page if the session is not present in the request. this will also prevent a user to access the site without login in. Filters however is only available with servlet 2.3 Brati Sankar Ghosh Tata Consultancy Services Mailto: [EMAIL PROTECTED] Website: http://www.tcs.com *Khalid K. [EMAIL PROTECTED]* 04/20/2004 07:13 AM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To 'Struts Users Mailing List' [EMAIL PROTECTED] cc Subject RE: detecting session timeout You can store an attribute in session when you initially start the session Subsquent checks for that attribute on EACH request will check if that Attribute doesn't exist...session has expired or they are not logged on etc. Of course the key to this is to put a hook on RequestProcessor to run this snipt For each request...if you do this correctly...the request won't even make it to your action You can redirect them to whatever page you like... We have similar code but we use Struts 1.0 so we have extended ActionServlet and have Written the processPreProcess() (I think..that is what the method is called..can't recall the actual name) Khalid -Original Message- From: Dean A. Hoover [mailto:[EMAIL PROTECTED] Sent: Monday, April 19, 2004 8:18 AM To: [EMAIL PROTECTED] Subject: detecting session timeout Any suggestions on how to detect session timeouts? I am experimenting with extending TilesRequestProcessor (I'm using struts 1.1 and tiles). Here's an example of the kind of thing I would like to detect: I have a multipage registration process. Suppose a user gets halfway through and then goes away for some reason (lunch?). They come back and their session has timed out. This means that the data that was gathered and placed in the session on previous forms is gone. The validator framework then complains about missing data from the previous pages. I just want to put up a special page indicating that they took too long to register. I need this same basic session in a number of places, so I really need a general solution. Any ideas? Dean Hoover - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.659 / Virus Database: 423 - Release Date: 4/15/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.659 / Virus Database: 423 - Release Date: 4/15/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ForwardSourceID:NT584A DISCLAIMER: The information contained in this message is intended only and solely for the addressed individual or entity indicated in this message and for the exclusive use of the said addressed individual or entity indicated in this message (or responsible for delivery of the message to such person) and may contain legally privileged and confidential information belonging to
Re: GOING GOING GONE DYNAMIC
Jim, This is a red herring - yes you're right about it being passed into the execute method - but since the reference isn't passed anywhere else after that in the RequestProcessor then it doesn't matter what you do - all you have to do is store the ActionForm under the appropriate attribute in the Request/Session. Niall - Original Message - From: Jim Barrows [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Friday, August 06, 2004 9:44 PM Subject: RE: GOING GOING GONE DYNAMIC -Original Message- From: Michael McGrady [mailto:[EMAIL PROTECTED] Sent: Friday, August 06, 2004 1:38 PM To: Struts Users Mailing List Subject: RE: GOING GOING GONE DYNAMIC At 12:57 PM 8/6/2004, you wrote: The problem would with Java in this case, since form is passed in. you could do something like BeanUtils.copyProperties( form, DynamicActionFormFactory.createBlankForm( blah blah); and that might work better. What about the ActionMapping? If I understand you correctly... Same issue it's passed into the execute method, and therefore you can't change it, only it's internals, so you would have to do the same thing there. I'm talking specifically in the execute method, which is where I think you're trying to create the form. - 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]
Re: GOING GOING GONE DYNAMIC
At 05:54 AM 8/7/2004, you wrote: especially all the chatter about passing form references We're probably just lame, Niall, but the idea is to try something innovative on the fly. What is being discussed is a way to dispense, essentially, with the action-mapping and form-beans XML. Maybe this makes sense and maybe not. But, what makes sense is clearly related to how and to when we can change the referent of a variable. Sometimes seeking a new question is more important than seeking the answers to old questions. I really like your contribution with the Lazy code. Good work. Is there anyway to change the commons utils to accommodate making a form a map? That way you can instrument the forms. Michael - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: GOING GOING GONE DYNAMIC
At 06:00 AM 8/7/2004, you wrote: This is a red herring - yes you're right about it being passed into the execute method - but since the reference isn't passed anywhere else after that in the RequestProcessor then it doesn't matter what you do Perhaps, though, Niall, you might want to do something that is not strictly request related. Then this would not be a red herring? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: very dynamic forms
The copy I got back turned out ok. Perhaps your mail admin is using something like the anomy sanitizer and it is stripping it out. I sent the message in plain text format and when I examined the message source it was ok and all the tags were in it. I don't think anyone was very interested in the idea anyway :-) --b Michael McGrady wrote: Bryan your html did not appear on the emails. At 12:09 PM 8/6/2004, you wrote: Wouldn't it be so cool if you could take something like a graph of hibernate objects and have a form dynamically generated for u. With dhtml or something so that you could populate the whole graph in one user form ? For example a House object that had a set of rooms, each room with it's own description. The dhtm generated by the form could expand out so that the user could add an arbitrary number of rooms each with their own description. The whole thing could get filled out in a single http request. This would greatly reduce the use case for creating a house. Has anyone ever developed anything like this ? --b On Fri, 06 Aug 2004 11:54:01 -0700, Michael McGrady [EMAIL PROTECTED] wrote: How do map based forms farm the values from the request? At 09:13 AM 8/6/2004, you wrote: For me it was very painless and although there aren't lots of big killer features - there are IMO lots of little ones that make this a good upgrade. Niall - Original Message - From: Dean A. Hoover [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Friday, August 06, 2004 4:49 PM Subject: Re: very dynamic forms Thanks. I am looking at Niall's Lazy stuff, but I like your idea. I will add it to my list of investigations and experiments. I've written quite a bit to struts 1.1. Is there a downside to upgrading? Thanks. Dean Kevin A. Palfreyman wrote: Dean, I do a similar thing with Struts 1.1, and I use an ordinary struts form (a subclass of ValidatorActionForm) that has a DynaBean as one of its fields. To match this, my DTO also has the same field as a DynaBean, and we just have to be a bit more clever when we copy properties between the two. The schema of the DynaBeans are configured entirely separately from the rest of the Struts stuff, and should be fairly easily done from a DB. In an upcoming version, the shape of the DynaBeans will be determined from data from a remote corba service. Unfortunately, this is all product specific (closed source), so I can't just pass it on (it wouldn't be useful to you anyway in its current form). But it should encourage you that it can be done. From a quick read of his web page, Niall's Lazy stuff looks very promising. If I were starting again, I might have a look to see if that would fit. Good luck, Kev -Original Message- From: Dean A. Hoover [mailto:[EMAIL PROTECTED] Sent: 06 August 2004 15:47 To: Struts Users Mailing List Subject: Re: very dynamic forms What I need to do is construct a form that has a variety of text input forms on it that are determined at run-time. I know how to do this in jsp but I need to provide an ActionForm that conforms to that form. I got several useful replies last night and am investigating them. Dean Michael McGrady wrote: That makes sense, but his other comments seem to negate that. He says, e.g., that [w]hat would come out of the query would be label, form position, variable name,etc, etc.. These are things that are on the page form, not on some dynamic class handling the form. He specifically rejects dynamic class structures in fact when he says that he has worked with DynaActionForm and ActionForm and that they don't fit the bill. I think he is focusing on the idea of having changing variables on the page form and how to handle this on the backend. Is that right, Dean? Michael At 01:40 AM 8/6/2004, you wrote: I thought that I want to build one on-the-fly according to configuration stuff stored in a database, that can change. was pretty clear, especially after he pointed out the DynaActionForms weren't what he was looking for because they came from struts config. But maybe it's just me - I'm used to wondering about what (weird stuff) I can do in Struts. At 05:00 PM 8/5/2004, you wrote: Suppose I want to construct a form based on a query to a database. What would come out of the query would be label, form position, variable name, etc, etc. What would be the recommended way of building this under struts/tiles? I've been working with struts/tiles for a while now and this is the first time this sort of requirement has come up. I've used
[Info] FormBeanConfig is now the Factory for ActionForm
Since Struts 1.2.1 the FormBeanConfig has now become the factory for ActionForms. Although a relatively minor change in makes plugging in custom ActionForm creation behaviour very straight forward: * Extend FormBeanConfig and override the createActionForm() method: public class MyFormBeanConfig extends FormBeanConfig { public ActionForm createActionForm(ActionServlet servlet) { return } } * configure Struts to use your custom FormBeanConfig in struts-config.xml: form-beans type=myPackage.MyFormBeanConfig form-bean name=... /form-bean /form-beans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy Dyna: Re: GOING GOING GONE DYNAMIC
You need the commons beanutils 1.7.0 for lazy DynaBeans - its not in the 1.6.1 jar - you can get it here: http://jakarta.apache.org/site/binindex.cgi For the lazy ActionForm stuff you need the Struts nightly build, thats available here: http://cvs.apache.org/builds/jakarta-struts/nightly/ Also download the LazyActionForms from my web site here: http://www.niallp.pwp.blueyonder.co.uk/lazyforms.zip Use the jars from the Struts nightly build, except you need to replace the commons beanutils with the 1.7.0 version - plus add the jar with the lazy ActionForms. Niall - Original Message - From: Michael McGrady [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Saturday, August 07, 2004 10:05 PM Subject: Lazy Dyna: Re: GOING GOING GONE DYNAMIC At 05:54 AM 8/7/2004, you wrote: If you really want to do a dynamic form created on the fly - then do it the easy way (shameless plug), use lazy ActionForms :-) http://www.niallp.pwp.blueyonder.co.uk Niall When I download and build Struts 1.2.1 I get commons-beanutils-1.6.1.jar. However, this does not contain Lazy dyna stuff. When I download the commons-beanutils nightly, I do get the Lazy dyna stuff and also a commons-beanutils-core.java with an unnumbered commons-beanutils.jar. How does this all get put together to run the LazyDyna stuff, Nia. - 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]
Struts, checkbox and optionally displaytag
hi, guess many questions were raised on this but could not find detail enough sample code. i am looking for sample code demostrating the support of checkbox in Struts ActionForm, Action and JSP files. I am using displaytag (really good!) to generate the table with a column of checkboxes. how do i know which boxes are selected in MyAction ? many thanks lixin __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]