Date UI
Hi all, Having just joined the list I am unaware if this topic has been done to death already but I was wondering what were peoples views on handling date input with Struts? I'm scanning archives right now and don't see it come up too often. If this is a little OT then please flame me. (Just kidding) Perhaps there are taglib discussion lists or jsp groups that I would be better off asking? If however you are willing to throw in your $0.02 worth please respond to either this address or the list. I will of course summarize and post back to Struts User. Are there favourite taglibs out there which are good for Dates? Do you split your dates into day, month and year fields in your HTML? How do you find is the best way to validate? I am generally allergic to Javascript which I guess limits what can be done with fancy pop-up pickers. Am open to suggestions should there be a nice robust script out there I guess. Regards Marty
RE: Date UI
Yes, I agree Javascript is at times a necessary evil. My current strategy is to rely on it as little as possible and only in situations where is does not form a structural part of the app. If someone is using a browser without Javascript support or with it turned off I need to have the app still usable. I guess that just means I am using it for bells and whistles. A date picker for example is OK but only if the plain text input is still on the page and does not depend on the script to work. You of course have to have good validity checking in the backend whether there is script or not. To give you some background, my aversion to using Javascript comes from having been forced to work on an app recently which totally depends upon Javascript for pretty much everything that is done. Every single link and form was being handled by generated scripts in each page. The resulting pages were twice the size of straight HTML, almost unreadable and if you were not using the right browser and version chances are the whole thing fell down around you. Nasty! A good example of what not to do for my way of thinking. Having had this general dislike of Javascript for a good number of years however I would like to say that the sophistication of an HTML only front-end can be pretty damn good. I have some lovely hierarchical trees (expand and contract branches etc), calendar representations etc that are completely server based with zero script on the client. It takes a bit of imagination but you can have a damn nice UI without a lot of JS. I'll hold off looking for a new career path just yet. Regards Marty -Original Message- From: Adam Hardy [mailto:[EMAIL PROTECTED] Sent: Wednesday, 8 June 2005 2:59 AM To: Struts Users Mailing List Subject: Re: Date UI On 07/06/05 12:55 Larry Meadors wrote: >>I am generally allergic to Javascript which I guess limits what can be done >>with fancy pop-up pickers. Am open to suggestions should there be a nice >>robust script out there I guess. > > > > Get over it. Like it or not, JavaScript is here to stay. Anyone who > looks at any modern framework (including Struts, JSF, and .net) and > says "Ew, JavaScript..." should consider a new career path. Sorry, but > it is just a fact of life, get used to it. > Yes sure but just make sure you don't make javascript mandatory for the user - because surfers will always use browsers (e.g. PDA, linux console) that don't do javascript. - 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]
Themes
I have a requirement to build a 'Themes' (think 'skins') capability into the UI of my Struts app and would just like to poll the list for ideas on the best way to approach such a mechanism. Multiple customers use the same app but they need to be presented with a view that meets their specific requirements. For example graphics, fonts and even layout would be specific to the user's login (actually their company/organization which is stored in the database). Now, for ease of use I guess something relying on CSS would be a way to go. Since I already use stylesheets for most HTML elements specifying a particular theme's stylesheet would not be hard. The tricky part is that I'd also like to be able to specify different jsp pages (mainly for Tiles layouts) in case I need to modify the layout beyond what is easy to do with CSS. Ultimately I may well have functionality in the app itself that is specific to a given customer so this concept should deal with handling customisation to that level well. Ideally I'd like to have a concept of an 'alternate source' directory that is used by the app to load it's jsp. i.e. the app first looks under the appropriate alternate directory for a jsp and uses the page it finds there if it exists but falls back to the standard jsp dir if there is no alternate. This would mean that I could create a theme with only those pages that need to be modified rather than copying and modifying the entire jsp source tree. If anyone has had to implement something along these lines I'd love to hear from you. What sort of mechanisms have you found work well within the structure of a Struts app? My architecture is Struts, Tiles, Spring and Hibernate if you are interested but I'm thinking that it's the Struts area that I'll be looking at mostly for this job. Are there any Struts sub-projects that touch on this sort of thing? Regards Marty
RE: Themes
Thanks for the links David. The app is already using Tiles extensively and as a result I need something that integrates well with this framework. I've had a quick read of the SiteMesh and Xkins sites and plan to download and compare the two later today. Will post back any findings. Regards Marty -Original Message- From: David G. Friedman [mailto:[EMAIL PROTECTED] Sent: Tuesday, 14 June 2005 2:58 PM To: Struts Users Mailing List Subject: RE: Themes Martin, Have you looked at any of these? a) Tiles http://struts.apache.org b) SiteMesh: http://www.opensymphony.com/sitemesh c) XKins: http://xkins.sourceforge.net/ Regards, David -Original Message- From: Martin Ravell [mailto:[EMAIL PROTECTED] Sent: Monday, June 13, 2005 8:22 PM To: Struts User Mailing List Subject: Themes I have a requirement to build a 'Themes' (think 'skins') capability into the UI of my Struts app and would just like to poll the list for ideas on the best way to approach such a mechanism. Multiple customers use the same app but they need to be presented with a view that meets their specific requirements. For example graphics, fonts and even layout would be specific to the user's login (actually their company/organization which is stored in the database). Now, for ease of use I guess something relying on CSS would be a way to go. Since I already use stylesheets for most HTML elements specifying a particular theme's stylesheet would not be hard. The tricky part is that I'd also like to be able to specify different jsp pages (mainly for Tiles layouts) in case I need to modify the layout beyond what is easy to do with CSS. Ultimately I may well have functionality in the app itself that is specific to a given customer so this concept should deal with handling customisation to that level well. Ideally I'd like to have a concept of an 'alternate source' directory that is used by the app to load it's jsp. i.e. the app first looks under the appropriate alternate directory for a jsp and uses the page it finds there if it exists but falls back to the standard jsp dir if there is no alternate. This would mean that I could create a theme with only those pages that need to be modified rather than copying and modifying the entire jsp source tree. If anyone has had to implement something along these lines I'd love to hear from you. What sort of mechanisms have you found work well within the structure of a Struts app? My architecture is Struts, Tiles, Spring and Hibernate if you are interested but I'm thinking that it's the Struts area that I'll be looking at mostly for this job. Are there any Struts sub-projects that touch on this sort of thing? Regards Marty - 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: Themes
I'm googling now for the article you mentioned since it isn't clear to me exactly where you meant. If you have a URL I'd appreciate it. This Tiles Controller looks like it is worth a good look. Regards Marty -Original Message- From: David G. Friedman [mailto:[EMAIL PROTECTED] Sent: Tuesday, 14 June 2005 4:36 PM To: Struts Users Mailing List Subject: RE: Themes Martin, If you're using tiles already, be sure to check out a tiles controller. It can insert pieces (putList) into your tile however you wish it, i.e. if the path is /members, if you set a (session?) cookie, etc. A tutorial on the capabilities of Tiles Controllers by Cedric Dumoulin which I wrote about earlier this week. The link is under the userGuide section for Tiles (at the bottom of the page). The site is in France but the tutorial is in English, if I recall correctly. I read it a year ago but it should still be relevant and current. Regards, David -Original Message- From: Martin Ravell [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 14, 2005 2:09 AM To: 'Struts Users Mailing List' Subject: RE: Themes Thanks for the links David. The app is already using Tiles extensively and as a result I need something that integrates well with this framework. I've had a quick read of the SiteMesh and Xkins sites and plan to download and compare the two later today. Will post back any findings. Regards Marty -Original Message- From: David G. Friedman [mailto:[EMAIL PROTECTED] Sent: Tuesday, 14 June 2005 2:58 PM To: Struts Users Mailing List Subject: RE: Themes Martin, Have you looked at any of these? a) Tiles http://struts.apache.org b) SiteMesh: http://www.opensymphony.com/sitemesh c) XKins: http://xkins.sourceforge.net/ Regards, David -Original Message- From: Martin Ravell [mailto:[EMAIL PROTECTED] Sent: Monday, June 13, 2005 8:22 PM To: Struts User Mailing List Subject: Themes I have a requirement to build a 'Themes' (think 'skins') capability into the UI of my Struts app and would just like to poll the list for ideas on the best way to approach such a mechanism. Multiple customers use the same app but they need to be presented with a view that meets their specific requirements. For example graphics, fonts and even layout would be specific to the user's login (actually their company/organization which is stored in the database). Now, for ease of use I guess something relying on CSS would be a way to go. Since I already use stylesheets for most HTML elements specifying a particular theme's stylesheet would not be hard. The tricky part is that I'd also like to be able to specify different jsp pages (mainly for Tiles layouts) in case I need to modify the layout beyond what is easy to do with CSS. Ultimately I may well have functionality in the app itself that is specific to a given customer so this concept should deal with handling customisation to that level well. Ideally I'd like to have a concept of an 'alternate source' directory that is used by the app to load it's jsp. i.e. the app first looks under the appropriate alternate directory for a jsp and uses the page it finds there if it exists but falls back to the standard jsp dir if there is no alternate. This would mean that I could create a theme with only those pages that need to be modified rather than copying and modifying the entire jsp source tree. If anyone has had to implement something along these lines I'd love to hear from you. What sort of mechanisms have you found work well within the structure of a Struts app? My architecture is Struts, Tiles, Spring and Hibernate if you are interested but I'm thinking that it's the Struts area that I'll be looking at mostly for this job. Are there any Struts sub-projects that touch on this sort of thing? Regards Marty - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Themes
I seem to keep coming back to the 'put' definitions in my tiles defs. Is there a way that I can insert a variable into the value at runtime? Something like: This still doesn't answer the fall-back to 'original' jsp tree idea but it would be a start. Worst case I could keep a register of the pages that have alternates for a particular theme and sub in the dir when necessary otherwise leaving it blank to grab the base 'original' version. Obviously I don't want to setup a put for every theme page. This would get out of hand awful fast. Regards Marty -Original Message- From: David G. Friedman [mailto:[EMAIL PROTECTED] Sent: Tuesday, 14 June 2005 4:36 PM To: Struts Users Mailing List Subject: RE: Themes Martin, If you're using tiles already, be sure to check out a tiles controller. It can insert pieces (putList) into your tile however you wish it, i.e. if the path is /members, if you set a (session?) cookie, etc. A tutorial on the capabilities of Tiles Controllers by Cedric Dumoulin which I wrote about earlier this week. The link is under the userGuide section for Tiles (at the bottom of the page). The site is in France but the tutorial is in English, if I recall correctly. I read it a year ago but it should still be relevant and current. Regards, David -Original Message- From: Martin Ravell [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 14, 2005 2:09 AM To: 'Struts Users Mailing List' Subject: RE: Themes Thanks for the links David. The app is already using Tiles extensively and as a result I need something that integrates well with this framework. I've had a quick read of the SiteMesh and Xkins sites and plan to download and compare the two later today. Will post back any findings. Regards Marty -Original Message- From: David G. Friedman [mailto:[EMAIL PROTECTED] Sent: Tuesday, 14 June 2005 2:58 PM To: Struts Users Mailing List Subject: RE: Themes Martin, Have you looked at any of these? a) Tiles http://struts.apache.org b) SiteMesh: http://www.opensymphony.com/sitemesh c) XKins: http://xkins.sourceforge.net/ Regards, David -Original Message- From: Martin Ravell [mailto:[EMAIL PROTECTED] Sent: Monday, June 13, 2005 8:22 PM To: Struts User Mailing List Subject: Themes I have a requirement to build a 'Themes' (think 'skins') capability into the UI of my Struts app and would just like to poll the list for ideas on the best way to approach such a mechanism. Multiple customers use the same app but they need to be presented with a view that meets their specific requirements. For example graphics, fonts and even layout would be specific to the user's login (actually their company/organization which is stored in the database). Now, for ease of use I guess something relying on CSS would be a way to go. Since I already use stylesheets for most HTML elements specifying a particular theme's stylesheet would not be hard. The tricky part is that I'd also like to be able to specify different jsp pages (mainly for Tiles layouts) in case I need to modify the layout beyond what is easy to do with CSS. Ultimately I may well have functionality in the app itself that is specific to a given customer so this concept should deal with handling customisation to that level well. Ideally I'd like to have a concept of an 'alternate source' directory that is used by the app to load it's jsp. i.e. the app first looks under the appropriate alternate directory for a jsp and uses the page it finds there if it exists but falls back to the standard jsp dir if there is no alternate. This would mean that I could create a theme with only those pages that need to be modified rather than copying and modifying the entire jsp source tree. If anyone has had to implement something along these lines I'd love to hear from you. What sort of mechanisms have you found work well within the structure of a Struts app? My architecture is Struts, Tiles, Spring and Hibernate if you are interested but I'm thinking that it's the Struts area that I'll be looking at mostly for this job. Are there any Struts sub-projects that touch on this sort of thing? Regards Marty - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Themes
Well, as promised here is some feedback. I recommend the article : http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf Especially the section 7.4.3 Dynamic L & F. Regards Marty
Themes
In looking into providing a Themes type functionality I've run across the idea of setting up a new DefinitionsFactory class. According to the section '8.4 Writing your own Definition Factory' of the document http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf this looks like a neat way in which one might implement a themes subsystem. I think that this could allow me to basically re-write the value of a tile definition in such a way that for example: /layout/menu.jsp Is changed to something like /themes/example/layout/menu.jsp Depending on say a session scoped variable. Some code would be needed to check to make sure that this new jsp actually exists (giving me the fall-back to original functionality previously mentioned in this thread). Apparently I'll need to extend DefinitionsFactory. Unfortunately the document is now a little out of date and I'm wondering if anyone out there has successfully messed with this class? If you can share any experiences you may have had I'd really appreciate it. Regards Marty
Multi-channels / Themes
Has anyone had any experiences with the Multi-Channels construct within Tiles? Any resources, experiences good or bad would be appreciated. Regards Marty
RE: [OT] Convert Java Object into XML. Is there a simple tool in Jakarta projects or elsewere
Try JAX-B. It is in the jwsdp. Regards Marty -Original Message- From: David Gagnon [mailto:[EMAIL PROTECTED] Sent: Saturday, 18 June 2005 10:09 PM To: Struts Users Mailing List Subject: [OT] Convert Java Object into XML. Is there a simple tool in Jakarta projects or elsewere Hi all, Sorry for this OT. I'm looking for a way to output an object into XML for debugging purpose. I'm pretty sure I can do it myself with beanUtils and xml-api ..but I hate reinventing the whell and pretty sure there is a simple tool somewhere. Thanks for your help! Have a nice week-end /David - 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, Tiles and the Validator
Say I have an app that uses Struts and Tiles and I am trying to get the Validator plugin to play nicely. As I understand it the 'input' option of an action element in struts-config.xml is used when a validation fails. i.e. if a validation fails we are redirected to whatever is in the input option rather than getting sent to the Action. This is what we want right? Only actually go to the Action if the fields pass their validations. I've looked at various Tiles tutorials and even more Validator tutorials but I can't seem to work out what I need to do to get these two to work in conjunction with each other. This 'input' value for the action element cannot be straight to a .jsp since I am using Tiles. If a validation fails we need to get Tiles to reconstruct the page (with it's header, menu etc) and display the messages from the failed validation. If I put in the name of a definition in my tiles-defs.xml into the 'input' option and purposefully fail validation on one or more fields I just get a blank page and a record in my log saying: Validation failed, returning to 'activate_init' (activate_init in this case was the name of my definition in tiles-defs.xml) I know that the validator is being invoked because if I enter values that will pass the validation tests I do go through to the Action. Can someone give me an idea of what the action element should look like? More specifically what should go into the input option if I am using Tiles? I've tried creating an action definition specifically for use in the 'input' option e.g. Then putting "/act.do" into the input still gives me a blank page. Damn I am confused. Have been looking so hard at this that I cannot see it. Can someone help with an explanation of how Struts and Tiles and the Validator can work happily together? Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts, Tiles and the Validator
Thanks for the post Vasumathi I don't quite follow what you are saying however. Since I use Tiles with my struts the page that contains my form is produced by an Action executing (I use an Action which extends DispatchAction). If the Validation fails (there are fields that do not meet their validations rules) I need to go back to what is in the 'input' option of the action element. As far as I can work out this needs to be a jsp. It cannot however be a jsp since it is my Action that ties me into a tiles definition which produces the form. I've tried putting thigns like '/activate.do?method=init' into the input option of the action element but this refuses to work. Any ideas? Regards Marty -Original Message- From: Vasumathi [mailto:[EMAIL PROTECTED] Sent: Tuesday, 24 January 2006 4:44 PM To: Struts Users Mailing List Subject: Re: Struts, Tiles and the Validator Hi you try like this in struts_config.xml and tiles_sam.xml file. in tiles for this sample.jsp this may help u - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts, Tiles and the Validator
I guess I should ask the overall question: Does anyone successfully use the plugin validator with a Struts / Tiles based application? If so how are the action elements setup with regard to the input option? Assuming that you can do the above is it then possible to have multiple pages contributing to the process (session scoped action)? Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts, Tiles and the Validator
Great minds think alike or Fools seldom differ I've already gone down almost exactly this track and while it does work I am currently using the deprecated saveErrors() method. Will give your request.setAttribute() method a try as well. This basically means I am not using the Validator. Sticking everything in the Action negates all the advantages of getting this stuff unbound. Ohh well, maybe I can't have everything. At the moment I'll settle for something that works. Regards Marty -Original Message- From: Vasumathi [mailto:[EMAIL PROTECTED] Sent: Tuesday, 24 January 2006 9:42 PM To: Struts Users Mailing List Subject: RE: Struts, Tiles and the Validator dont change anything in struts_config.xml. write your validation in action itself instead of writing in validation.xml for your Form. like, if(id == null){ request.setAttribute("error","errors.id.notexist"); } try this, let me the result pls. with regards vasu Quoting Martin Ravell <[EMAIL PROTECTED]>: > Thanks for the post Vasumathi > > I don't quite follow what you are saying however. > > Since I use Tiles with my struts the page that contains my form is produced > by an Action executing (I use an Action which extends DispatchAction). > > If the Validation fails (there are fields that do not meet their > validations > rules) I need to go back to what is in the 'input' option of the action > element. > > As far as I can work out this needs to be a jsp. > > It cannot however be a jsp since it is my Action that ties me into a tiles > definition which produces the form. > > I've tried putting thigns like '/activate.do?method=init' into the input > option of the action element but this refuses to work. > > Any ideas? > > > Regards > Marty > > > -Original Message- > From: Vasumathi [mailto:[EMAIL PROTECTED] > Sent: Tuesday, 24 January 2006 4:44 PM > To: Struts Users Mailing List > Subject: Re: Struts, Tiles and the Validator > > Hi > you try like this in struts_config.xml and tiles_sam.xml file. > > type="controller.admin.action.SampleAction" validate="true" > input="/admin/icf/sample.jsp"> > > > > in tiles for this sample.jsp > > > > > > > > > > this may help u > > > > > > > > > > - > 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]
RE: Struts, Tiles and the Validator
>I call validate manually, but since I'm using DynaValidatorActionForms >I'm using the validation defs from the validator XML config file. This >is quite a bit more flexible to boot. > >In any case, I use tiles and validator together all the time so I'm not >quite sure where your problem lies: > >type="com.pingsite.actions.NiceAction" >name="niceBean" >input="page.NiceAction" >scope="request" >validate="false" >roles="Role1,Role2"> > > redirect="true"/> > > > > > > > > >etc. > >Dave One of the main reasons I have for heading down this path was to use generic validation defs. This alone should cut out a heap of tedious code. So you call validate from within the Action? Do you then have to forward back to the original page if you have errors? Have you tried having validate="true" in your action? Could I take a look at an example out of one of your Actions? Thanks for showing me that the input can point to a tiles definition. I've been trying this without luck. Perhaps I have something in my configuration somewhere which is not setup 100% correctly. Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts, Tiles and the Validator
> >I'm not using extension mapping so I'm not sure about this, but have you >tried input="/activate" instead of input="/activate.do"? It's certainly >possible for the input attribute to point to an action rather than a JSP >or Tiles def. > >L. Part of the problem is that my actions typically extend DispatchAction and therefore need a parameter passed as well. Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Going Down
Has anyone out there had to work out a solution for alerting their users that the (Struts based) system will be taken offline for maintenance? I'm thinking a filter perhaps or some sort of mechanism to insert a simple Javascript for a dialog box to popup. I'd appreciate it if anyone is willing to share their experiences. Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Being Lazy with Hibernate
Has anyone been able to get a Struts / Hibernate app to work nicely with Lazy Initialization? Whenever I have things with Lazy set to true I'm getting a "Failed to lazily initialize a collection" Exception. I'd like to be able to lazily access related objects in my DAO layer, potentially my Actions and the JSPs of the frontend as well. (I use tiles as well if that affects things). Is this possible? I've posted once or twice to the Equinox list but it seems a little low on traffic these days and was wondering if anyone else out there has done this particular thing with the same combination of technologies? If it is at all relevant my app is using Hibernate 2, JBoss 3.2.1 with a Tomcat 4 plugin (not my choice and I cannot change it), an Apache web server and Oracle as the DB. If there is anyone out there being successfully lazy I'd love to hear from you. I've been trying filters and such things but without result so far. Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Being Lazy with Hibernate
Hi David, This sounds good but I should have mentioned that I am somewhat new to this particular area and as a result I have no idea how to go about doing what you have suggested. I will continue to research but would you be able to help me with a little more detail on what this entails? Regards Marty -Original Message- From: David Delbecq [mailto:[EMAIL PROTECTED] Sent: Tuesday, 20 September 2005 10:04 PM To: Struts Users Mailing List Subject: Re: Being Lazy with Hibernate For lazy initialization to work, at the moment of the lazy initialisation, (that is the moment you request the data) the hibernate session must not be closed. The best way to do this is to store the hibernate session in the user session and use a servlet filter to connect/disconnect/reconnect the hibernate session. Martin Ravell a écrit : >Has anyone been able to get a Struts / Hibernate app to work nicely with >Lazy Initialization? > >Whenever I have things with Lazy set to true I'm getting a "Failed to lazily >initialize a collection" Exception. > >I'd like to be able to lazily access related objects in my DAO layer, >potentially my Actions and the JSPs of the frontend as well. (I use tiles as >well if that affects things). > >Is this possible? I've posted once or twice to the Equinox list but it seems >a little low on traffic these days and was wondering if anyone else out >there has done this particular thing with the same combination of >technologies? > >If it is at all relevant my app is using Hibernate 2, JBoss 3.2.1 with a >Tomcat 4 plugin (not my choice and I cannot change it), an Apache web server >and Oracle as the DB. > >If there is anyone out there being successfully lazy I'd love to hear from >you. I've been trying filters and such things but without result so far. > > > >Regards >Marty > > > > > > >- >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]
RE: Being Lazy with Hibernate
> > -Original Message- > From: David Delbecq [mailto:[EMAIL PROTECTED] > Sent: Tuesday, 20 September 2005 10:28 PM > To: Struts Users Mailing List > Subject: Re: Being Lazy with Hibernate > > See sections > 20.1.4. Initializing collections and proxies and 1.4, Playing with cats > For details :) (Hibernate 3 documentation) > Martin Ravell a écrit : > Thanks for this David. Will check it out today. I am using Hibernate2 is the only thing. With luck it will work the same Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Being Lazy with Hibernate
> > -Original Message- >From: Bill Schneider [mailto:[EMAIL PROTECTED] >Sent: Tuesday, 20 September 2005 11:01 PM >To: user@struts.apache.org >Subject: Re: Being Lazy with Hibernate > >Has anyone been able to get a Struts / Hibernate app to work nicely with >Lazy Initialization? > Whenever I have things with Lazy set to true I'm getting a "Failed to lazily initialize a collection" Exception. > >The easiest way to do this is to use the "open session in view" pattern. > >If you're using Spring to manage your Hibernate SessionFactory, you can >just pop the OpenSessionInViewFilter in web.xml and go. The only thing >to watch out for is that any writes back to the database need to be >within transactions. > >-- Bill >-- >Bill Schneider >Chief Architect > >Vecna Technologies, Inc. >5004 Lehigh Road, Suite B >College Park, MD 20740 >[EMAIL PROTECTED] >t: 301-864-7594 >f: 301-699-3180 I am using Spring and have bee having a go at getting this pattern to work without much luck. Not sure what I am doing wrong but will persevere. It seems as though even if I have the filter in place I still get the Exceptions. Perhaps I need to disable some of my existing setup (on top of setting up the filter properly). Could I have a conflict somehow? Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Being Lazy with Hibernate
> > -Original Message- > From: Letícia Álvares Barbalho [mailto:[EMAIL PROTECTED] > Sent: Tuesday, 20 September 2005 11:03 PM > To: Struts Users Mailing List > Subject: Re: Being Lazy with Hibernate > > I use struts and Hibernate 3 and lazy initialization works just fine for me. > I didn't have to do anything. What's your hibernate version? > I have Hibernate 2 which originally came with the Equinox build that I started the project on (like an Appfuse lite if you have not heard of it before. Matt Raible put it together.) I wonder if I should attempt upgrading to Hibernate 3 from hibernate 2? Does anyone know if there are significant differences between the two versions that I should be aware of? Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Lazy again
I'm just getting back to looking at my lazy loading problem and would like to see if I am understanding things correctly. While not strictly Struts related (I do use Struts in this app) I am hoping that someone else on this list has gone down the same path as I am attempting. My web.xml has the following section in it: hibernateFilter org.springframework.orm.hibernate3.support.OpenSessionInViewFi lter hibernateFilter *.spring I have also tried other patterns than *.spring (as I was unsure if this was correct. When attempting to access objects in the jsp that have come from hibernate I am still getting : [LazyInitializationException] could not initialize prozy - the owning Session was closed Originally I was using Hibernate 2 and had tried the similar OpenSessionInViewFilter that is meant for that version. Same problem. Any ideas? Am I correct in thinking that if the filter is working correctly I should be able to grab an object from my DAO layer in an Action, put it into the session or request scope and have my jsp page access it's related objects (with lazy loading)? What mechanism opens and closes these Hibernate sessions? I thought it was supposed to be all done by the filter? PS. I do use Tiles with my Struts if this makes any difference. Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hibernate data at startup
I have Menu information for my app in the database which I would like to be able to load somehow when my app server starts up (or app is deployed). This would be much more efficient than the current method of having each user load it when they enter the application. Can anyone suggest how to best go about doing this? The architecture is Struts, Hibernate and Spring. Thanks Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Premature Session Close
Im running Struts, Tiles, Hibernate 2 and Spring in my project and have been attempting for some time to get the OpenSessionInView pattern to work without much luck. I have the filter setup in my web.xml like so : hibernateFilter org.springframework.orm.hibernate.support.OpenSessionInViewFilter hibernateFilter *.do applicationContext.xml for various things is as follows: java:/JournalDS com/rave/journal/model/Activity.hbm.xml . . . . . net.sf.hibernate.dialect.Oracle9Dialect false Looking at the log output it seems to be closing the Hibernate session after the first POJO is populated in my Action. The next piece of code tries to access a collection and bam, down it goes : . . . [net.sf.hibernate.impl.SessionImpl] executing flush [net.sf.hibernate.impl.SessionImpl] post flush [org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [EMAIL PROTECTED] for key [EMAIL PROTECTED] from thread [Ajp13Processor[8009][4]] [org.springframework.orm.hibernate.SessionFactoryUtils] Closing Hibernate session [net.sf.hibernate.impl.SessionImpl] closing session [net.sf.hibernate.impl.SessionImpl] disconnecting session [net.sf.hibernate.impl.SessionImpl] transaction completion [net.sf.hibernate.LazyInitializationException] Failed to lazily initialize a collection - no session or session was closed All my mappings have lazy set to true. If I switch them all over to false the application does run. If I look at all the SQL generated with lazy set false though it is quite scary how much access is done. I've attached a bigger excerpt from the log if that will help track down the issue. Any ideas what would be causing the Hibernate session to be closed? If I understand things correctly the OpenSessionInViewFilter should be the thing closing the session (after everything has run in the Request. From the log it looks as if org.springframework.orm.hibernate.SessionFactoryUtils is doing it. I'd really appreciate some help here. This has been driving me nuts for days. Regards Marty Martin Ravell FMS Global - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Premature Session Close
Hi Werner, Hmm. I do not use iframes but I am doing Single Sign On. (JBoss/Tomcat with multiple applications on the one server) I wonder if that could complicate matters? Regards Marty >-Original Message- >From: news [mailto:[EMAIL PROTECTED] On Behalf Of Werner Punz >Sent: Thursday, 6 October 2005 10:48 PM >To: user@struts.apache.org >Subject: Re: Premature Session Close > >I ran into a situation like that once, the application was using iframes >internally which triggered other sessions... > >Werner > > >Martin Ravell wrote: >> I'm running Struts, Tiles, Hibernate 2 and Spring in my project and have >> been attempting for some time to get the OpenSessionInView pattern to work >> without much luck. >> > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Premature Session Close
Hi Martin, Thanks for the post. Yep this is one of the main sites I have referenced in trying to get this stuff up and running. BTW. I mentioned a log file in the first post and then forgot to attach it. Here it is on this email. I wonder if the org.springframework.transaction.support.TransactionSynchronizationManager is somehow involved? Its either that or org.springframework.orm.hibernate.SessionFactoryUtils. Trouble is I do not understand the mechanisms where these classes get called from. Regards Marty > >-Original Message- >From: Martin Gainty [mailto:[EMAIL PROTECTED] >Sent: Thursday, 6 October 2005 11:57 PM >To: Struts Users Mailing List >Subject: Re: Premature Session Close > >Martin/Werner > >Have you had a chance to look at Karl Blaums Lacy Initialization and the DAO >Pattern with Hibernate and Spring example >http://www.jroller.com/comments/kbaum/Weblog/orm_lazy_initialization_with_d ao > >Martin- > >- Original Message - >From: "Werner Punz" <[EMAIL PROTECTED]> >To: >Sent: Thursday, October 06, 2005 8:48 AM >Subject: Re: Premature Session Close > > >>I ran into a situation like that once, the application was using iframes >> internally which triggered other sessions... >> >> Werner >> >> >> Martin Ravell wrote: >>> I'm running Struts, Tiles, Hibernate 2 and Spring in my project and have >>> been attempting for some time to get the OpenSessionInView pattern to >>> work >>> without much luck. >>> >> >> >> - >> 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] 2005-10-06 12:14:01,768 INFO [org.springframework.orm.hibernate.support.OpenSessionInViewFilter] Using SessionFactory 'sessionFactory' for OpenSessionInViewFilter 2005-10-06 12:14:01,768 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'sessionFactory' 2005-10-06 12:14:01,768 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Bean with name 'sessionFactory' is a factory bean 2005-10-06 12:14:01,768 DEBUG [org.springframework.orm.hibernate.support.OpenSessionInViewFilter] Opening Hibernate Session in OpenSessionInViewFilter 2005-10-06 12:14:01,788 DEBUG [org.springframework.orm.hibernate.SessionFactoryUtils] Opening Hibernate session 2005-10-06 12:14:01,838 DEBUG [net.sf.hibernate.impl.SessionImpl] opened session 2005-10-06 12:14:01,848 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Bound value [EMAIL PROTECTED] for key [EMAIL PROTECTED] to thread [Ajp13Processor[8009][4]] 2005-10-06 12:14:01,848 DEBUG [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true 2005-10-06 12:14:01,848 DEBUG [org.apache.struts.util.ModuleUtils] Get module name for path /sso.do 2005-10-06 12:14:01,848 DEBUG [org.apache.struts.util.ModuleUtils] Module name found: default 2005-10-06 12:14:01,848 INFO [org.apache.struts.tiles.TilesRequestProcessor] Tiles definition factory found for request processor ''. 2005-10-06 12:14:01,848 DEBUG [org.apache.struts.action.RequestProcessor] Processing a 'GET' for path '/sso' 2005-10-06 12:14:01,848 DEBUG [org.apache.struts.action.RequestProcessor] Setting user locale 'en_US' 2005-10-06 12:14:01,848 DEBUG [org.apache.struts.action.RequestProcessor] Looking for Action instance for class org.springframework.web.struts.DelegatingActionProxy 2005-10-06 12:14:01,848 DEBUG [org.apache.struts.action.RequestProcessor] Creating new Action instance 2005-10-06 12:14:01,848 DEBUG [org.springframework.web.struts.DelegatingActionUtils] DelegatingActionProxy with mapping path '/sso' and module prefix '' delegating to Spring bean with name [/sso] 2005-10-06 12:14:01,848 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Creating instance of bean '/sso' with merged definition [Root bean with class [com.rave.journal.web.SSOAction] defined in resource [/WEB-INF/action-servlet.xml] of ServletContext] 2005-10-06 12:14:01,848 DEBUG [org.springframework.beans.CachedIntrospectionResults] Getting BeanInfo for class [com.rave.journal.web.SSOAction] 2005-10-06 12:14:01,868 DEBUG [org.springframework.beans.CachedIntrospectionResults] Caching PropertyDescriptors for class [com.rave.journal.web.SSOAction] 2005-10-06 12:14:01,868 DEBUG [org.springfra
RE: Premature Session Close
Unfortunately doing an eager fetch would (if I understand the concept correctly) be the exact opposite of what I am trying to achieve here. I really need the load to be lazy. Am I correct in thinking that an eager fetch is the opposite of a lazy one? i.e. all of the associated collections are loaded with the owning object? The second suggestion of doing an initialize is basically the same right? It is saying to Hibernate 'go and fill this collection for this object'. i.e. not being lazy. What I am trying to do is use the OpenSessionInView pattern. This means that the control of opening and closing Hibernate sessions is delegated to a filter (or some other mechanism) which opens the session at the start of the request, allows any objects whether they are in the DAO layer, Action layer, even JSP layer to access hibernate objects with Lazy loading. Therefore it should only load collections when they are first accessed. The filter should then execute it's shutdown method at the end of the request which will close the Hibernate session. Regards Marty -Original Message- From: Martin Gainty [mailto:[EMAIL PROTECTED] Sent: Friday, 7 October 2005 12:47 AM To: [EMAIL PROTECTED] Cc: Struts Users Mailing List Subject: Re: Premature Session Close 2 solutions I found at hibernate users group http://forum.hibernate.org/viewtopic.php?t=938083&sid=3e74c7e9a3aa83e9cde5ce 4862c920fb .assuming you will be retrieving a userID from your User class.. do an 'eager fetch' instead of lazy fetch e.g. user = (User) session.createCriteria(User.class) .setFetchMode("groups", FetchMode.EAGER) .add(Expression.eq("userID", new Integer(userID))) .uniqueResult(); OR In the case where you have nothing to return add the item (userID) to the User class AND actively initialise hibernate to apprise it of the new item's addition user = (User) session.createCriteria(User.class).add(Expression.eq("userID", new Integer(userID))).uniqueResult(); Hibernate.initialize(user.getGroups()); HTH, Martin- - Original Message - From: "Martin Ravell" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" ; "'Martin Gainty'" <[EMAIL PROTECTED]> Sent: Thursday, October 06, 2005 10:14 AM Subject: RE: Premature Session Close > Hi Martin, > > Thanks for the post. Yep this is one of the main sites I have referenced > in > trying to get this stuff up and running. > > BTW. I mentioned a log file in the first post and then forgot to attach > it. > Here it is on this email. > > I wonder if the > org.springframework.transaction.support.TransactionSynchronizationManager > is > somehow involved? Its either that or > org.springframework.orm.hibernate.SessionFactoryUtils. > > Trouble is I do not understand the mechanisms where these classes get > called > from. > > > > Regards > Marty > >> >>-Original Message- >>From: Martin Gainty [mailto:[EMAIL PROTECTED] >>Sent: Thursday, 6 October 2005 11:57 PM >>To: Struts Users Mailing List >>Subject: Re: Premature Session Close >> >>Martin/Werner >> >>Have you had a chance to look at Karl Blaums Lacy Initialization and the > DAO >>Pattern with Hibernate and Spring example >>http://www.jroller.com/comments/kbaum/Weblog/orm_lazy_initialization_with_ d > ao >> >>Martin- >> >>- Original Message - >>From: "Werner Punz" <[EMAIL PROTECTED]> >>To: >>Sent: Thursday, October 06, 2005 8:48 AM >>Subject: Re: Premature Session Close >> >> >>>I ran into a situation like that once, the application was using iframes >>> internally which triggered other sessions... >>> >>> Werner >>> >>> >>> Martin Ravell wrote: >>>> I'm running Struts, Tiles, Hibernate 2 and Spring in my project and >>>> have >>>> been attempting for some time to get the OpenSessionInView pattern to >>>> work >>>> without much luck. >>>> >>> >>> >>> - >>> 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] - 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: Struts + Spring + Hibernate
> Are there some developers here who use this solution? > Does someone have a good tutorial or sample to indicate? (I've already >seen "Wiring your web applications with Open Source java"..thanks :o)) > > Thanks for your feedback on this architecture :o) > Check out Matt Raible's Equinox project. For that matter you can get a head start on this combination using Appfuse. Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
OT: Graphing Taglibs
Hi All, Just casting about for taglibs to produce graphs in a Struts, JSP app that I'm about to start prototyping. Google turned up a couple and Cewolf looks like a likely candidate. Has anyone got experiences to share about this or any other taglib set for producing nice graphs and charts in a JSP environment? Regards Marty
Weird multiple GET error
My Struts, Hibernate app (Appfuse based on JBoss with Tomcat plugin) has developed a really weird bug and I have no idea after a day of searching of how to track down the problem. It seems that any request I make, be it a GET or a POST, is somehow followed up by three GET requests for the same action. Generally for GET requests this doesn't seem to break anything (although of course three times the network traffic is less than ideal). If the request happens to be a POST from a form submission however the thing tends to fall over from the subsequent GET posts. I have no idea why the browser is sending these extra requests. Nothing in the page contents or headers seems to be likely to cause this. I put a little proxy server I have between my browser and the app to see what happens. The headers and responses are : == http://localhost/127.0.0.1:80 == GET /portal/gateway.do HTTP/1.0 Host: localhost User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q= 0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Proxy-Connection: keep-alive Cookie: JSESSIONID=38C8A3C4B5FED782C162C0326A38EBAE == HTTP/1.1 200 OK Date: Fri, 30 Dec 2005 07:16:12 GMT Server: Apache/1.3.31 (Win32) PHP/4.3.4 mod_jk/1.2.0 Expires: Thu, 01 Jan 1970 00:00:00 GMT Pragma: No-cache Cache-Control: no-cache,no-store,max-age=0 Connection: close Content-Type: text/html;charset=ISO-8859-1 Content-Length: 16560 . . . Now the above looks OK. The page renders up on the browser without a problem This is followed immediately however by three identical requests like this: == http://localhost/127.0.0.1:80 == GET /portal/gateway.do HTTP/1.0 Host: localhost User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6 Accept: image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Proxy-Connection: keep-alive Referer: http://localhost/portal/gateway.do Cookie: JSESSIONID=38C8A3C4B5FED782C162C0326A38EBAE == HTTP/1.1 200 OK Date: Fri, 30 Dec 2005 07:16:12 GMT Server: Apache/1.3.31 (Win32) PHP/4.3.4 mod_jk/1.2.0 Expires: Thu, 01 Jan 1970 00:00:00 GMT Pragma: No-cache Cache-Control: no-cache,no-store,max-age=0 Connection: close Content-Type: text/html;charset=ISO-8859-1 Content-Length: 16560 The only differences I can see between the initial Get and the following ones are: Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q= 0.8,image/png,*/*;q=0.5 Versus Accept: image/png,*/*;q=0.5 and the three bogus requests have the line Referer: http://localhost/portal/gateway.do I'm wondering if anyone out there in list land has come across a problem with similar symptoms? Regards Marty
Weird multiple GET error
Well I finally tracked this one down. There were no badly formed tags but I do have to say thank you Laurie and Wendy for the hint anyway as it pointed me in the right direction. Turns out I'd managed to put in a bogus option on a tag. What I should have written was but what I'd written was . As the browser expects an image URL in the background option it was treating the color triplet, specifically the # at the start, as a bookmark hyperlink instead and therefore tried to do a GET on the originating action.. Yes, I realize I should have done the table cell background color stuff in a stylesheet. Was one of those late night couldn't be bothered type errors. You would not believe what a complete bitch it was to track down though! Regards Marty
Globally available variables
Is there a simple way to put an object into a globally available spot for access by any current session? Something like the session.setAttribute() method? I have some info that I'd like to be able to load up and then have accessed by any user logged into my app. I'm thinking of a cache type of deal. Ideally writeable by any of the sessions. App is Struts, Hibernate and Spring running on JBoss/Tomcat. Any ideas will be much appreciated. Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Globally available variables
>-Original Message- >From: ALEX HYDE [mailto:[EMAIL PROTECTED] >Sent: Wednesday, 18 January 2006 10:47 PM >To: Struts Users Mailing List >Subject: Re: Globally available variables > >Can't you put it in the application context instead of all the sessions? > I don't know. Will look into this but is it possible to have a session write an object to this app context and have another session see the result? I had a suspicion that stuff in the application context was setup during the app being deployed and could not be changed? Regards Marty - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]