RE: Design question regarding struts security features
You should be able to do this with standard J2EE security provided by your web container. If you store your user credentials in a database, then you may want to look at SecurityFilter: http://sourceforge.net/projects/securityfilter/ It allows you to leverage standard J2EE security features but provides more flexible authentication. robert -Original Message- From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] Sent: Sunday, December 28, 2003 6:37 PM To: Struts Users List Subject: Design question regarding struts security features Hello everybody, I'm in the process of developing my first Struts application, so forgive me if this question is insulting everybody's intellect. The application I'm working on is a support portal where you can download technical document, drivers etc. The tricky part is, that certain documents should be only accessible to users with a certain role. My idea so far is to put a user object in the session and to evaluate the role (and therefore the access level) of the user for all views that are displaying data which might be restricted. I guess the easiest way would be using a jsp tag like security:checkAccessLevel / which would retrieve the user object from the session (if it exists) and the then filter the data accordingly. Is there such security taglib around? Has anybody worked on a similar scenario? What is the best approach to solve this problem? Is there a best practice for it? Any tips, hints, code snippets are welcome. Thank you very much. Patrick - 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: Design question regarding struts security features
Hi Are you only filtering data based on role ? If you are talking about role-based access of views then we are doing something like that 1. You can use Container Manager Authentication and restrict access to URL patterns to only valid users. 2. You can use the vendor-specify XML file to specify roles and groups. (e.g) principals.xml in OC4J 3. You can use a vendor-specific API like the 'DataSourceUserManager' in OC4J to write custom code that can access your tables and do away with hard-coded principals.xml I think you can also use the role attribute in struts-config.xml and restrict access actions. Tiles has a role attribute too ? though we are not using that. Mohan -Original Message- From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] Sent: Monday, December 29, 2003 5:07 AM To: Struts Users List Subject: Design question regarding struts security features Hello everybody, I'm in the process of developing my first Struts application, so forgive me if this question is insulting everybody's intellect. The application I'm working on is a support portal where you can download technical document, drivers etc. The tricky part is, that certain documents should be only accessible to users with a certain role. My idea so far is to put a user object in the session and to evaluate the role (and therefore the access level) of the user for all views that are displaying data which might be restricted. I guess the easiest way would be using a jsp tag like security:checkAccessLevel / which would retrieve the user object from the session (if it exists) and the then filter the data accordingly. Is there such security taglib around? Has anybody worked on a similar scenario? What is the best approach to solve this problem? Is there a best practice for it? Any tips, hints, code snippets are welcome. Thank you very much. Patrick - 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: Design question regarding struts security features
Mohan Radhakrishnan wrote: I think you can also use the role attribute in struts-config.xml and restrict access actions. Tiles has a role attribute too ? though we are not using that. I came across the role tag of tiles as well, but I guess it's suitable only if you want to restrict some area of the user interface (let's say a special panel for administrators). Where can I find more information about the role attribute in struts-config.xml? I couldn't find anything in the Struts User's Guide... Thanks, Patrick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: design question
hi Drik once the user have filled up the other 2 forms in the pop window u can make object of those two forms into your final action and can get the values like Form1 form=new Form1(); Form2 form2=new Form2(); from1.getUserAddress(); from1.getCity(); Hope this works Regards Gurpreet Dhanoa - Original Message - From: dirk [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, December 24, 2003 2:54 PM Subject: design question I have 3 FormObjects. I have a newuser.jsp page containing the form userForm, in this form i put a javascript button with an onclick event, window.open with a popup (adresuser.jsp), with the form adresUserForm. Finally i have on the userForm another javascript button with a popup to specialinfo.jsp. This page contains the specialInfoForm. After closing these popups i want to have one action ( submitting the userForm ). How can i get the values from the 2 other formObjects ? Is there anybody that has a similar problem ... Thanks ! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: design question
If the forms are in different windows then instantiating new forms I dont think will work. If you want a non javascript way of doing things then you'll want to scope the master form to the session, and then keep populating to from your subforms . However you do this I imagine that scoping the master form to session is the way forward and retrieving and populating it in the actions processing your secondary forms. action path=/master name=masterForm scope=session... action path=/gimp/submit name=gimpForm scope=request type=com.sparrow.struts.GimpAction.. You could make one form property of the master form of type gimpform or store this as a map. html:form action=/gimp/submit.do public GimpAction ... GimpForm gimpForm = (GimpForm) form; MasterForm masterForm = (MasterForm) session.getAttribute(masterForm); masterForm.setGimp(gimpForm); or if you're using a map to store the properties of gimp in your masterForm Map gimpMap = BeanUtils.describe(gimpForm); masterForm.setGimp(gimpMap); Hope this helps Mark On 24 Dec 2003, at 09:50, Gurpreet Dhanoa wrote: hi Drik once the user have filled up the other 2 forms in the pop window u can make object of those two forms into your final action and can get the values like Form1 form=new Form1(); Form2 form2=new Form2(); from1.getUserAddress(); from1.getCity(); Hope this works Regards Gurpreet Dhanoa - Original Message - From: dirk [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, December 24, 2003 2:54 PM Subject: design question I have 3 FormObjects. I have a newuser.jsp page containing the form userForm, in this form i put a javascript button with an onclick event, window.open with a popup (adresuser.jsp), with the form adresUserForm. Finally i have on the userForm another javascript button with a popup to specialinfo.jsp. This page contains the specialInfoForm. After closing these popups i want to have one action ( submitting the userForm ). How can i get the values from the 2 other formObjects ? Is there anybody that has a similar problem ... Thanks ! - 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: design question
hi all! would anyone in the spirit of diwali like to help me on this one. how do i direct a form submission to a remote action class, after having fthe form submitted to a local action class first. ie, communicate between two action classes, one of which is on a remote machine. I am looking at sending a URL object with the form data from the local to the remote class, but then depending upon the remote class's response i want to forward the user to a page on the remote machine. Its like a payment system, you select your good at an e-comm website, then click pay. This then transfers you to a payment page located on a payment gateway site. Before the transfer i will have a security session establishment. This is being handled by two Java classes, one on each end. so when the user clicks pay, the following two things happen: - establish secure session - send form data across. I have the first figured out, how do i implement the second? please help. If you have an alternative way of doing it, tell me. any ideas, thoughts would be very much helpful cheers Ajay From: ajay brar [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: design question Date: Wed, 22 Oct 2003 17:37:38 +1000 hi! i have the following scenario. server0 - has a jsp page, that allows user to enter the goods they want etc, say foo.jsp server1-jsp payment page, say bar.jsp and action class CommAction on clicking done on foo.jsp, this should establish a connection with CommAction class on server1, perform some identity exchange, based on the exchange, route to bar.jsp i came up with [server0] foo.jsp -FooForm -FooAction [server1] bar.jsp -BarForm -BarAction i have java classes to establish a secure communication between two parties. what i want to do now is, have some way of FooAction (on successful return from the underlying comm establishing class) to direct the person to BarAction along with the information they submitted orginally. in other words how can i conditionally submit a form to another action class on some other server. I ofcourse want the form to be submitted to the local action class, that first checks it, then resubmits to a remote action class, the remote action class then forwards the user to a page on its own remote server. sorry if the above sounds too cryptic. any help would be greatly welcome thanks cheers ajay _ Hot chart ringtones and polyphonics. Go to http://ninemsn.com.au/mobilemania/default.asp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Hot chart ringtones and polyphonics. Go to http://ninemsn.com.au/mobilemania/default.asp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: design question
AFAIK u can do the same using the serialization ( by making ur form implement the serializable interface) or u can also do one case like create the other action class as a seperate module and do switch action which might work out also might help u to switch back in the previous application. I am no expert on security but this might work look what other people might say. ur security depends on how u call ur remote class -Original Message- From: ajay brar [mailto:[EMAIL PROTECTED] Sent: 22 October 2003 16:12 To: [EMAIL PROTECTED] Subject: Re: design question hi all! would anyone in the spirit of diwali like to help me on this one. how do i direct a form submission to a remote action class, after having fthe form submitted to a local action class first. ie, communicate between two action classes, one of which is on a remote machine. I am looking at sending a URL object with the form data from the local to the remote class, but then depending upon the remote class's response i want to forward the user to a page on the remote machine. Its like a payment system, you select your good at an e-comm website, then click pay. This then transfers you to a payment page located on a payment gateway site. Before the transfer i will have a security session establishment. This is being handled by two Java classes, one on each end. so when the user clicks pay, the following two things happen: - establish secure session - send form data across. I have the first figured out, how do i implement the second? please help. If you have an alternative way of doing it, tell me. any ideas, thoughts would be very much helpful cheers Ajay From: ajay brar [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: design question Date: Wed, 22 Oct 2003 17:37:38 +1000 hi! i have the following scenario. server0 - has a jsp page, that allows user to enter the goods they want etc, say foo.jsp server1-jsp payment page, say bar.jsp and action class CommAction on clicking done on foo.jsp, this should establish a connection with CommAction class on server1, perform some identity exchange, based on the exchange, route to bar.jsp i came up with [server0] foo.jsp -FooForm -FooAction [server1] bar.jsp -BarForm -BarAction i have java classes to establish a secure communication between two parties. what i want to do now is, have some way of FooAction (on successful return from the underlying comm establishing class) to direct the person to BarAction along with the information they submitted orginally. in other words how can i conditionally submit a form to another action class on some other server. I ofcourse want the form to be submitted to the local action class, that first checks it, then resubmits to a remote action class, the remote action class then forwards the user to a page on its own remote server. sorry if the above sounds too cryptic. any help would be greatly welcome thanks cheers ajay _ Hot chart ringtones and polyphonics. Go to http://ninemsn.com.au/mobilemania/default.asp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Hot chart ringtones and polyphonics. Go to http://ninemsn.com.au/mobilemania/default.asp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: design question
hi! thanks for the reply. How do i do the switch action you talked about. cheers ajay From: [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: design question Date: Wed, 22 Oct 2003 16:49:32 +0100 AFAIK u can do the same using the serialization ( by making ur form implement the serializable interface) or u can also do one case like create the other action class as a seperate module and do switch action which might work out also might help u to switch back in the previous application. I am no expert on security but this might work look what other people might say. ur security depends on how u call ur remote class -Original Message- From: ajay brar [mailto:[EMAIL PROTECTED] Sent: 22 October 2003 16:12 To: [EMAIL PROTECTED] Subject: Re: design question hi all! would anyone in the spirit of diwali like to help me on this one. how do i direct a form submission to a remote action class, after having fthe form submitted to a local action class first. ie, communicate between two action classes, one of which is on a remote machine. I am looking at sending a URL object with the form data from the local to the remote class, but then depending upon the remote class's response i want to forward the user to a page on the remote machine. Its like a payment system, you select your good at an e-comm website, then click pay. This then transfers you to a payment page located on a payment gateway site. Before the transfer i will have a security session establishment. This is being handled by two Java classes, one on each end. so when the user clicks pay, the following two things happen: - establish secure session - send form data across. I have the first figured out, how do i implement the second? please help. If you have an alternative way of doing it, tell me. any ideas, thoughts would be very much helpful cheers Ajay From: ajay brar [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: design question Date: Wed, 22 Oct 2003 17:37:38 +1000 hi! i have the following scenario. server0 - has a jsp page, that allows user to enter the goods they want etc, say foo.jsp server1-jsp payment page, say bar.jsp and action class CommAction on clicking done on foo.jsp, this should establish a connection with CommAction class on server1, perform some identity exchange, based on the exchange, route to bar.jsp i came up with [server0] foo.jsp -FooForm -FooAction [server1] bar.jsp -BarForm -BarAction i have java classes to establish a secure communication between two parties. what i want to do now is, have some way of FooAction (on successful return from the underlying comm establishing class) to direct the person to BarAction along with the information they submitted orginally. in other words how can i conditionally submit a form to another action class on some other server. I ofcourse want the form to be submitted to the local action class, that first checks it, then resubmits to a remote action class, the remote action class then forwards the user to a page on its own remote server. sorry if the above sounds too cryptic. any help would be greatly welcome thanks cheers ajay _ Hot chart ringtones and polyphonics. Go to http://ninemsn.com.au/mobilemania/default.asp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Hot chart ringtones and polyphonics. Go to http://ninemsn.com.au/mobilemania/default.asp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
RE: design question regarding multiple submit buttons
David wrote: When they have no more addresses to enter, they should hit DONE to move on to the next form. However, when DONE is selected, the form calls the validate method, which of course fails because the fields are empty. I think validation is on by default, so you may want to turn it off and call validate() manually when appropriate. (IE, from the 'add' method but not from the 'done' method.) Also take a look at LookupDispatchAction (Tip #3). -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: design question regarding multiple submit buttons
thanks for the advice, Wendy. its up and running :) -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Thursday, September 18, 2003 12:22 PM To: Struts Users Mailing List Subject: RE: design question regarding multiple submit buttons David wrote: When they have no more addresses to enter, they should hit DONE to move on to the next form. However, when DONE is selected, the form calls the validate method, which of course fails because the fields are empty. I think validation is on by default, so you may want to turn it off and call validate() manually when appropriate. (IE, from the 'add' method but not from the 'done' method.) Also take a look at LookupDispatchAction (Tip #3). -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM - 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: Design Question
oops. Forget what I said - didnt read it properly. You need to be able to tell which fields changed. The digest will merely tell you if any changed. Sorry. -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED] Sent: Wednesday, 17 September 2003 23:01 To: Struts Users Mailing List Subject: RE: Design Question Actually you could just store a digest of the previous values, and then compare that with a digest of the new. -Original Message- From: sean schofield [mailto:[EMAIL PROTECTED] Sent: Wednesday, 17 September 2003 22:57 To: [EMAIL PROTECTED] Subject: Design Question I am working on a struts-based web application and I have an interesting design issue that I'd like to get some feedback on. I think this problem is actually quite generic and there must be some good ideas out there already that I could sponge off! Basically I have a struts form with a bunch of fields that will be presented to the user through the usual JSP-based view. The user will have the opportunity to makes edits and then submit to an action. What I would like to do is be able to identify which fields changed and then take certain actions based on these changes. Here is one rough ideas I have so far. Any thoughts on this plus additional ideas would be greatly appreciated. 1.) Extend ActionForm and customize the populate method so that it makes a copy of the old version of the form that is already stored in the session (since it will have session scope) 2.) Populate new form 3.) Compare two forms and store list of changes in new form 4.) Discard copy of old. Any thoughts, comments? TIA, sean - 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: Design Question
You are correct that my problem requires more information that just something changed. But your solution may prove useful for a different problem ... Basically the user has the option of bringing up different forms without submitting their changes. I'd like to be able to present them with Are you sure you don't want to submit your changes? message but only if something actually changed. I could use onchange for each field and also keep track of the original values but the digest idea might be nice. Thanks for the timely response. I'd be happy to hear feedback on this idea plus my original problem from anybody. Regards, - sean -- Original Message -- From: Andrew Hill [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] Date: Wed, 17 Sep 2003 23:02:41 +0800 oops. Forget what I said - didnt read it properly. You need to be able to tell which fields changed. The digest will merely tell you if any changed. Sorry. -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED] Sent: Wednesday, 17 September 2003 23:01 To: Struts Users Mailing List Subject: RE: Design Question Actually you could just store a digest of the previous values, and then compare that with a digest of the new. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design Question
You can probably write an aspect (using AspectJ) to do this fairly automatically -- i.e. create a pointcut for all *Form.set* methods, and then do your comparisons there. i.e. public aspect DiffAspect { pointcut setter() : call(public void *Form.set*(..)); before() : setter() { //... your comparison here... } } - Original Message - From: sean schofield [EMAIL PROTECTED] To: Struts [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 8:20 AM Subject: RE: Design Question You are correct that my problem requires more information that just something changed. But your solution may prove useful for a different problem ... Basically the user has the option of bringing up different forms without submitting their changes. I'd like to be able to present them with Are you sure you don't want to submit your changes? message but only if something actually changed. I could use onchange for each field and also keep track of the original values but the digest idea might be nice. Thanks for the timely response. I'd be happy to hear feedback on this idea plus my original problem from anybody. Regards, - sean -- Original Message -- From: Andrew Hill [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] Date: Wed, 17 Sep 2003 23:02:41 +0800 oops. Forget what I said - didnt read it properly. You need to be able to tell which fields changed. The digest will merely tell you if any changed. Sorry. -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED] Sent: Wednesday, 17 September 2003 23:01 To: Struts Users Mailing List Subject: RE: Design Question Actually you could just store a digest of the previous values, and then compare that with a digest of the new. - 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: Design Question
I have special field objects which with separate methods for jsp setting and database setting which also track changes. Then I can use reflection to the specific type and see if any of the objects in the database changed and are not confused by spurious instance variables. You can then create methods for checkpointing the data so if you have a complex set of updates you can know the status at any point. The main drawback and one I am still working on) is that for reflection to work with the field objects directly they need to be public. The Bean Utils will still work as long as your getters and setters follow the Java Bean spec. Edgar -Original Message- From: sean schofield [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 9:57 AM To: [EMAIL PROTECTED] Subject: Design Question I am working on a struts-based web application and I have an interesting design issue that I'd like to get some feedback on. I think this problem is actually quite generic and there must be some good ideas out there already that I could sponge off! Basically I have a struts form with a bunch of fields that will be presented to the user through the usual JSP-based view. The user will have the opportunity to makes edits and then submit to an action. What I would like to do is be able to identify which fields changed and then take certain actions based on these changes. Here is one rough ideas I have so far. Any thoughts on this plus additional ideas would be greatly appreciated. 1.) Extend ActionForm and customize the populate method so that it makes a copy of the old version of the form that is already stored in the session (since it will have session scope) 2.) Populate new form 3.) Compare two forms and store list of changes in new form 4.) Discard copy of old. Any thoughts, comments? TIA, sean - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: design question
If the values are not going to change during the life of the application, I would suggest using a plugin to set them at startup. See the MailReader Example application for some sample code. -Ted. deepaksawdekar wrote: I am displaying some dropdown boxes on my jsp. I have to take the values for them from ApplicationResource file. I have writen a separate file which will read the properties file and return me the values in array list. Now I have to set this arraylist to the property of my form bean, now the question is should i assign this arraylist in action class execute method or will it good option to assign this value in from bean constructor, since the value are not going to change dynamically. Please suggest me which is better option 1. set values in action execute method 2. set values in constructor of form bean. Thanks and Regards Deepak. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Ted Husted, Junit in Action - http://www.manning.com/massol/, Struts in Action - http://husted.com/struts/book.html, JSP Site Design - http://www.amazon.com/exec/obidos/ISBN=1861005512. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design Question - Need to put assertions in Actions?
Message-ID: [EMAIL PROTECTED] From: White, Joshua A (HTSC, CASD) [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Design Question - Need to put assertions in Actions? Date: Fri, 5 Sep 2003 08:53:49 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Say I have a form formFoo which manages some noun Foo. It has two different actions, newFoo and editFoo. Each has specific logic depending on whether or not Foo exists. I am experiencing a problem where users create Foo, but then (either by bookmark or the back button) users are returning to the newFoo action and edit Foo using the new action instead of the edit action. What about to create a custom tag which, if the newfoo already exists, simply redirect the user to the editfoo form? In any case, take in account that the 'Back' button issue is a known problem among web applications, and that users should be aware of it. My 2 cents, Marco !-- ORIGINAL MESSAGE -- I have looked into the transaction token to eliminate the double submit problem, but I have not found a solution to this problem. So far, I have placed some assertions in the newFoo action which validates that foo does not already exist. If it does exist, it forwards control to editFoo. This brings about the design question. Putting this kind of assertion/redirection logic in each action class gets messy fast and makes each action class more of a controller than an action class. (Which is not where I want to go) Any suggestions on how to handle this type of problem? Regards, Joshua - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design question
| |Now my questions are : |1 I am doing write something wrong. It's better not to club two logically different business process handlers. I guess you want to reduce the number of Action Classes to be created. If yes, follow this way action path=/CreateUser type=navjot.CreateAction form=UserForm parameter=user action path=/CreateProject type=navjot.CreateAction form=ProjectForm parameter=proj In your action class.. String doWhat = mapping.getParameter(); if(proj.equals(doWhat)) proj.create(dto); else if(user.equals(doWhat)) user.create(dto); |2 Validation errors are to be send to called jsp. Like validation |error for create user has to be send to create user jsp, for that |i need to dynamically change the value of input in my action |mapping, how to do this. |3 Since the form beans are different for each jsp can i |dynamically change the formbean of the actionmapping |4 can you suggest some alternate method so that i can not have to |do copy past of my code in execute method of action class. If you follow my advice on 1, you need not to bother about that. HTH navjot Singh PS - may i know where are you located? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design question
Thanks a lot navjot. I will try this. Deepak . -Original Message- From: Navjot Singh [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 26, 2003 11:20 AM To: Struts Users Mailing List Subject: RE: Design question | |Now my questions are : |1 I am doing write something wrong. It's better not to club two logically different business process handlers. I guess you want to reduce the number of Action Classes to be created. If yes, follow this way action path=/CreateUser type=navjot.CreateAction form=UserForm parameter=user action path=/CreateProject type=navjot.CreateAction form=ProjectForm parameter=proj In your action class.. String doWhat = mapping.getParameter(); if(proj.equals(doWhat)) proj.create(dto); else if(user.equals(doWhat)) user.create(dto); |2 Validation errors are to be send to called jsp. Like validation |error for create user has to be send to create user jsp, for that |i need to dynamically change the value of input in my action |mapping, how to do this. |3 Since the form beans are different for each jsp can i |dynamically change the formbean of the actionmapping |4 can you suggest some alternate method so that i can not have to |do copy past of my code in execute method of action class. If you follow my advice on 1, you need not to bother about that. HTH navjot Singh PS - may i know where are you located? - 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: Design question...
hi, If are getting some collection to the JSP page and just wish to display a subset of them without changing anything on BL layer, Use Pager Taglib and get away with it easily. But there is a downside to it as you may have 1000 records and you just want to show 10. So, 990 records are burden on network for no use at all. But you can avoid this also. Pager taglib provides you with one parameter offset that can be passed onto the controller layer and then to your Session EJB. Session EJB will trim the 1000 records collection obtained to 10 records based on that offset value. Now when you pass the DTO back, it will contain maximum 10 records. Reducing network load and you get only those records that you want in presentation layer. HTH navjot singh |-Original Message- |From: Keith Pemberton [mailto:[EMAIL PROTECTED] |Sent: Sunday, August 24, 2003 7:09 PM |To: [EMAIL PROTECTED] |Subject: Design question... | | |I have a JSP page that contains entries from a database. I am getting |the items using a DTO that is passed from a session EJB. What I would |like to be able to do is to specify a parameter in the URL named |offset that when changed would display the next results from the |database. Couple of questions... Would it be considered presentation |logic to perform the action of getting the DTO from the session bean |within the JSP page? I really don't want to do it that way because I'm |trying to keep the layers as separate as possible. So, if I don't do it |that way, I will have to use Action classes and html:links that can pass |the parameter to action class? | |My real question is what is the best way of dealing with EJBs in the |presentation layer? I know that I have to get a DTO of the information |that I want, but usually the methods of the DTO take parameters that I |can't pass to the DTO in the JSP page. I have read over and over the |Oreilly Struts book but it still is confusing me. Thanks for any help! | |Keith Pemberton |-- |Keith Pemberton [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: Design question
There is a workflow extension for struts. I have read the docs, but did not use it. You can take a close look at it here http://www.livinglogic.de/Struts/ Alex. -Original Message- From: David Thielen [mailto:[EMAIL PROTECTED] Sent: Sunday, August 10, 2003 7:18 PM To: Struts-Users Subject: Design question Hi; I am designing a store check-out process. The old software (pre-struts) had a check at the top of each page to make sure the information from the previous page had been entered. And if not, forwarded to that page. So if you bookmarked the last page and went there, you would get forwarded back page by page and still start on the first page. For my new system (using struts), what's the suggested process: 1.. Something like that? Only to be real struts-like I would need to have it go to a page that immediately called an action to see if all data needed for that page was there yet. 2.. Keep a single url so they cannot go to any page other than the first, then the second, etc. In this case, going back in the browser and then clicking reload would take them back to the page they were on. 3.. Just do the standard struts action when they submit a page and in that action go back to the first page for which I have incomplete information. So they can bookmark and click the purchase submit but it would then take them back to the first page of the checkout process. So, what's standard out there? thanks - dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design Question: Forms-and-Validation, which scope to use for dynamic beans?
In your action configuration set the 'input' URL to point to an action instead of your JSP and then build your lists in the action. Steve -Original Message- From: Gino LV. Ledesma [mailto:[EMAIL PROTECTED] Sent: August 10, 2003 10:28 PM To: Struts Users Mailing List Subject: Design Question: Forms-and-Validation, which scope to use for dynamic beans? Hello, I've been using the Struts framework for a couple of months now and have really fancied it. I try as much as possible to adhere to the MVC guidelines, but have run into a couple of problems I've not been able to solve. I have a form which is validated by Struts-validator. One of the form's properties is a pull-down menu which contains list of selectable items. These list of selectable items are generated dynamically (by being called from an EJB). The problem I have is when an error in the form occurs Struts brings back the form page, but the servlet container (Tomcat) then reports a no such bean error -- this bean containing the list of items that populate the pull-down menu. The bean is stored in a request-level scope by the controller servlet. Now when the form is submitted (new request), and an error is found, the form is displayed again. But because the bean was stored in a request-level scope, the bean is no longer found. What is the propery way of fixing this? Currently, I've implemented a tag which generates this list (it basically calls the EJB) and stores it in a page-level scope, so the servlet no longer bothers storing this in any scope. But doesn't doing this break the separate logic from the view rule? I don't want to store it in the session-level scope as well as the list _can_ be updated frequently. Granted, the session-scope seems to be the ideal solution, though. What are your thoughts on this? I'd appreciate help on the matter, as I'm weeding out non-conforming implementations in my code. :) Thanks for your help in advance. = __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com - 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: Design Question: Forms-and-Validation, which scope to use for dynamic beans?
Thanks for the quick reply. Does this work if the action requires additional request parameters, however? Not that my particular servlet will require it, but some of them do. For example, say I have something like: /createObjectB.do?parentID=1 Where ObjectB has ObjectA for its parent (and is necessary for the creation to filter its attributes). Gino LV. Ledesma Ateneo de Manila University // Programmer's Excuse #4: It was working yesterday. --- Steve Raeburn [EMAIL PROTECTED] wrote: In your action configuration set the 'input' URL to point to an action instead of your JSP and then build your lists in the action. Steve -Original Message- From: Gino LV. Ledesma [mailto:[EMAIL PROTECTED] Sent: August 10, 2003 10:28 PM To: Struts Users Mailing List Subject: Design Question: Forms-and-Validation, which scope to use for dynamic beans? Hello, I've been using the Struts framework for a couple of months now and have really fancied it. I try as much as possible to adhere to the MVC guidelines, but have run into a couple of problems I've not been able to solve. I have a form which is validated by Struts-validator. One of the form's properties is a pull-down menu which contains list of selectable items. These list of selectable items are generated dynamically (by being called from an EJB). The problem I have is when an error in the form occurs Struts brings back the form page, but the servlet container (Tomcat) then reports a no such bean error -- this bean containing the list of items that populate the pull-down menu. The bean is stored in a request-level scope by the controller servlet. Now when the form is submitted (new request), and an error is found, the form is displayed again. But because the bean was stored in a request-level scope, the bean is no longer found. What is the propery way of fixing this? Currently, I've implemented a tag which generates this list (it basically calls the EJB) and stores it in a page-level scope, so the servlet no longer bothers storing this in any scope. But doesn't doing this break the separate logic from the view rule? I don't want to store it in the session-level scope as well as the list _can_ be updated frequently. Granted, the session-scope seems to be the ideal solution, though. What are your thoughts on this? I'd appreciate help on the matter, as I'm weeding out non-conforming implementations in my code. :) Thanks for your help in advance. = __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com - 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] = __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design Question
Why not just define the forward action in the selectRecord action mapping element in your struts-config.xml? shane Quoting Erik Price [EMAIL PROTECTED]: Travis Stevens wrote: As you can see, the select a record functionality is common. To implement this I would like to create action classes specifically for the select a record interface. One of the request parameters would be the action to forward the result to. The GET request would look something like this: /action/selectRecord? recordSetName=namefinishedForwardAction=/action/combineRecord This would: 1. display search fields 2. search / display results 3. redirect to the finishedForwardActionPage (would it be better to put the record in the session for the finshedForwardAction or just pass the id as a parameter) Is this an acceptable implementation, or is there a better way? I'm not saying that this is a better way, but it strikes me that selecting a record might not be something that you want to confine to Struts Actions -- for instance, someday down the road you might want to select a record from some other interface or even as a service from another application. You might wish to abstract this even further than the level of Action, and make (for instance) a [POJO] class, such as RecordSelector, that performs this activity. Then you can create Actions specific to your form interfaces, and when it is necessary to select a record, you can use this class to do the work (delegating the information from the Action to the class). This is known as the Command design pattern (in fact Struts Actions are themselves an implementation of the Command design pattern, but they are tightly coupled to the servlet framework). http://www.dofactory.com/Patterns/PatternCommand.aspx This may also spare you the process of supplying a parameter to indicate which Action this should ultimately be forwarded to, since you would just have the form submit to that Action and delegate the work to RecordSelector from inside of that Action. Just a suggestion. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- This mail sent through Toaster-Horde (http://qmailtoaster.clikka.com/) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design Question
Because the foward action should be completely dinamic. The select action should know nothing concrete about any of the actions that use the functionality, otherwise one would have to edit the select action every time a new action is created that uses the select action. [EMAIL PROTECTED] wrote: Why not just define the forward action in the selectRecord action mapping element in your struts-config.xml? shane Quoting Erik Price [EMAIL PROTECTED]: Travis Stevens wrote: As you can see, the select a record functionality is common. To implement this I would like to create action classes specifically for the select a record interface. One of the request parameters would be the action to forward the result to. The GET request would look something like this: /action/selectRecord? recordSetName=namefinishedForwardAction=/action/combineRecord This would: 1. display search fields 2. search / display results 3. redirect to the finishedForwardActionPage (would it be better to put the record in the session for the finshedForwardAction or just pass the id as a parameter) Is this an acceptable implementation, or is there a better way? I'm not saying that this is a better way, but it strikes me that selecting a record might not be something that you want to confine to Struts Actions -- for instance, someday down the road you might want to select a record from some other interface or even as a service from another application. You might wish to abstract this even further than the level of Action, and make (for instance) a [POJO] class, such as RecordSelector, that performs this activity. Then you can create Actions specific to your form interfaces, and when it is necessary to select a record, you can use this class to do the work (delegating the information from the Action to the class). This is known as the Command design pattern (in fact Struts Actions are themselves an implementation of the Command design pattern, but they are tightly coupled to the servlet framework). http://www.dofactory.com/Patterns/PatternCommand.aspx This may also spare you the process of supplying a parameter to indicate which Action this should ultimately be forwarded to, since you would just have the form submit to that Action and delegate the work to RecordSelector from inside of that Action. Just a suggestion. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- This mail sent through Toaster-Horde (http://qmailtoaster.clikka.com/) - 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: Design Question - same action, many jsps/views
Hello, one way to solve it is not to duplicate code in different Action classes, but have many ActionMapping entries in your struts-config.xml file. This way you keep the navigational part of your application away from Action classes, but still avoid code duplication in Actions. HTH, -- Laurent -Original Message- From: Brian McSweeney To: [EMAIL PROTECTED] Sent: 28-7-03 11:38 Subject: Design Question - same action, many jsps/views Hi all, I've come across a situation which I'm not sure how to handle with struts. I have an action which, depending on from which page it's called, should forward to different jsps pages. Currently, for each resultant jsp, I create a new action with the exact same logic code inside which forwards to the right jsp. I'm just not sure if this is the right way to do it, because it's replication of code. An alternative might be to switch on the input path of the request and forward to The right jsp, but I'm not sure if this is right either. This has to have come up before, so I'm looking for a best practice solution. What do you guys reckon? Thanks, Brian - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design Question - same action, many jsps/views
Hi Brian, Why not use different named forwards for the action and access each one from the action with a: { ... return (mapping.findForward(page1/page2/page3)); } In s-c: action path=/myAction type=FQ Class name=bean ... forward name=page1 path=/page1.jsp/ forward name=page2 path=/page2.jsp/ forward name=page3 path=/page3.jsp/ /action Hue. -Original Message- From: Brian McSweeney [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 10:39 To: [EMAIL PROTECTED] Subject: Design Question - same action, many jsps/views Hi all, I've come across a situation which I'm not sure how to handle with struts. I have an action which, depending on from which page it's called, should forward to different jsps pages. Currently, for each resultant jsp, I create a new action with the exact same logic code inside which forwards to the right jsp. I'm just not sure if this is the right way to do it, because it's replication of code. An alternative might be to switch on the input path of the request and forward to The right jsp, but I'm not sure if this is right either. This has to have come up before, so I'm looking for a best practice solution. What do you guys reckon? Thanks, Brian --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design Question - same action, many jsps/views
Hi Hue, That's definitely one way to go, but the disadvantage that I see of using this way is that you presumably have to hard code into the action, some way of identifying where the request came from. Perhaps something like: String input = request.getRequestURI(); if(input.equalsIgnorCase(inputpath1) return (mapping.findForward(page1)); else if(input.equalsIgnorCase(inputpath2); return (mapping.findForward(page2)); else if(input.equalsIgnorCase(inputpath3); return (mapping.findForward(page3)); The previous new action mapping idea means you don't have to do this I think, which might make it a better solution. What do you think? I'm not sure though, and thanks very much for the help. Brian -Original Message- From: Hue Holleran [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 16:11 To: Struts Users Mailing List Subject: RE: Design Question - same action, many jsps/views Hi Brian, Why not use different named forwards for the action and access each one from the action with a: { ... return (mapping.findForward(page1/page2/page3)); } In s-c: action path=/myAction type=FQ Class name=bean ... forward name=page1 path=/page1.jsp/ forward name=page2 path=/page2.jsp/ forward name=page3 path=/page3.jsp/ /action Hue. -Original Message- From: Brian McSweeney [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 10:39 To: [EMAIL PROTECTED] Subject: Design Question - same action, many jsps/views Hi all, I've come across a situation which I'm not sure how to handle with struts. I have an action which, depending on from which page it's called, should forward to different jsps pages. Currently, for each resultant jsp, I create a new action with the exact same logic code inside which forwards to the right jsp. I'm just not sure if this is the right way to do it, because it's replication of code. An alternative might be to switch on the input path of the request and forward to The right jsp, but I'm not sure if this is right either. This has to have come up before, so I'm looking for a best practice solution. What do you guys reckon? Thanks, Brian --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 - 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: Design Question - same action, many jsps/views
I used a design I called the side trip action. Basically any caller to the action has placed, either in a form field or in the user session object, a from and dest url. the action does what it needs to do, redirects errors back to from, and then forwards on success to dest. I called this the Side trip because I originally used it for a small bit of intelligence -- you go to a page that requires you to be logged in.. you're sent to the login page.. and after a successful login, you're sent back to where you started from. From: Brian McSweeney [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Subject: RE: Design Question - same action, many jsps/views Date: Mon, 28 Jul 2003 16:26:52 +0100 Hi Hue, That's definitely one way to go, but the disadvantage that I see of using this way is that you presumably have to hard code into the action, some way of identifying where the request came from. Perhaps something like: String input = request.getRequestURI(); if(input.equalsIgnorCase(inputpath1) return (mapping.findForward(page1)); else if(input.equalsIgnorCase(inputpath2); return (mapping.findForward(page2)); else if(input.equalsIgnorCase(inputpath3); return (mapping.findForward(page3)); The previous new action mapping idea means you don't have to do this I think, which might make it a better solution. What do you think? I'm not sure though, and thanks very much for the help. Brian -Original Message- From: Hue Holleran [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 16:11 To: Struts Users Mailing List Subject: RE: Design Question - same action, many jsps/views Hi Brian, Why not use different named forwards for the action and access each one from the action with a: { ... return (mapping.findForward(page1/page2/page3)); } In s-c: action path=/myAction type=FQ Class name=bean ... forward name=page1 path=/page1.jsp/ forward name=page2 path=/page2.jsp/ forward name=page3 path=/page3.jsp/ /action Hue. -Original Message- From: Brian McSweeney [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 10:39 To: [EMAIL PROTECTED] Subject: Design Question - same action, many jsps/views Hi all, I've come across a situation which I'm not sure how to handle with struts. I have an action which, depending on from which page it's called, should forward to different jsps pages. Currently, for each resultant jsp, I create a new action with the exact same logic code inside which forwards to the right jsp. I'm just not sure if this is the right way to do it, because it's replication of code. An alternative might be to switch on the input path of the request and forward to The right jsp, but I'm not sure if this is right either. This has to have come up before, so I'm looking for a best practice solution. What do you guys reckon? Thanks, Brian --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 - 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] _ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design Question - same action, many jsps/views
Hi Brian, Yes - I can see your point. Whenever I need to do this (with multi-page forms, for instance - where the Next button should forward to the next page) - I use a property on the form, from memory it might be currentPage (which is numeric for me) that is held as a hidden form property that is used to do the from logic you are describing. Ok, this was done specifically as we are using tiles, as I believe this may confuse the getRequestURI() return value(?). The alternative may be to use the dispatcher to define a specific entry point in your action that can call some generic code (i.e. that presumably you're now concerned about duplicating - and I agree with your concerns) - and then forward to the correct forward? Alternatively the struts-workflow extensions may provide additional clues for you on how this may be done. From memory, we were discouraged from using this as it had several pre-requisites, like appending something to every action and actions needing to work in a particular way that was too much work for us (and I think there some issues using it with tiles?). I think the new version integrates much better with 1.1 so this may be worth a look, too? URL in case you don't have it: http://www.livinglogic.de/Struts Hue. -Original Message- From: Brian McSweeney [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 16:27 To: 'Struts Users Mailing List' Subject: RE: Design Question - same action, many jsps/views Hi Hue, That's definitely one way to go, but the disadvantage that I see of using this way is that you presumably have to hard code into the action, some way of identifying where the request came from. Perhaps something like: String input = request.getRequestURI(); if(input.equalsIgnorCase(inputpath1) return (mapping.findForward(page1)); else if(input.equalsIgnorCase(inputpath2); return (mapping.findForward(page2)); else if(input.equalsIgnorCase(inputpath3); return (mapping.findForward(page3)); The previous new action mapping idea means you don't have to do this I think, which might make it a better solution. What do you think? I'm not sure though, and thanks very much for the help. Brian -Original Message- From: Hue Holleran [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 16:11 To: Struts Users Mailing List Subject: RE: Design Question - same action, many jsps/views Hi Brian, Why not use different named forwards for the action and access each one from the action with a: { ... return (mapping.findForward(page1/page2/page3)); } In s-c: action path=/myAction type=FQ Class name=bean ... forward name=page1 path=/page1.jsp/ forward name=page2 path=/page2.jsp/ forward name=page3 path=/page3.jsp/ /action Hue. -Original Message- From: Brian McSweeney [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 10:39 To: [EMAIL PROTECTED] Subject: Design Question - same action, many jsps/views Hi all, I've come across a situation which I'm not sure how to handle with struts. I have an action which, depending on from which page it's called, should forward to different jsps pages. Currently, for each resultant jsp, I create a new action with the exact same logic code inside which forwards to the right jsp. I'm just not sure if this is the right way to do it, because it's replication of code. An alternative might be to switch on the input path of the request and forward to The right jsp, but I'm not sure if this is right either. This has to have come up before, so I'm looking for a best practice solution. What do you guys reckon? Thanks, Brian --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 - 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] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design Question - same action, many jsps/views
Using tiles and 1.1 I currently am working on a project which uses DispatchAction extensively. In the action classes which extend DispatchAction I have 3 methods: 1. init() - which initializes form data, etc. 2. update() - which does some business logic based on a form selection. 3. submitForm() - which does some validation and other associated logic on the completed data. In the struts-config.xml I have 3 forwards defined: 1. success - defaults to the jsp associated with the action 2. failure - same jsp as above if there is a validation failure 3. nextAction - fowards to the next action in the flow ...usually something like /action/Action?method=init Maybe this will give you some idea for your design? HTH, Shane -Original Message- From: Hue Holleran [mailto:[EMAIL PROTECTED] Sent: Monday, July 28, 2003 1:40 PM To: Struts Users Mailing List Subject: RE: Design Question - same action, many jsps/views Hi Brian, Yes - I can see your point. Whenever I need to do this (with multi-page forms, for instance - where the Next button should forward to the next page) - I use a property on the form, from memory it might be currentPage (which is numeric for me) that is held as a hidden form property that is used to do the from logic you are describing. Ok, this was done specifically as we are using tiles, as I believe this may confuse the getRequestURI() return value(?). The alternative may be to use the dispatcher to define a specific entry point in your action that can call some generic code (i.e. that presumably you're now concerned about duplicating - and I agree with your concerns) - and then forward to the correct forward? Alternatively the struts-workflow extensions may provide additional clues for you on how this may be done. From memory, we were discouraged from using this as it had several pre-requisites, like appending something to every action and actions needing to work in a particular way that was too much work for us (and I think there some issues using it with tiles?). I think the new version integrates much better with 1.1 so this may be worth a look, too? URL in case you don't have it: http://www.livinglogic.de/Struts Hue. -Original Message- From: Brian McSweeney [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 16:27 To: 'Struts Users Mailing List' Subject: RE: Design Question - same action, many jsps/views Hi Hue, That's definitely one way to go, but the disadvantage that I see of using this way is that you presumably have to hard code into the action, some way of identifying where the request came from. Perhaps something like: String input = request.getRequestURI(); if(input.equalsIgnorCase(inputpath1) return (mapping.findForward(page1)); else if(input.equalsIgnorCase(inputpath2); return (mapping.findForward(page2)); else if(input.equalsIgnorCase(inputpath3); return (mapping.findForward(page3)); The previous new action mapping idea means you don't have to do this I think, which might make it a better solution. What do you think? I'm not sure though, and thanks very much for the help. Brian -Original Message- From: Hue Holleran [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 16:11 To: Struts Users Mailing List Subject: RE: Design Question - same action, many jsps/views Hi Brian, Why not use different named forwards for the action and access each one from the action with a: { ... return (mapping.findForward(page1/page2/page3)); } In s-c: action path=/myAction type=FQ Class name=bean ... forward name=page1 path=/page1.jsp/ forward name=page2 path=/page2.jsp/ forward name=page3 path=/page3.jsp/ /action Hue. -Original Message- From: Brian McSweeney [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 10:39 To: [EMAIL PROTECTED] Subject: Design Question - same action, many jsps/views Hi all, I've come across a situation which I'm not sure how to handle with struts. I have an action which, depending on from which page it's called, should forward to different jsps pages. Currently, for each resultant jsp, I create a new action with the exact same logic code inside which forwards to the right jsp. I'm just not sure if this is the right way to do it, because it's replication of code. An alternative might be to switch on the input path of the request and forward to The right jsp, but I'm not sure if this is right either. This has to have come up before, so I'm looking for a best practice solution. What do you guys reckon? Thanks, Brian --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003
Re: Design question: Confirm action after validation ?
I have an Action base class which all my other Action classes inherit. In the execute() of this base class I check whether the user clicked cancel, before I call the child class execute(). I presume it would be easy enough to store the originating URL in the session, and if cancel is clicked, roll your own Action Forward back to this URL. Since it is all in the base class, it could work for every action as long as you are careful to watch the parameters or ids. Ajay Patil wrote: Hello, In my Struts application, the validation is done on server-side for every page. If the validation is successful, the user would like to see a page to confirm his action. The Confirm page should also have a Cancel button allowing him to go back to the previous page showing the data entered so far. This functionality is needed for every action. I am thinking if there is a generic way by which I can achieve this functionality. I also realize that I might end up making scope=session for every form, in trying to implement this requirement. (and I am worried about this too). Any ideas, pointers and/or thoughts will be very useful. Ajay Ajay Patil Vertex Software Pvt. Ltd. [EMAIL PROTECTED] http://www.vertex.co.in - 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: Design question: Confirm action after validation ?
Hello Adam I have one doubt. You have base action class for all your subaction classes. What is the responsibility of this base action class. Do your base action class checks which button is clicked? If there are say 10 buttons in one form (say, GO, ADD, SAVE, NEXT, etc) are there 10 if statements in your class. Or it is sub action class resposibility to check this.? are there 10 or (any no) of if statements in subaction classes.? How to eliminate those if statements? any idea? Pls reply Shashank - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 2:52 PM Subject: Re: Design question: Confirm action after validation ? I have an Action base class which all my other Action classes inherit. In the execute() of this base class I check whether the user clicked cancel, before I call the child class execute(). I presume it would be easy enough to store the originating URL in the session, and if cancel is clicked, roll your own Action Forward back to this URL. Since it is all in the base class, it could work for every action as long as you are careful to watch the parameters or ids. Ajay Patil wrote: Hello, In my Struts application, the validation is done on server-side for every page. If the validation is successful, the user would like to see a page to confirm his action. The Confirm page should also have a Cancel button allowing him to go back to the previous page showing the data entered so far. This functionality is needed for every action. I am thinking if there is a generic way by which I can achieve this functionality. I also realize that I might end up making scope=session for every form, in trying to implement this requirement. (and I am worried about this too). Any ideas, pointers and/or thoughts will be very useful. Ajay Ajay Patil Vertex Software Pvt. Ltd. [EMAIL PROTECTED] http://www.vertex.co.in - 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: Design question: Confirm action after validation ?
my base action class sorts out all the general objects and variables that the child actions need - this is the child action's execute() signature: public String executeList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, BlackSailUser user, Locale locale, MessageResources messages, ActionErrors errors, Connection conn) throws Exception I guess the list of responsibilites for the base action superclass is: (1) establish the action to carry out (your GO, ADD, SAVE etc) which is a token that is set by any of a request parameter, request attribute, action mapping parameter, or cancel button. (2) get a jdbc connection object from pool (3) get message resources from request (4) get locale from request (5) get user object from session (6) get errors from request (7) error handling (I don't have any in my subclasses) (8) get any lists for drop-down boxes (a seperate call to subclass) Had to check that out by looking at the code. It served me fine since my first struts app. Shashank Dixit wrote: Hello Adam I have one doubt. You have base action class for all your subaction classes. What is the responsibility of this base action class. Do your base action class checks which button is clicked? If there are say 10 buttons in one form (say, GO, ADD, SAVE, NEXT, etc) are there 10 if statements in your class. Or it is sub action class resposibility to check this.? are there 10 or (any no) of if statements in subaction classes.? How to eliminate those if statements? any idea? Pls reply Shashank - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 2:52 PM Subject: Re: Design question: Confirm action after validation ? I have an Action base class which all my other Action classes inherit. In the execute() of this base class I check whether the user clicked cancel, before I call the child class execute(). I presume it would be easy enough to store the originating URL in the session, and if cancel is clicked, roll your own Action Forward back to this URL. Since it is all in the base class, it could work for every action as long as you are careful to watch the parameters or ids. Ajay Patil wrote: Hello, In my Struts application, the validation is done on server-side for every page. If the validation is successful, the user would like to see a page to confirm his action. The Confirm page should also have a Cancel button allowing him to go back to the previous page showing the data entered so far. This functionality is needed for every action. I am thinking if there is a generic way by which I can achieve this functionality. I also realize that I might end up making scope=session for every form, in trying to implement this requirement. (and I am worried about this too). Any ideas, pointers and/or thoughts will be very useful. Ajay Ajay Patil Vertex Software Pvt. Ltd. [EMAIL PROTECTED] http://www.vertex.co.in - 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: Design question: Confirm action after validation ?
Hi again Are you using EJBs?? If you are using EJB, where is the connection pool? At webserver side or app server side. Or where datasource is defined. at web server or app server? How you are taking data(Value Objects) from webserver to appserver Shashank - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 3:26 PM Subject: Re: Design question: Confirm action after validation ? my base action class sorts out all the general objects and variables that the child actions need - this is the child action's execute() signature: public String executeList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, BlackSailUser user, Locale locale, MessageResources messages, ActionErrors errors, Connection conn) throws Exception I guess the list of responsibilites for the base action superclass is: (1) establish the action to carry out (your GO, ADD, SAVE etc) which is a token that is set by any of a request parameter, request attribute, action mapping parameter, or cancel button. (2) get a jdbc connection object from pool (3) get message resources from request (4) get locale from request (5) get user object from session (6) get errors from request (7) error handling (I don't have any in my subclasses) (8) get any lists for drop-down boxes (a seperate call to subclass) Had to check that out by looking at the code. It served me fine since my first struts app. Shashank Dixit wrote: Hello Adam I have one doubt. You have base action class for all your subaction classes. What is the responsibility of this base action class. Do your base action class checks which button is clicked? If there are say 10 buttons in one form (say, GO, ADD, SAVE, NEXT, etc) are there 10 if statements in your class. Or it is sub action class resposibility to check this.? are there 10 or (any no) of if statements in subaction classes.? How to eliminate those if statements? any idea? Pls reply Shashank - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 2:52 PM Subject: Re: Design question: Confirm action after validation ? I have an Action base class which all my other Action classes inherit. In the execute() of this base class I check whether the user clicked cancel, before I call the child class execute(). I presume it would be easy enough to store the originating URL in the session, and if cancel is clicked, roll your own Action Forward back to this URL. Since it is all in the base class, it could work for every action as long as you are careful to watch the parameters or ids. Ajay Patil wrote: Hello, In my Struts application, the validation is done on server-side for every page. If the validation is successful, the user would like to see a page to confirm his action. The Confirm page should also have a Cancel button allowing him to go back to the previous page showing the data entered so far. This functionality is needed for every action. I am thinking if there is a generic way by which I can achieve this functionality. I also realize that I might end up making scope=session for every form, in trying to implement this requirement. (and I am worried about this too). Any ideas, pointers and/or thoughts will be very useful. Ajay Ajay Patil Vertex Software Pvt. Ltd. [EMAIL PROTECTED] http://www.vertex.co.in - 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: Design question: Confirm action after validation ?
I plan on using EJB but haven't got that far yet. At the moment I am using a bunch of 'factory' classes as my model, and would like to isolate this layer from the request, response objects etc in the actions. So the fact that I get the connection in the base action is a legacy thing - I thought about changing it and probably will soon, to a strategy where the actions don't see the connection. I changed the database configuration so that the pool is a JNDI resource, but I haven't got around to this second bit yet because the interface between the actions and the factories requires more thought as to how I marshall the data across. Adam Shashank Dixit wrote: Hi again Are you using EJBs?? If you are using EJB, where is the connection pool? At webserver side or app server side. Or where datasource is defined. at web server or app server? How you are taking data(Value Objects) from webserver to appserver Shashank - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 3:26 PM Subject: Re: Design question: Confirm action after validation ? my base action class sorts out all the general objects and variables that the child actions need - this is the child action's execute() signature: public String executeList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, BlackSailUser user, Locale locale, MessageResources messages, ActionErrors errors, Connection conn) throws Exception I guess the list of responsibilites for the base action superclass is: (1) establish the action to carry out (your GO, ADD, SAVE etc) which is a token that is set by any of a request parameter, request attribute, action mapping parameter, or cancel button. (2) get a jdbc connection object from pool (3) get message resources from request (4) get locale from request (5) get user object from session (6) get errors from request (7) error handling (I don't have any in my subclasses) (8) get any lists for drop-down boxes (a seperate call to subclass) Had to check that out by looking at the code. It served me fine since my first struts app. Shashank Dixit wrote: Hello Adam I have one doubt. You have base action class for all your subaction classes. What is the responsibility of this base action class. Do your base action class checks which button is clicked? If there are say 10 buttons in one form (say, GO, ADD, SAVE, NEXT, etc) are there 10 if statements in your class. Or it is sub action class resposibility to check this.? are there 10 or (any no) of if statements in subaction classes.? How to eliminate those if statements? any idea? Pls reply Shashank - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 2:52 PM Subject: Re: Design question: Confirm action after validation ? I have an Action base class which all my other Action classes inherit. In the execute() of this base class I check whether the user clicked cancel, before I call the child class execute(). I presume it would be easy enough to store the originating URL in the session, and if cancel is clicked, roll your own Action Forward back to this URL. Since it is all in the base class, it could work for every action as long as you are careful to watch the parameters or ids. Ajay Patil wrote: Hello, In my Struts application, the validation is done on server-side for every page. If the validation is successful, the user would like to see a page to confirm his action. The Confirm page should also have a Cancel button allowing him to go back to the previous page showing the data entered so far. This functionality is needed for every action. I am thinking if there is a generic way by which I can achieve this functionality. I also realize that I might end up making scope=session for every form, in trying to implement this requirement. (and I am worried about this too). Any ideas, pointers and/or thoughts will be very useful. Ajay Ajay Patil Vertex Software Pvt. Ltd. [EMAIL PROTECTED] http://www.vertex.co.in - 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: design question about action chaining
On Tuesday 01 April 2003 02:30 pm, Thorin Linderholm wrote: I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different bits of logic to whole sets of pages. Some of those 'bits of logic' (actions if you will,) interrupt the process and forward to a different page (page access rules for instance.) There are several possible solutions that I've come up with, but so far all of them involve either hacks, extending struts (which happens to partialy eliminate the reason I'm being required to move to Struts, and so isn't very favored by my supperiors,) some complicated java inheritance hierarchy where I inherit non-related functionality in those ten actions into a set of compound actions, each inheriting in the set of functionality we want (lame,) or I could implement a 'view preprocessor' of some kind that parallels the struts-config and defines processing that I need to do for each view page (which requires me to have two completely redundant sets of page mappings, and apears to me to obsolete the need for Struts in the first place (if we were to ignore it's tag libraries and other helper classes which we also already have proprietary equivalents to.) I'd love to hear from anyone about other possibilities, or (even better,) pointers to somebody/some package already solving this problem. Another way to look at the whole thing: How have other people solved the problem of being able to apply a set of page access rules to arbitrary sets of pages without having to create a system parallel to struts that re-defines every page in the application? Or do people consider a parallel system that respecifies every page as the proper design? Thorin Ever thought of defining functionality equivalent to your proprietory actions in classes that don't extend the Struts framework and chaining calls to instances of these classes in your Struts Actions? This is a static solution as opposed to having struts-config.xml support some sort of action chaining tags but Struts Actions are only HTTP adapters, and chaining them violates the spirit of the framework. That's why I think implementing chaining with non-Struts classes is a better idea. Your actions seem to be pretty fine-grained (Ensure Session initialization has been completed/Initialize session). If session in this case refers to the HttpSession, then they are almost as low-level as the Servlet API (why?). If they are a business tier concept, Struts should have nothing to do with chaining them. Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: design question about action chaining
I think Filters would be a good choice for your needs. You can define a filter for each piece of logic and then configure them in web.xml for groups of pages. You'll need to put related pages in the same path scheme so that you can map a filter to the group instead of each page. David From: Thorin Linderholm [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: design question about action chaining Date: Tue, 1 Apr 2003 11:30:39 -0800 I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different bits of logic to whole sets of pages. Some of those 'bits of logic' (actions if you will,) interrupt the process and forward to a different page (page access rules for instance.) There are several possible solutions that I've come up with, but so far all of them involve either hacks, extending struts (which happens to partialy eliminate the reason I'm being required to move to Struts, and so isn't very favored by my supperiors,) some complicated java inheritance hierarchy where I inherit non-related functionality in those ten actions into a set of compound actions, each inheriting in the set of functionality we want (lame,) or I could implement a 'view preprocessor' of some kind that parallels the struts-config and defines processing that I need to do for each view page (which requires me to have two completely redundant sets of page mappings, and apears to me to obsolete the need for Struts in the first place (if we were to ignore it's tag libraries and other helper classes which we also already have proprietary equivalents to.) I'd love to hear from anyone about other possibilities, or (even better,) pointers to somebody/some package already solving this problem. Another way to look at the whole thing: How have other people solved the problem of being able to apply a set of page access rules to arbitrary sets of pages without having to create a system parallel to struts that re-defines every page in the application? Or do people consider a parallel system that respecifies every page as the proper design? Thorin - 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: design question about action chaining
The static method you suggest would be very cumbersome to implement and maintain, requiring hard-coding calls to each bit of functionality I wanted on each page (aghh!) But thanks for the reply :-) I have to disagree that 'If they are a business tier concept, Struts should have nothing to do with chaining them.' The struts ActionServlet and the page mappings in the struts-config are the 'controller' portion of Struts. The whole of Struts is much more than the 'C' in MVC. It has taglibs for supporting the V, and actions are in fact always implementing buisness logic (they decide what page to go to by returning a 'forward': definite buisness logic, if there is such a thing.) And that's always been a gray area in MVC for me: does all the buisness logic belong in the model, or can it also go in the controller? Or is there an MVCC where there is a 'view' controller and 'buisness' controller (which seems a bit redundant to me.) -Original Message- From: Paul Yunusov [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 11:43 AM To: Struts Users Mailing List Subject: Re: design question about action chaining On Tuesday 01 April 2003 02:30 pm, Thorin Linderholm wrote: I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different bits of logic to whole sets of pages. Some of those 'bits of logic' (actions if you will,) interrupt the process and forward to a different page (page access rules for instance.) There are several possible solutions that I've come up with, but so far all of them involve either hacks, extending struts (which happens to partialy eliminate the reason I'm being required to move to Struts, and so isn't very favored by my supperiors,) some complicated java inheritance hierarchy where I inherit non-related functionality in those ten actions into a set of compound actions, each inheriting in the set of functionality we want (lame,) or I could implement a 'view preprocessor' of some kind that parallels the struts-config and defines processing that I need to do for each view page (which requires me to have two completely redundant sets of page mappings, and apears to me to obsolete the need for Struts in the first place (if we were to ignore it's tag libraries and other helper classes which we also already have proprietary equivalents to.) I'd love to hear from anyone about other possibilities, or (even better,) pointers to somebody/some package already solving this problem. Another way to look at the whole thing: How have other people solved the problem of being able to apply a set of page access rules to arbitrary sets of pages without having to create a system parallel to struts that re-defines every page in the application? Or do people consider a parallel system that respecifies every page as the proper design? Thorin Ever thought of defining functionality equivalent to your proprietory actions in classes that don't extend the Struts framework and chaining calls to instances of these classes in your Struts Actions? This is a static solution as opposed to having struts-config.xml support some sort of action chaining tags but Struts Actions are only HTTP adapters, and chaining them violates the spirit of the framework. That's why I think implementing chaining with non-Struts classes is a better idea. Your actions seem to be pretty fine-grained (Ensure Session initialization has been completed/Initialize session). If session in this case refers to the HttpSession, then they are almost as low-level as the Servlet API (why?). If they are a business tier concept, Struts should have nothing to do with chaining them
RE: design question about action chaining
I had come to the conclusion that Struts Actions are moreover 'View Adapter Components' or VAC's (you can quote me on that one!) and should not be relied on for handling business logic or data collection by any means, just as a facsimile for pulling model/controller data into the view. I wrote a logical framework that runs under the same premise as Ant's targets and depends attributes (storingUser depends on validateUser). My LogicalAction class allowed properties to be set through normal means with the struts-config w/ a plugin too, that would have a comma delimited list of 'modules' to execute. Using the Filter Pattern and FilterChain-type object, LogicalActions are provided with an executeLogic() method that throws an exception. So basically, your struts-config defines the controller calls per action, but the controllers are actually referenced in a separate document that defines their dependency. Keeping your business logic separate, you may want to create a separate DTO object that wraps the http request, much like torque uses. BTW, only after writing this framework did I see that turbine has this framework already built with valves and pipelines: http://jakarta.apache.org/turbine/turbine-3/pipeline.html -Jacob | -Original Message- | From: Thorin Linderholm [mailto:[EMAIL PROTECTED] | Sent: Tuesday, April 01, 2003 1:31 PM | To: '[EMAIL PROTECTED]' | Subject: design question about action chaining | | | I have been tasked with porting an existing web application with it's own | proprietary controller architecture to using Struts. | | As they are both web controller architectures, they have many | similarities, | but I'm running into one difference in overall architecture that I'm | having | difficulty resolving. | | This difficulty is most closely related to the 'action chaining' posts | I've | been able to find in the mailing list archives. | | Specifically, I have over 400 pages mapped to various actions (our | controller calls them that, and they're roughly synonymous with struts | actions.) However, our controller allows specifying a list of actions to | execute on a per-page, and per-page-set basis. In other words, we can | assign an action like 'Ensure Session initialization has been | completed/Initialize session' to every page in the site with a single | mapping (assuming you've already listed all the pages.) Or you can assign | it to 90% of your pages if you happen to desire. We have approximatly ten | actions that happen on between 60-99% of the pages on our site. If we | were | to directly translate this to the struts mapping system we would end up | having to re-specify those ten actions on most of those 400+ pages, | creating | long action chains for each page (a whole lot of duplication: hard to | maintain, easy to get wrong, etc.) | | So, conceptually, I want to be able to apply a few different bits of logic | to whole sets of pages. Some of those 'bits of logic' (actions if you | will,) interrupt the process and forward to a different page (page access | rules for instance.) | | There are several possible solutions that I've come up with, but so far | all | of them involve either hacks, extending struts (which happens to partialy | eliminate the reason I'm being required to move to Struts, and so isn't | very | favored by my supperiors,) some complicated java inheritance hierarchy | where | I inherit non-related functionality in those ten actions into a set of | compound actions, each inheriting in the set of functionality we want | (lame,) or I could implement a 'view preprocessor' of some kind that | parallels the struts-config and defines processing that I need to do for | each view page (which requires me to have two completely redundant sets of | page mappings, and apears to me to obsolete the need for Struts in the | first | place (if we were to ignore it's tag libraries and other helper classes | which we also already have proprietary equivalents to.) | | I'd love to hear from anyone about other possibilities, or (even better,) | pointers to somebody/some package already solving this problem. | | Another way to look at the whole thing: How have other people solved the | problem of being able to apply a set of page access rules to arbitrary | sets | of pages without having to create a system parallel to struts that | re-defines every page in the application? Or do people consider a | parallel | system that respecifies every page as the proper design? | | Thorin | | | - | 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: design question about action chaining
Filters are one of the design/imp choices I've considered under the 'parallel system' heading, though I hadn't thought of trying to use the web.xml for this. I'd have to look into these more. I take it you recomending that a second, parallel system of specifying functionality on a per-page or per-page-set basis is the way to go? What reasons would you have for this design choice, as opposed to extending struts to contain this functionality? Have you (or others,) implemented something similar to this? (This port is going to be a large chunk of time and I'm just trying to find out if other people have already thought through and implemented this type of functionality before I just pick something, run with it, and end up with some kind of maintenance or design nightmare :-) -Original Message- From: David Graham [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 11:52 AM To: [EMAIL PROTECTED] Subject: Re: design question about action chaining I think Filters would be a good choice for your needs. You can define a filter for each piece of logic and then configure them in web.xml for groups of pages. You'll need to put related pages in the same path scheme so that you can map a filter to the group instead of each page. David From: Thorin Linderholm [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: design question about action chaining Date: Tue, 1 Apr 2003 11:30:39 -0800 I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different bits of logic to whole sets of pages. Some of those 'bits of logic' (actions if you will,) interrupt the process and forward to a different page (page access rules for instance.) There are several possible solutions that I've come up with, but so far all of them involve either hacks, extending struts (which happens to partialy eliminate the reason I'm being required to move to Struts, and so isn't very favored by my supperiors,) some complicated java inheritance hierarchy where I inherit non-related functionality in those ten actions into a set of compound actions, each inheriting in the set of functionality we want (lame,) or I could implement a 'view preprocessor' of some kind that parallels the struts-config and defines processing that I need to do for each view page (which requires me to have two completely redundant sets of page mappings, and apears to me to obsolete the need for Struts in the first place (if we were to ignore it's tag libraries and other helper classes which we also already have proprietary equivalents to.) I'd love to hear from anyone about other possibilities, or (even better,) pointers to somebody/some package already solving this problem. Another way to look at the whole thing: How have other people solved the problem of being able to apply a set of page access rules to arbitrary sets of pages without having to create a system parallel to struts that re-defines every page in the application? Or do people consider a parallel system that respecifies every page as the proper design? Thorin - 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: design question about action chaining
On Tuesday 01 April 2003 03:00 pm, Thorin Linderholm wrote: The static method you suggest would be very cumbersome to implement and maintain, requiring hard-coding calls to each bit of functionality I wanted on each page (aghh!) But thanks for the reply :-) I have to disagree that 'If they are a business tier concept, Struts should have nothing to do with chaining them.' The struts ActionServlet and the page mappings in the struts-config are the 'controller' portion of Struts. The whole of Struts is much more than the 'C' in MVC. It has taglibs for supporting the V, and actions are in fact always implementing buisness logic (they decide what page to go to by returning a 'forward': definite buisness logic, if there is such a thing.) And that's always been a gray area in MVC for me: does all the buisness logic belong in the model, or can it also go in the controller? Or is there an MVCC where there is a 'view' controller and 'buisness' controller (which seems a bit redundant to me.) Well, at one point you will wonder which is more cumbersome: coding Action classes or having a mile-long struts-config.xml. Paul -Original Message- From: Paul Yunusov [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 11:43 AM To: Struts Users Mailing List Subject: Re: design question about action chaining On Tuesday 01 April 2003 02:30 pm, Thorin Linderholm wrote: I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different bits of logic to whole sets of pages. Some of those 'bits of logic' (actions if you will,) interrupt the process and forward to a different page (page access rules for instance.) There are several possible solutions that I've come up with, but so far all of them involve either hacks, extending struts (which happens to partialy eliminate the reason I'm being required to move to Struts, and so isn't very favored by my supperiors,) some complicated java inheritance hierarchy where I inherit non-related functionality in those ten actions into a set of compound actions, each inheriting in the set of functionality we want (lame,) or I could implement a 'view preprocessor' of some kind that parallels the struts-config and defines processing that I need to do for each view page (which requires me to have two completely redundant sets of page mappings, and apears to me to obsolete the need for Struts in the first place (if we were to ignore it's tag libraries and other helper classes which we also already have proprietary equivalents to.) I'd love to hear from anyone about other possibilities, or (even better,) pointers to somebody/some package already solving this problem. Another way to look at the whole thing: How have other people solved the problem of being able to apply a set of page access rules to arbitrary sets of pages without having to create a system parallel to struts that re-defines every page in the application? Or do people consider a parallel system that respecifies every page as the proper design? Thorin Ever thought of defining functionality equivalent to your proprietory actions in classes that don't extend the Struts framework and chaining calls to instances of these classes in your Struts Actions? This is a static solution as opposed to having struts-config.xml support some sort of action chaining tags but Struts Actions are only HTTP adapters, and chaining them violates the spirit of the framework. That's why I think implementing chaining with non-Struts classes is a better idea. Your actions seem
Re: design question about action chaining
You can not possibly imagine how useful and powerful can be good GUI tool when you handle really big and cumbersome struts-config file. Actually it can give you much more capability to implement such pipes, filers and assembling of application from pre-defined action components. Best, Igor. http://www.exadel.com http://www.exadel.com/products_strutsstudio.htm On Tue, 1 Apr 2003 15:12:34 -0500, Paul Yunusov [EMAIL PROTECTED] wrote: On Tuesday 01 April 2003 03:00 pm, Thorin Linderholm wrote: The static method you suggest would be very cumbersome to implement and maintain, requiring hard-coding calls to each bit of functionality I wanted on each page (aghh!) But thanks for the reply :-) I have to disagree that 'If they are a business tier concept, Struts should have nothing to do with chaining them.' The struts ActionServlet and the page mappings in the struts-config are the 'controller' portion of Struts. The whole of Struts is much more than the 'C' in MVC. It has taglibs for supporting the V, and actions are in fact always implementing buisness logic (they decide what page to go to by returning a 'forward': definite buisness logic, if there is such a thing.) And that's always been a gray area in MVC for me: does all the buisness logic belong in the model, or can it also go in the controller? Or is there an MVCC where there is a 'view' controller and 'buisness' controller (which seems a bit redundant to me.) Well, at one point you will wonder which is more cumbersome: coding Action classes or having a mile-long struts-config.xml. Paul -Original Message- From: Paul Yunusov [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 11:43 AM To: Struts Users Mailing List Subject: Re: design question about action chaining On Tuesday 01 April 2003 02:30 pm, Thorin Linderholm wrote: I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different bits of logic to whole sets of pages. Some of those 'bits of logic' (actions if you will,) interrupt the process and forward to a different page (page access rules for instance.) There are several possible solutions that I've come up with, but so far all of them involve either hacks, extending struts (which happens to partialy eliminate the reason I'm being required to move to Struts, and so isn't very favored by my supperiors,) some complicated java inheritance hierarchy where I inherit non-related functionality in those ten actions into a set of compound actions, each inheriting in the set of functionality we want (lame,) or I could implement a 'view preprocessor' of some kind that parallels the struts-config and defines processing that I need to do for each view page (which requires me to have two completely redundant sets of page mappings, and apears to me to obsolete the need for Struts in the first place (if we were to ignore it's tag libraries and other helper classes which we also already have proprietary equivalents to.) I'd love to hear from anyone about other possibilities, or (even better,) pointers to somebody/some package already solving this problem. Another way to look at the whole thing: How have other people solved the problem of being able to apply a set of page access rules to arbitrary sets of pages without having to create a system parallel to struts that re-defines every page in the application? Or do people consider a parallel system that respecifies every page as the proper design? Thorin Ever thought of defining functionality equivalent to your proprietory actions in classes that don't extend the Struts
RE: design question about action chaining
You need to understand what Struts does for you. The Action classes are *not* for business logic, they are part of the controller and define page flow and call business logic methods. If you need special authentication, logging, etc. for particular views then a filter is your best choice. Filters aren't a parallel system to Struts because they logically sit in front of Struts handling requests before Struts gets them. David From: Thorin Linderholm [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Subject: RE: design question about action chaining Date: Tue, 1 Apr 2003 12:08:09 -0800 Filters are one of the design/imp choices I've considered under the 'parallel system' heading, though I hadn't thought of trying to use the web.xml for this. I'd have to look into these more. I take it you recomending that a second, parallel system of specifying functionality on a per-page or per-page-set basis is the way to go? What reasons would you have for this design choice, as opposed to extending struts to contain this functionality? Have you (or others,) implemented something similar to this? (This port is going to be a large chunk of time and I'm just trying to find out if other people have already thought through and implemented this type of functionality before I just pick something, run with it, and end up with some kind of maintenance or design nightmare :-) -Original Message- From: David Graham [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 11:52 AM To: [EMAIL PROTECTED] Subject: Re: design question about action chaining I think Filters would be a good choice for your needs. You can define a filter for each piece of logic and then configure them in web.xml for groups of pages. You'll need to put related pages in the same path scheme so that you can map a filter to the group instead of each page. David From: Thorin Linderholm [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: design question about action chaining Date: Tue, 1 Apr 2003 11:30:39 -0800 I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different bits of logic to whole sets of pages. Some of those 'bits of logic' (actions if you will,) interrupt the process and forward to a different page (page access rules for instance.) There are several possible solutions that I've come up with, but so far all of them involve either hacks, extending struts (which happens to partialy eliminate the reason I'm being required to move to Struts, and so isn't very favored by my supperiors,) some complicated java inheritance hierarchy where I inherit non-related functionality in those ten actions into a set of compound actions, each inheriting in the set of functionality we want (lame,) or I could implement a 'view preprocessor' of some kind that parallels the struts-config and defines processing that I need to do for each view page (which requires me to have two completely redundant sets of page mappings, and apears to me to obsolete the need for Struts in the first place (if we were to ignore it's tag libraries and other helper classes which we also already have proprietary equivalents to.) I'd love to hear from anyone about other possibilities, or (even better,) pointers to somebody/some package already solving this problem. Another way to look at the whole thing: How have other people solved the problem of being able to apply a set of page access rules to arbitrary sets of pages without having to create a system parallel to struts that re-defines every page in the application
Re: design question about action chaining
On Tuesday 01 April 2003 03:59 pm, Igor Shabalov wrote: You can not possibly imagine how useful and powerful can be good GUI tool when you handle really big and cumbersome struts-config file. Actually it can give you much more capability to implement such pipes, filers and assembling of application from pre-defined action components. Why, I can. Paul On Tue, 1 Apr 2003 15:12:34 -0500, Paul Yunusov [EMAIL PROTECTED] wrote: On Tuesday 01 April 2003 03:00 pm, Thorin Linderholm wrote: The static method you suggest would be very cumbersome to implement and maintain, requiring hard-coding calls to each bit of functionality I wanted on each page (aghh!) But thanks for the reply :-) I have to disagree that 'If they are a business tier concept, Struts should have nothing to do with chaining them.' The struts ActionServlet and the page mappings in the struts-config are the 'controller' portion of Struts. The whole of Struts is much more than the 'C' in MVC. It has taglibs for supporting the V, and actions are in fact always implementing buisness logic (they decide what page to go to by returning a 'forward': definite buisness logic, if there is such a thing.) And that's always been a gray area in MVC for me: does all the buisness logic belong in the model, or can it also go in the controller? Or is there an MVCC where there is a 'view' controller and 'buisness' controller (which seems a bit redundant to me.) Well, at one point you will wonder which is more cumbersome: coding Action classes or having a mile-long struts-config.xml. Paul -Original Message- From: Paul Yunusov [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 11:43 AM To: Struts Users Mailing List Subject: Re: design question about action chaining On Tuesday 01 April 2003 02:30 pm, Thorin Linderholm wrote: I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different bits of logic to whole sets of pages. Some of those 'bits of logic' (actions if you will,) interrupt the process and forward to a different page (page access rules for instance.) There are several possible solutions that I've come up with, but so far all of them involve either hacks, extending struts (which happens to partialy eliminate the reason I'm being required to move to Struts, and so isn't very favored by my supperiors,) some complicated java inheritance hierarchy where I inherit non-related functionality in those ten actions into a set of compound actions, each inheriting in the set of functionality we want (lame,) or I could implement a 'view preprocessor' of some kind that parallels the struts-config and defines processing that I need to do for each view page (which requires me to have two completely redundant sets of page mappings, and apears to me to obsolete the need for Struts in the first place (if we were to ignore it's tag libraries and other helper classes which we also already have proprietary equivalents to.) I'd love to hear from anyone about other possibilities, or (even better,) pointers to somebody/some package already solving this problem. Another way to look at the whole thing: How have other people solved the problem of being able to apply a set of page access rules to arbitrary sets of pages without having to create a system parallel to struts that re-defines every page
Re: design question about action chaining
Sure, you can. Sorry, I'm thinking in Russian, sometimes that produces really ugly English at the output :-) On Tue, 1 Apr 2003 17:18:15 -0500, Paul Yunusov [EMAIL PROTECTED] wrote: On Tuesday 01 April 2003 03:59 pm, Igor Shabalov wrote: You can not possibly imagine how useful and powerful can be good GUI tool when you handle really big and cumbersome struts-config file. Actually it can give you much more capability to implement such pipes, filers and assembling of application from pre-defined action components. Why, I can. Paul On Tue, 1 Apr 2003 15:12:34 -0500, Paul Yunusov [EMAIL PROTECTED] wrote: On Tuesday 01 April 2003 03:00 pm, Thorin Linderholm wrote: The static method you suggest would be very cumbersome to implement and maintain, requiring hard-coding calls to each bit of functionality I wanted on each page (aghh!) But thanks for the reply :-) I have to disagree that 'If they are a business tier concept, Struts should have nothing to do with chaining them.' The struts ActionServlet and the page mappings in the struts-config are the 'controller' portion of Struts. The whole of Struts is much more than the 'C' in MVC. It has taglibs for supporting the V, and actions are in fact always implementing buisness logic (they decide what page to go to by returning a 'forward': definite buisness logic, if there is such a thing.) And that's always been a gray area in MVC for me: does all the buisness logic belong in the model, or can it also go in the controller? Or is there an MVCC where there is a 'view' controller and 'buisness' controller (which seems a bit redundant to me.) Well, at one point you will wonder which is more cumbersome: coding Action classes or having a mile-long struts-config.xml. Paul -Original Message- From: Paul Yunusov [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 11:43 AM To: Struts Users Mailing List Subject: Re: design question about action chaining On Tuesday 01 April 2003 02:30 pm, Thorin Linderholm wrote: I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different bits of logic to whole sets of pages. Some of those 'bits of logic' (actions if you will,) interrupt the process and forward to a different page (page access rules for instance.) There are several possible solutions that I've come up with, but so far all of them involve either hacks, extending struts (which happens to partialy eliminate the reason I'm being required to move to Struts, and so isn't very favored by my supperiors,) some complicated java inheritance hierarchy where I inherit non-related functionality in those ten actions into a set of compound actions, each inheriting in the set of functionality we want (lame,) or I could implement a 'view preprocessor' of some kind that parallels the struts-config and defines processing that I need to do for each view page (which requires me to have two completely redundant sets of page mappings, and apears to me to obsolete the need for Struts in the first place (if we were to ignore it's tag libraries and other helper classes which we also already have proprietary equivalents to.) I'd love to hear from anyone about other possibilities, or (even better,) pointers to somebody/some package already solving this problem. Another way to look at the whole thing: How have other people solved the problem of being able to apply a set of page access rules to arbitrary sets of pages without having to create a system parallel
Re: design question about action chaining
+1 for David's recommendation to look at filters (Servlet 2.3) and his emphasis that the responsibility of a Struts action is controller logic, not business logic. Of course, there's nothing to keep you from (ab)using them that way, but it's certainly not a best practice. In fact, if you've got your business logic too tightly coupled to your controller framework, I bet it makes it a PITA to port to a different controller framework. As for using filters with Struts, I'd wager it's pretty common (I do it routinely). For example, a search through the archives on SecurityFilter (http://securityfilter.sourceforge.net/) results in about 120 hits. It just doesn't make sense to me to ignore a standard piece of functionality just to reimplement it as an extension to a custom framework. I suppose I can understand the potential problem of having to sift through both web.xml and struts-config.xml to get a complete picture of how a given request gets processed though. Stepping back for a moment, I like to view the interface to my web apps as a set of request URIs (e.g. http://host/app/do/profile/edit). This is the contract my app has with its clients. With that established, I'm free to implement the servicing of requests for those URIs in any way I see fit. If I don't need to tie that handling to Struts (or any other framework), I won't. It makes my life that much easier downt the road. David Graham wrote: You need to understand what Struts does for you. The Action classes are *not* for business logic, they are part of the controller and define page flow and call business logic methods. If you need special authentication, logging, etc. for particular views then a filter is your best choice. Filters aren't a parallel system to Struts because they logically sit in front of Struts handling requests before Struts gets them. David From: Thorin Linderholm [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Subject: RE: design question about action chaining Date: Tue, 1 Apr 2003 12:08:09 -0800 Filters are one of the design/imp choices I've considered under the 'parallel system' heading, though I hadn't thought of trying to use the web.xml for this. I'd have to look into these more. I take it you recomending that a second, parallel system of specifying functionality on a per-page or per-page-set basis is the way to go? What reasons would you have for this design choice, as opposed to extending struts to contain this functionality? Have you (or others,) implemented something similar to this? (This port is going to be a large chunk of time and I'm just trying to find out if other people have already thought through and implemented this type of functionality before I just pick something, run with it, and end up with some kind of maintenance or design nightmare :-) -Original Message- From: David Graham [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 11:52 AM To: [EMAIL PROTECTED] Subject: Re: design question about action chaining I think Filters would be a good choice for your needs. You can define a filter for each piece of logic and then configure them in web.xml for groups of pages. You'll need to put related pages in the same path scheme so that you can map a filter to the group instead of each page. David From: Thorin Linderholm [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: design question about action chaining Date: Tue, 1 Apr 2003 11:30:39 -0800 I have been tasked with porting an existing web application with it's own proprietary controller architecture to using Struts. As they are both web controller architectures, they have many similarities, but I'm running into one difference in overall architecture that I'm having difficulty resolving. This difficulty is most closely related to the 'action chaining' posts I've been able to find in the mailing list archives. Specifically, I have over 400 pages mapped to various actions (our controller calls them that, and they're roughly synonymous with struts actions.) However, our controller allows specifying a list of actions to execute on a per-page, and per-page-set basis. In other words, we can assign an action like 'Ensure Session initialization has been completed/Initialize session' to every page in the site with a single mapping (assuming you've already listed all the pages.) Or you can assign it to 90% of your pages if you happen to desire. We have approximatly ten actions that happen on between 60-99% of the pages on our site. If we were to directly translate this to the struts mapping system we would end up having to re-specify those ten actions on most of those 400+ pages, creating long action chains for each page (a whole lot of duplication: hard to maintain, easy to get wrong, etc.) So, conceptually, I want to be able to apply a few different
Re: Design Question - giving nice URL's with parameters hidden
When people first hit one of the internationalized pages, I'd like to check their browser settings for locale. You don't need to check that yourself. The first time a user hits your site the RequestProcessor.processLocale() will put a Locale object in their session. It checks their Accept-Language header to find the appropriate locale or uses the server default if they don't have that HTTP header. David _ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design Question - giving nice URL's with parameters hidden
Thanks. I must have been looking at old or incorrect documentation. It said that processLocale looks at the server default but ignores the browser settings. Nice to have this problem eliminated. Thanks, Joe Baker Director of Internet Communications Amnesty International USA 600 Pennsylvania Ave SE 5th Floor Washington, DC 20003 202-544-0200 x285 http://www.amnestyusa.org [EMAIL PROTECTED] David Graham [EMAIL PROTECTED] 03/14/03 05:43 PM Please respond to Struts Users Mailing List To: [EMAIL PROTECTED] cc: Subject:Re: Design Question - giving nice URL's with parameters hidden When people first hit one of the internationalized pages, I'd like to check their browser settings for locale. You don't need to check that yourself. The first time a user hits your site the RequestProcessor.processLocale() will put a Locale object in their session. It checks their Accept-Language header to find the appropriate locale or uses the server default if they don't have that HTTP header. David _ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design question
If I understood your domain there is a page where user can choose a formation: once choosen the formation, the control should be forwarded to another page where, together with data binded with the formation, user would have the possibility to add new info. Is that correct? In this case, there could be a tricky to avoid session scope savings: once the user chooses the formation(i.e. he/she submit the form), your action could ask to a business component(a service class, an EJB, whatever) to fill in a JavaBean with the relevant information related to the formation. The next JSP page shown to the user could take advantage from the Struts tags to get info from the Bean and display these info to the user, together with the new info the user can add to the formation. Two advantages would come from this approach: - first, you would avoid to save lots of info in the session scope, which we know if resource's consuming; - second, you would fulfill the MVC contract, letting the business domain to take care of getting and setting data in the relevant objects, and letting the view just to access the filled data presenting those to the user My 2 cents. -Original Message- From: alexj [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 04, 2003 11:29 PM To: Struts Users Mailing List Subject: Re: Design question I got a little question how can I manage that case : In my project I need to add activities to a formation an user select into a view page. I need to forward the selected formation to an other view page where this page need to contain specific populated datas (like branch) from the previously selected formation and then I can fill the new activity according the branch a formation have. What I'm thinking is to save in the session scope all the datas in relation with formations (but didn't show all in the first view) and then add a link to be able to forward to a specific formation page. But I'm really not sure if it's a good way. (I'm not sure if I'm clear enough to). Thanks for you advice. -- Alexandre Jaquet - 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: Design question
I got a little question how can I manage that case : In my project I need to add activities to a formation an user select into a view page. I need to forward the selected formation to an other view page where this page need to contain specific populated datas (like branch) from the previously selected formation and then I can fill the new activity according the branch a formation have. What I'm thinking is to save in the session scope all the datas in relation with formations (but didn't show all in the first view) and then add a link to be able to forward to a specific formation page. But I'm really not sure if it's a good way. (I'm not sure if I'm clear enough to). Thanks for you advice. -- Alexandre Jaquet - 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: Design question
On Sat, Feb 22,'03 (03:22 PM GMT+0100), alexj wrote: What's the best to do if for example I got a view where an user can choose to view students by class, view students by year or view students by year ? I think the best is to bring back the results in a table in some default manner (by class, year, whatever) but then allow the user to click on the table column header which will resort the list. If the collection is not that large look into using the Display tag (more recent updates to this tag can be found, search the struts archives). If the collection is very large you might want to use a different approach that doesn't rely on keeping the entire collection in session scope. -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design question
Great thanks Rick :) -- Alexandre Jaquet - Original Message - From: Rick Reumann [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Saturday, February 22, 2003 5:19 PM Subject: Re: Design question On Sat, Feb 22,'03 (03:22 PM GMT+0100), alexj wrote: What's the best to do if for example I got a view where an user can choose to view students by class, view students by year or view students by year ? I think the best is to bring back the results in a table in some default manner (by class, year, whatever) but then allow the user to click on the table column header which will resort the list. If the collection is not that large look into using the Display tag (more recent updates to this tag can be found, search the struts archives). If the collection is very large you might want to use a different approach that doesn't rely on keeping the entire collection in session scope. -- Rick - 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: Design Question
On Sat, Feb 08, 2003 at 12:34:35AM -0500, Rob Leland wrote: EditAAction SaveAAction --EditBAction SaveBAction \ / \/ \ / \ / \/ / \/ / (AActionForm) + A.jsp (BActionForm)+B.jsp To keep your code maintainable after SaveAAction is 'happy' It looks up the 'success' or 'happy' mapping in your struts-config.xml That maps to EditBAction which takes care of filling in the data for BActionForm, and then forwards to b.jsp. First off, thanks for the funky ASCII graphics and the reply. ;) What I find confusing is the SaveAAction -- EditBAction. Does SaveAAction simply instantiate EditBAction and then pass whatever data it needs? Doesn't struts think the current ActionForm is not BActionForm but AActionForm since that is the form that was declard in the struts-config.xml for that the very first Action we performed? My understanding is that the lifetime of an Action is jsp to servlet to jsp and during that Action the ActionForm declared for that Action is the only ActionForm that is valid. Are you saying that it is possible to change the type of ActionForm used after the first submit? Thanks for the book and website referrals. I had purchaed O'Reilly's Struts books but it's been very dissapointing. I'll take a look at Ted Husted's book. Thanks again Justin -- Justin F. Knotzke [EMAIL PROTECTED] http://www.shampoo.ca - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Design question: Model component using Business logic beans
Thanks for all that help. Anyway I guess I'll opt for using custom exception, like mentioned in an early post, in my business logic components. Seems easier to do in the interim and I wonder why i didn't think of that solution myself in the beginning... light...light... throw new MyBusinessLogicException(error.something.wrong) then I'll catch it in the calling execute() and generate an ActionError with an ActionMessage that I get from the Exceptions getMessage(). At least this works for me as long as I only have one exception message per problem because business logic won't be processed any further after that exception, of course. But why should I bother a user with a list of a 10 issues he did wrong at one time ;-) Let him try again and again until he got it... Should have read the usage notes in the view before clicking like mad. ;-) The simple input validation stuff can still be done in the form's validate() to notify about all those hundreds of dumb mistakes with ActionErros.add(). So the business logic usually shouldn't throw so many different problems at one time after validate(). I guess if my database connection is dead or the transaction had to rollback there's not much more to say than bad luck, try again and further processing makes no sense anyway. Michael -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Dienstag, 4. Februar 2003 04:49 To: Struts Users Mailing List Cc: [EMAIL PROTECTED] Subject: Re: Design question: Model component using Business logic beans On Mon, 3 Feb 2003, BaTien Duong wrote: Date: Mon, 3 Feb 2003 20:02:41 -0700 From: BaTien Duong [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: Design question: Model component using Business logic beans We use chained exception from jdk1.4, commons.logging, and factoring out 4 components that are independent on Struts [MessageResources, MessageResourcesFactory, PropertyMessageResources, and PropertyMessageResourcesFactory]. I heard somewhere that these 4 components will eventually be in commons. ActionErrors and ActionError are used at the web layer. With many TilesAction(s) in 1 page, we coordinate the error handling of the page via the ERROR_KEY attribute of the request. The refactoring of the resources code to make it independent of Struts has been completed: http://jakarta.apache.org/builds/jakarta-commons/nightly/commons-resourc es However, it was too late in the 1.1 release cycle to make Struts use this new code itself. That will happen in a future version, but you can use commons-resources for your business tier message resource needs in the interim. Hope this may help. BaTien Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design question: Model component using Business logic beans
Great. Thanks. BaTien - Original Message - From: Craig R. McClanahan [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 8:49 PM Subject: Re: Design question: Model component using Business logic beans On Mon, 3 Feb 2003, BaTien Duong wrote: Date: Mon, 3 Feb 2003 20:02:41 -0700 From: BaTien Duong [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: Design question: Model component using Business logic beans We use chained exception from jdk1.4, commons.logging, and factoring out 4 components that are independent on Struts [MessageResources, MessageResourcesFactory, PropertyMessageResources, and PropertyMessageResourcesFactory]. I heard somewhere that these 4 components will eventually be in commons. ActionErrors and ActionError are used at the web layer. With many TilesAction(s) in 1 page, we coordinate the error handling of the page via the ERROR_KEY attribute of the request. The refactoring of the resources code to make it independent of Struts has been completed: http://jakarta.apache.org/builds/jakarta-commons/nightly/commons-resources However, it was too late in the 1.1 release cycle to make Struts use this new code itself. That will happen in a future version, but you can use commons-resources for your business tier message resource needs in the interim. Hope this may help. BaTien Craig - 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: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..)
Hi Ted, This explanatation has set to rest most of my doubts about action chainning..And I think the way Most of us use actions(One action to serve the request like save action)and another to display the page (like getAccountsList Action )is not action chainning but action relay which is perfectly alright. Also I have understood what u mean by actions becoming API rather than being distinations..And this has really helped me to find some of trouble spots in our application... Thanks very very much...For all others as well who have contributed to this discussion and helped me (and hopefully a couple others )to better understand the very core of struts architecture.. regards, Shirish -Original Message- From: husted [mailto:[EMAIL PROTECTED]] Sent: Friday, January 31, 2003 7:07 PM To: struts-user Cc: husted Subject: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) The best example of waht I'm calling an Action relay is how Struts handles validation. If validation fails, the request is forwarded to the input property, which could be another Action. This is done to complete the response, rather than continue with processing the action. This same technique is often used after a lookup, where one Action does the lookup but another Action is used to complete the response, usually to setup any tools the page might need to render. In an Action chain, control is not forwarded simply to complete the response but to continue processing. One action doesn't do some similar activity because that's the another actions job. The request/response transaction begins to be distributed between several Action, and this is where Action stop being destinations and start becoming an API. Most often, whatever processing the Action in a chain are supposed to be doing can be refactored into base actions or utility classes, so the funcationality can be reused using standard object-orientated techniques. -Ted. -- Ted Husted, Struts in Action http://husted.com/struts/book.html - 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: design question about action chaining
Thanks, Ted, for clarifying these issues for me. -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 02, 2003 11:06 AM To: [EMAIL PROTECTED] Subject: Re: design question about action chaining In Patterns of Enterprise Application Architecture [1], Martin Fowler [2] lays out two basic patterns for handling business logic [3]. * Transaction Script - Organizes business logic by procedures where each procedure handles a single request from the presentation. * Domain Model - An object model of the domain that incorporates both behavior and data. The Struts MailReader example uses the Transaction Script pattern. This is a fine way to go for simple applications. I used it myself in my first significant Struts application (an online auction), still do, and probably always will. It's simple and efficient, and when the logic is not complex, does the job quite well, thank you. The Artimus example [4] from Struts in Action uses the domain model. Here a stub Action is used to call a domain object. The domain object does all of the processing for this transaction and returns a response. The stub Action analyzes the domain's response and bundles everything into a HTTP response. The Artimus example is not so complex that it really needs to use Domain Model, but I wanted it to contrast the MailReader example. My second significant Struts application was a telemarketing and inventory manager for the first auction application. Here, the logic is sometimes quite complex, and I *do* need to use the domain model. Compared to the public auction application, there's an extra layer of indirection, but it can do ~whatever~ I need it to do. It's my belief that when people start to chain Actions, they are trying to move from a Transaction Script to a Domain Model. Problem is, they are trying to do it with Struts Actions rather than POJO's (Plain Old Java Objects). There are several problems with using Struts Action classes as Domain Objects: * First, you must embed complex business logic inside of a HTTP presentation tier class. As long you use Struts and nothing but Struts, this is not necessarily a problem. But you never know what nutty idea the suits will have next =:0) * Second, the Action interface is not designed so that one Action can call another. In more complicated applications, use-case C is really a combination of cases A and B. With Actions, to get to C, you need to forward through A and B (hence the chain). With POJO, C can cleanly call A and B and return the result. The presentation tier doesn't know, or need to know, that C is a combination of A and B. Such chains of responsibility are the concern of application controllers, but should not be delegated to a presentation tier controller, like Struts. * Third, Struts Test Case [5] makes testing Struts actions relatively simple, but the tests are still more complicated that testing POJOs alone. With PODOs (Plain Old Domain Objects), you can have two layers of tests: a pure TestCase against the business logic, and a Struts TestCase against the interaction between the business layer and the presentation layer. It's my thinking that you should be able to look at any given ActionMapping and say this uses Transaction Script or this uses Domain Model. If you can't, then I would suggest that you may be letting the tail wag the dog =:0) Struts uses a number of very excellent patterns. I am continually amazed at how well it all fits together. The trick is to use the same patterns in your enterprise architecture. The dark side is letting Struts ~become~ your enterprise architecture. Faster yes, better no. -Ted. Resources - [1] Patterns of Enterprise Application Architecture http://www.amazon.com/exec/obidos/ISBN=0321127420 /hitchhikeguidetoA/ [2] Martin Fowler also wrote Refactoring, among others. He is definitely one of our favorite ~non-fiction~ authors. [3] Business logic - An oxymoron akin to military intelligence. Business logic is whatever nutty stuff the client wants to do with the data that we have so carefully obtained, stored, and retrieved (using system logic). Sadly, implementing the business logic is what they actually ~pay~ us to do, rather than the other interesting stuff that we enjoy doing on the way. (The voyage is the reward.) [4] Artimus CVS http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/struts/artimus/ [5] My new best friend http://sourceforge.net/projects/strutstestcase/ -- Ted Husted, Struts in Action http://husted.com/struts/book.html - 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: Design question: Model component using Business logic beans
Michael, I have been putting my data logic into DAO classes that throw their own custom exceptions. Based on the exception thrown, I append to the ActionError object in the Action class. I don't think this answers the specific question you asked regarding use of the ActionError object in your business logic but it could be an alternative path that you could opt for. -Original Message- From: mech [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 1:05 PM To: [EMAIL PROTECTED] Subject: Design question: Model component using Business logic beans Hi, currently I'm doing all my business logic in my Action classes. So besides the execute() method I might have some helper methods like populateFormBean() or I even put those stuff in the execute() directly if it wasn't to much. I have to do quite a lot of database queries to populate the form bean for the views. So actually the Action class should only do the controlling. So far so good and since things got to much in my Action classes I planned to move the code out into business logic beans to be accessed within execute() in order to do all the populate form stuff there. It's no problem to use a setter method to give my business logic beans the reference to my struts connection pool. Also fine to do it with the form bean. One thing, I'm having a bit trouble with migration is the ActionError stuff. Since most of the errors, like lost DB connections or the rollbacks of db transactions usually happen in my business logic beans then, I wonder what could be a good practice to pass those errors back to the Action execute() as I need those information in html:errors/ in my views. I guess if I import org.apache.struts.action.ActionError in my business logic, I'm doing a bad job to untie business logic from my controller, right? I guess it would be similar bad like including the servlet packages as mentioned as a warning in the Struts documentation. But on the other hand, it's quite useful to say errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.something.happend)); in my business logic bean in order to log an error at the place where it occurs, right? But to use a setter method in my business logic bean writting all those errors and retrieving them with a getter method in the calling execute() requires importing Struts packages... Does anyone have good ideas how to untie business logic from all web-related stuff while still being able to pass errors in a sophisticated way back to the caller, like it can be done with the ActionError classes. I would appreciate any design hints from everybody who doesn't put all his business logic code into the Action classes or it's execute() method, since most books speak about not to tie business logic with the controller, but usually do the opposite in the sample code. ;-) Thanks Michael - 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: Design question: Model component using Business logic beans
This is why Java has exceptions. In our case the backend mostly throws standard EJB exceptions (RemoveException, CreateException, etc), the business delegate translates those into our custom application exceptions, many of which are handled by our base action class, otherwise they bubble up to the specific action class and we generate the appropriate ActionErrors. -- Voytek Jarnot Quidquid latine dictum sit, altum viditur. -Original Message- From: mech [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 12:05 PM To: [EMAIL PROTECTED] Subject: Design question: Model component using Business logic beans Hi, currently I'm doing all my business logic in my Action classes. So besides the execute() method I might have some helper methods like populateFormBean() or I even put those stuff in the execute() directly if it wasn't to much. I have to do quite a lot of database queries to populate the form bean for the views. So actually the Action class should only do the controlling. So far so good and since things got to much in my Action classes I planned to move the code out into business logic beans to be accessed within execute() in order to do all the populate form stuff there. It's no problem to use a setter method to give my business logic beans the reference to my struts connection pool. Also fine to do it with the form bean. One thing, I'm having a bit trouble with migration is the ActionError stuff. Since most of the errors, like lost DB connections or the rollbacks of db transactions usually happen in my business logic beans then, I wonder what could be a good practice to pass those errors back to the Action execute() as I need those information in html:errors/ in my views. I guess if I import org.apache.struts.action.ActionError in my business logic, I'm doing a bad job to untie business logic from my controller, right? I guess it would be similar bad like including the servlet packages as mentioned as a warning in the Struts documentation. But on the other hand, it's quite useful to say errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.something.happend)); in my business logic bean in order to log an error at the place where it occurs, right? But to use a setter method in my business logic bean writting all those errors and retrieving them with a getter method in the calling execute() requires importing Struts packages... Does anyone have good ideas how to untie business logic from all web-related stuff while still being able to pass errors in a sophisticated way back to the caller, like it can be done with the ActionError classes. I would appreciate any design hints from everybody who doesn't put all his business logic code into the Action classes or it's execute() method, since most books speak about not to tie business logic with the controller, but usually do the opposite in the sample code. ;-) Thanks Michael - 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: Design question: Model component using Business logic beans
I would have the business components handle their own DB connections (they shouldn't rely on the presentation layer for that). As far as your errors coming back to the presentation layer, I usually have a BusinessDelegate class that the action makes business calls into. That business delegate is responsible for catching exceptions like SQL, Remote, IO, etc. and then wrapping them into more application/business specific exceptions. Here is a good description of the BD pattern: http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.ht ml -Original Message- From: mech [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 12:05 PM To: [EMAIL PROTECTED] Subject: Design question: Model component using Business logic beans Hi, currently I'm doing all my business logic in my Action classes. So besides the execute() method I might have some helper methods like populateFormBean() or I even put those stuff in the execute() directly if it wasn't to much. I have to do quite a lot of database queries to populate the form bean for the views. So actually the Action class should only do the controlling. So far so good and since things got to much in my Action classes I planned to move the code out into business logic beans to be accessed within execute() in order to do all the populate form stuff there. It's no problem to use a setter method to give my business logic beans the reference to my struts connection pool. Also fine to do it with the form bean. One thing, I'm having a bit trouble with migration is the ActionError stuff. Since most of the errors, like lost DB connections or the rollbacks of db transactions usually happen in my business logic beans then, I wonder what could be a good practice to pass those errors back to the Action execute() as I need those information in html:errors/ in my views. I guess if I import org.apache.struts.action.ActionError in my business logic, I'm doing a bad job to untie business logic from my controller, right? I guess it would be similar bad like including the servlet packages as mentioned as a warning in the Struts documentation. But on the other hand, it's quite useful to say errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.something.happend)); in my business logic bean in order to log an error at the place where it occurs, right? But to use a setter method in my business logic bean writting all those errors and retrieving them with a getter method in the calling execute() requires importing Struts packages... Does anyone have good ideas how to untie business logic from all web-related stuff while still being able to pass errors in a sophisticated way back to the caller, like it can be done with the ActionError classes. I would appreciate any design hints from everybody who doesn't put all his business logic code into the Action classes or it's execute() method, since most books speak about not to tie business logic with the controller, but usually do the opposite in the sample code. ;-) Thanks Michael - 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: Design question: Model component using Business logic beans
Thanks... custom exceptions... of course...! I must have been blind. Thanks for the light! Michael -Original Message- From: Pani, Gourav [mailto:[EMAIL PROTECTED]] Sent: Montag, 3. Februar 2003 19:11 To: 'Struts Users Mailing List' Subject: RE: Design question: Model component using Business logic beans Michael, I have been putting my data logic into DAO classes that throw their own custom exceptions. Based on the exception thrown, I append to the ActionError object in the Action class. I don't think this answers the specific question you asked regarding use of the ActionError object in your business logic but it could be an alternative path that you could opt for. -Original Message- From: mech [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 1:05 PM To: [EMAIL PROTECTED] Subject: Design question: Model component using Business logic beans Hi, currently I'm doing all my business logic in my Action classes. So besides the execute() method I might have some helper methods like populateFormBean() or I even put those stuff in the execute() directly if it wasn't to much. I have to do quite a lot of database queries to populate the form bean for the views. So actually the Action class should only do the controlling. So far so good and since things got to much in my Action classes I planned to move the code out into business logic beans to be accessed within execute() in order to do all the populate form stuff there. It's no problem to use a setter method to give my business logic beans the reference to my struts connection pool. Also fine to do it with the form bean. One thing, I'm having a bit trouble with migration is the ActionError stuff. Since most of the errors, like lost DB connections or the rollbacks of db transactions usually happen in my business logic beans then, I wonder what could be a good practice to pass those errors back to the Action execute() as I need those information in html:errors/ in my views. I guess if I import org.apache.struts.action.ActionError in my business logic, I'm doing a bad job to untie business logic from my controller, right? I guess it would be similar bad like including the servlet packages as mentioned as a warning in the Struts documentation. But on the other hand, it's quite useful to say errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.something.happend)); in my business logic bean in order to log an error at the place where it occurs, right? But to use a setter method in my business logic bean writting all those errors and retrieving them with a getter method in the calling execute() requires importing Struts packages... Does anyone have good ideas how to untie business logic from all web-related stuff while still being able to pass errors in a sophisticated way back to the caller, like it can be done with the ActionError classes. I would appreciate any design hints from everybody who doesn't put all his business logic code into the Action classes or it's execute() method, since most books speak about not to tie business logic with the controller, but usually do the opposite in the sample code. ;-) Thanks Michael - 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: Design question: Model component using Business logic beans
Hi, What i have been doing is the following, I wrote a simple class , which will hold all the errors in the business class (An ArrayList whoes each row is an error or message ) , and then send back this class to the Action class, and then in the Action class i have written logic to build ActionErrors , if there are any. So the call to my business class looks some thing like this ProcessError error = myBusinessClass.doIt(); where processerror is the place for holdin all messages The advantage i got buy doing this, is that i was able to pass on errors as well information messages to Action class which will forward them to the view Ashish --- John Espey [EMAIL PROTECTED] wrote: I would have the business components handle their own DB connections (they shouldn't rely on the presentation layer for that). As far as your errors coming back to the presentation layer, I usually have a BusinessDelegate class that the action makes business calls into. That business delegate is responsible for catching exceptions like SQL, Remote, IO, etc. and then wrapping them into more application/business specific exceptions. Here is a good description of the BD pattern: http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.ht ml -Original Message- From: mech [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 12:05 PM To: [EMAIL PROTECTED] Subject: Design question: Model component using Business logic beans Hi, currently I'm doing all my business logic in my Action classes. So besides the execute() method I might have some helper methods like populateFormBean() or I even put those stuff in the execute() directly if it wasn't to much. I have to do quite a lot of database queries to populate the form bean for the views. So actually the Action class should only do the controlling. So far so good and since things got to much in my Action classes I planned to move the code out into business logic beans to be accessed within execute() in order to do all the populate form stuff there. It's no problem to use a setter method to give my business logic beans the reference to my struts connection pool. Also fine to do it with the form bean. One thing, I'm having a bit trouble with migration is the ActionError stuff. Since most of the errors, like lost DB connections or the rollbacks of db transactions usually happen in my business logic beans then, I wonder what could be a good practice to pass those errors back to the Action execute() as I need those information in html:errors/ in my views. I guess if I import org.apache.struts.action.ActionError in my business logic, I'm doing a bad job to untie business logic from my controller, right? I guess it would be similar bad like including the servlet packages as mentioned as a warning in the Struts documentation. But on the other hand, it's quite useful to say errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.something.happend)); in my business logic bean in order to log an error at the place where it occurs, right? But to use a setter method in my business logic bean writting all those errors and retrieving them with a getter method in the calling execute() requires importing Struts packages... Does anyone have good ideas how to untie business logic from all web-related stuff while still being able to pass errors in a sophisticated way back to the caller, like it can be done with the ActionError classes. I would appreciate any design hints from everybody who doesn't put all his business logic code into the Action classes or it's execute() method, since most books speak about not to tie business logic with the controller, but usually do the opposite in the sample code. ;-) Thanks Michael - 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] = A$HI$H __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design question: Model component using Business logic beans
On Mon, 3 Feb 2003, mech wrote: One thing, I'm having a bit trouble with migration is the ActionError stuff. One of the things we wanted to do in Struts 1.1, but ran out of time for, was to switch to using commons-resources for the underlying message resources stuff, and then build ActionError and ActionMessage in Struts on top of that API. This would have made it trivially easy to use the same sort of thing for business logic error message management. Alas, we ran out of time ... In the interim, though, you might want to investigate using commons-resources directly for your business logic (so you don't have to depend directly on Struts APIs), and then write variants of the errors and messages tags to display them. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design question: Model component using Business logic beans
Craig McClanhan wrote: In the interim, though, you might want to investigate using commons-resources directly for your business logic (so you don't have to depend directly on Struts APIs) +1 What I'm doing is having the business tier bring back a MessageList and then just pumping it into ActionErrors. Next go around, we won't even have to bother with that =:0) protected void mergeAlerts( HttpServletRequest request, ActionErrors alerts, MessageList list) { if ((null != list) (!list.isEmpty())) { Iterator properties = list.properties(); while (properties.hasNext()) { String property = (String) properties.next(); Iterator messages = list.get(property); // special case if (MessageList.GLOBAL_MESSAGE_KEY.equals(property)) { if (isStruts_1_0()) property = ActionErrors.GLOBAL_ERROR; else property = ActionMessages.GLOBAL_MESSAGE; } while (messages.hasNext()) { Message message = (Message) messages.next(); // :FIXME: In 1.1, use ActionMessage alerts.add(property, new ActionError( message.getKey(), message.getValues() )); } } } } // end mergeAlerts() -T. -- Ted Husted, Struts in Action http://husted.com/struts/book.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design question: Model component using Business logic beans
We use chained exception from jdk1.4, commons.logging, and factoring out 4 components that are independent on Struts [MessageResources, MessageResourcesFactory, PropertyMessageResources, and PropertyMessageResourcesFactory]. I heard somewhere that these 4 components will eventually be in commons. ActionErrors and ActionError are used at the web layer. With many TilesAction(s) in 1 page, we coordinate the error handling of the page via the ERROR_KEY attribute of the request. Hope this may help. BaTien --- - Original Message - From: mech [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 11:05 AM Subject: Design question: Model component using Business logic beans Hi, currently I'm doing all my business logic in my Action classes. So besides the execute() method I might have some helper methods like populateFormBean() or I even put those stuff in the execute() directly if it wasn't to much. I have to do quite a lot of database queries to populate the form bean for the views. So actually the Action class should only do the controlling. So far so good and since things got to much in my Action classes I planned to move the code out into business logic beans to be accessed within execute() in order to do all the populate form stuff there. It's no problem to use a setter method to give my business logic beans the reference to my struts connection pool. Also fine to do it with the form bean. One thing, I'm having a bit trouble with migration is the ActionError stuff. Since most of the errors, like lost DB connections or the rollbacks of db transactions usually happen in my business logic beans then, I wonder what could be a good practice to pass those errors back to the Action execute() as I need those information in html:errors/ in my views. I guess if I import org.apache.struts.action.ActionError in my business logic, I'm doing a bad job to untie business logic from my controller, right? I guess it would be similar bad like including the servlet packages as mentioned as a warning in the Struts documentation. But on the other hand, it's quite useful to say errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.something.happend)); in my business logic bean in order to log an error at the place where it occurs, right? But to use a setter method in my business logic bean writting all those errors and retrieving them with a getter method in the calling execute() requires importing Struts packages... Does anyone have good ideas how to untie business logic from all web-related stuff while still being able to pass errors in a sophisticated way back to the caller, like it can be done with the ActionError classes. I would appreciate any design hints from everybody who doesn't put all his business logic code into the Action classes or it's execute() method, since most books speak about not to tie business logic with the controller, but usually do the opposite in the sample code. ;-) Thanks Michael - 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: Design question: Model component using Business logic beans
On Mon, 3 Feb 2003, BaTien Duong wrote: Date: Mon, 3 Feb 2003 20:02:41 -0700 From: BaTien Duong [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: Design question: Model component using Business logic beans We use chained exception from jdk1.4, commons.logging, and factoring out 4 components that are independent on Struts [MessageResources, MessageResourcesFactory, PropertyMessageResources, and PropertyMessageResourcesFactory]. I heard somewhere that these 4 components will eventually be in commons. ActionErrors and ActionError are used at the web layer. With many TilesAction(s) in 1 page, we coordinate the error handling of the page via the ERROR_KEY attribute of the request. The refactoring of the resources code to make it independent of Struts has been completed: http://jakarta.apache.org/builds/jakarta-commons/nightly/commons-resources However, it was too late in the 1.1 release cycle to make Struts use this new code itself. That will happen in a future version, but you can use commons-resources for your business tier message resource needs in the interim. Hope this may help. BaTien Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: design question about action chaining
In Patterns of Enterprise Application Architecture [1], Martin Fowler [2] lays out two basic patterns for handling business logic [3]. * Transaction Script - Organizes business logic by procedures where each procedure handles a single request from the presentation. * Domain Model - An object model of the domain that incorporates both behavior and data. The Struts MailReader example uses the Transaction Script pattern. This is a fine way to go for simple applications. I used it myself in my first significant Struts application (an online auction), still do, and probably always will. It's simple and efficient, and when the logic is not complex, does the job quite well, thank you. The Artimus example [4] from Struts in Action uses the domain model. Here a stub Action is used to call a domain object. The domain object does all of the processing for this transaction and returns a response. The stub Action analyzes the domain's response and bundles everything into a HTTP response. The Artimus example is not so complex that it really needs to use Domain Model, but I wanted it to contrast the MailReader example. My second significant Struts application was a telemarketing and inventory manager for the first auction application. Here, the logic is sometimes quite complex, and I *do* need to use the domain model. Compared to the public auction application, there's an extra layer of indirection, but it can do ~whatever~ I need it to do. It's my belief that when people start to chain Actions, they are trying to move from a Transaction Script to a Domain Model. Problem is, they are trying to do it with Struts Actions rather than POJO's (Plain Old Java Objects). There are several problems with using Struts Action classes as Domain Objects: * First, you must embed complex business logic inside of a HTTP presentation tier class. As long you use Struts and nothing but Struts, this is not necessarily a problem. But you never know what nutty idea the suits will have next =:0) * Second, the Action interface is not designed so that one Action can call another. In more complicated applications, use-case C is really a combination of cases A and B. With Actions, to get to C, you need to forward through A and B (hence the chain). With POJO, C can cleanly call A and B and return the result. The presentation tier doesn't know, or need to know, that C is a combination of A and B. Such chains of responsibility are the concern of application controllers, but should not be delegated to a presentation tier controller, like Struts. * Third, Struts Test Case [5] makes testing Struts actions relatively simple, but the tests are still more complicated that testing POJOs alone. With PODOs (Plain Old Domain Objects), you can have two layers of tests: a pure TestCase against the business logic, and a Struts TestCase against the interaction between the business layer and the presentation layer. It's my thinking that you should be able to look at any given ActionMapping and say this uses Transaction Script or this uses Domain Model. If you can't, then I would suggest that you may be letting the tail wag the dog =:0) Struts uses a number of very excellent patterns. I am continually amazed at how well it all fits together. The trick is to use the same patterns in your enterprise architecture. The dark side is letting Struts ~become~ your enterprise architecture. Faster yes, better no. -Ted. Resources - [1] Patterns of Enterprise Application Architecture http://www.amazon.com/exec/obidos/ISBN=0321127420 /hitchhikeguidetoA/ [2] Martin Fowler also wrote Refactoring, among others. He is definitely one of our favorite ~non-fiction~ authors. [3] Business logic - An oxymoron akin to military intelligence. Business logic is whatever nutty stuff the client wants to do with the data that we have so carefully obtained, stored, and retrieved (using system logic). Sadly, implementing the business logic is what they actually ~pay~ us to do, rather than the other interesting stuff that we enjoy doing on the way. (The voyage is the reward.) [4] Artimus CVS http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/struts/artimus/ [5] My new best friend http://sourceforge.net/projects/strutstestcase/ -- Ted Husted, Struts in Action http://husted.com/struts/book.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..)
Hi, I agree with u that u can have another layer of abstraction(like helper beans) between action and Service layer.So that same code ecan be reused. But this some disadvangates. Firstly U are then not really using the power of Struts Configuration file which allows you to use logical mappings in Action classes And to change the Flow,U can just change the config file (So long as all required parametzers are being passed in new flow as well..).Because in our project, we had this requirement many a times.After we had done one release, the business gusy will come up with a suggestion some thing like, After AccountDetails PAge, can we go to AccountList üpage instead of Summary page etc etc .And because of Reusable actions, this was just a matter of changing the struts config file and in one of cases may be make the new caller pass a few more parameters.But there was no code duplication. So as i said in my original mail,If your services are not tied to actions, then in that case I don't see any problem in action chainning.ANd it seems to me the best thing to really harness the power of Struts..Or is there any other preformance or design issue which i have missed? Any comments:-))?? regards, Shirish -Original Message- From: batien.duong [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 30, 2003 5:09 PM To: struts-user Subject: Re: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) We achieve what you describe as a chain of actions for re-use with helper beans and follow Struts design principal as Ted described. The helper beans can be ready in cache or service pool for reuse. Look at http://myportal.myb2cb2b.com/com.dbgroups.ppf/model/web/dao.html Hope this may help. BaTien - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 30, 2003 3:34 AM Subject: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) Hi All, I have a very basic design question about struts action design..We have been developing a fairly large and complex web application involving struts and struts has proved to be a great help :-)) But after reading the book by Mr. Husted et al., Struts in action,I have some basic questions about the way we have done our project and the way it is described in the book. TO quote Mr. Husted...(Section 8.4 Chaining Actions .Note at the end of Section8.4.1. Starting fresh..) Speaking as a Software architect,chainning actions in any way is not something that I like to do.Ideally you should be able to call the business objects from any Action where they are needed.Wanting to forward control to another action implies that the Business object my be too tightly coupled.Or it may imply that the actions should descend from a common super class with hotspots that sub classes should overrideThere are occasions when chainning actions makes sense-for example if the other action is being used to render the response in lieu of a presentation page.But valid use cases are rare.The best general practice is to stay with one-request ,one action regimen. * And also after searching the archives for action chainnign , I found another reply from Mr. Husted which says.. Wanting to chain actions is a warning sign that there is too much business logic is creeping into the Actions and they are becoming the API, rather than an adaptor for the API. (Struts should not *be* your application, it should be a gateway *to* your application.) * I have a high regard for Mr. Ted Husted and that's why I would like to clarify some of my doubts about the design strategy he has advocated in his book from the exüperienced users of this list and Mr Husted himself if possible. I dont understand what is the disadvantage in Chainning actions?HAs it some thing to do with performance?I totally agree that the business objects shuld not be tightly coupled with actions and should be callable from any where .But even after following this principal, most of the time you will end up chainning actions if u really want reusable actions.Example can be loging process of a user.So the request for loging form a user can result in 2 actions being called.1:CheckLogin(which checks user credentials) It forwards control to 2:getUserAccountList which gets the list of accounts for the user. So now the getUserAccountList action I can call from any where else by passing right params and it becomes reusable.But if i had done all of this(check log in and then get accunts)in login action, i need to write another action to get account for another page.And I am using calls
RE: design question about action chainning(As quoted in :Struts inaction...by Ted Husted et al..)
Derek Richardson writes: But you still have to duplicate code in the actions, right? Even if that code is as simple as: Service service = Service.getService(SERVICE_KEY); Foo[] foos = service.getFoos(); request.setAttribute(FOO_KEY, foos); Action chaining allows this code to be written once and used many times. Thus you get reuse of presentation code, not just business logic. Personally, I would put utility code like this in a super class and make it available to whatever Action wanted to call it. Actions are instantiated once, and there is no performance penalty for have a deep hierarchy. So there would be something like setService(request) that any Action could call. The BaseAction in Scaffold makes good use of this technique for error handling and such. What happens with true Action chaining (not to be confused with a simple Action relay) is that instead of using Java calls to create our presentation API, we start to use HTTP to make the API calls instead. IMHO, this is a step backward. The point of Struts is to get us up and out of HTTP and into an object-orientated domain, where we can write proper programs. (Rather than an endless chain of kludges.) -Ted. -- Ted Husted, Struts in Action http://husted.com/struts/book.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..)
Hi, Does this mean that using action forwards To point another action is not action chainning?So we can call this action relay and its in line with Struts design principles? And as u said,We have really abstracted away all error handling etc to Abstract Action class.But the point is if we go withoput action chainning(or if we call it action relay),then to get the same page from different work flows,U may need to copy the same code to call service in muiltiple action classes. my question is what is the real disadvantage of using Atomic actions , if the are designed proper struts way(USing struts techniques so that they are not dealing with HTTP but directly getting objects from form beans..As u rightly said...)And then forward from one atomic action to another to complete a work flow.. regards Shirish -Original Message- From: husted [mailto:[EMAIL PROTECTED]] Sent: Friday, January 31, 2003 12:34 PM To: struts-user Cc: husted Subject: RE: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) Derek Richardson writes: But you still have to duplicate code in the actions, right? Even if that code is as simple as: Service service = Service.getService(SERVICE_KEY); Foo[] foos = service.getFoos(); request.setAttribute(FOO_KEY, foos); Action chaining allows this code to be written once and used many times. Thus you get reuse of presentation code, not just business logic. Personally, I would put utility code like this in a super class and make it available to whatever Action wanted to call it. Actions are instantiated once, and there is no performance penalty for have a deep hierarchy. So there would be something like setService(request) that any Action could call. The BaseAction in Scaffold makes good use of this technique for error handling and such. What happens with true Action chaining (not to be confused with a simple Action relay) is that instead of using Java calls to create our presentation API, we start to use HTTP to make the API calls instead. IMHO, this is a step backward. The point of Struts is to get us up and out of HTTP and into an object-orientated domain, where we can write proper programs. (Rather than an endless chain of kludges.) -Ted. -- Ted Husted, Struts in Action http://husted.com/struts/book.html - 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: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..)
Ted, can you (or someone else) clarify the difference b/t action chaining and action relay? Thanks, Greg -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, January 31, 2003 5:34 AM To: [EMAIL PROTECTED] Subject: RE: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) Derek Richardson writes: But you still have to duplicate code in the actions, right? Even if that code is as simple as: Service service = Service.getService(SERVICE_KEY); Foo[] foos = service.getFoos(); request.setAttribute(FOO_KEY, foos); Action chaining allows this code to be written once and used many times. Thus you get reuse of presentation code, not just business logic. Personally, I would put utility code like this in a super class and make it available to whatever Action wanted to call it. Actions are instantiated once, and there is no performance penalty for have a deep hierarchy. So there would be something like setService(request) that any Action could call. The BaseAction in Scaffold makes good use of this technique for error handling and such. What happens with true Action chaining (not to be confused with a simple Action relay) is that instead of using Java calls to create our presentation API, we start to use HTTP to make the API calls instead. IMHO, this is a step backward. The point of Struts is to get us up and out of HTTP and into an object-orientated domain, where we can write proper programs. (Rather than an endless chain of kludges.) -Ted. -- Ted Husted, Struts in Action http://husted.com/struts/book.html - 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: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..)
We think Struts power lies in its simple and rigorous design process. If you combine Struts-Tiles, you will have the display Action for the whole page and actions for all included tiles. Actions are controllers that can have parameters set in the configuration file. With careful design of helper beans (ActionForm is a helper bean) and class structures for both actions and helper beans, which we call processing containers, you can bring the set parameters to your business processes that change per action. An example may help to illustrate this simple but powerful process inherent in Struts that makes it so popular. A user may initially be authenticated via username and password that you assign as authenticationLevel1. When the user requests a certain action such as money transfer and/or sending a legal-binding contract, you may decide to further challenge the user identity with a personalized token (what user has). Struts-Tiles action allows you to do this at individual action level. In this example, you just assign the action at authenticationLevel2. Your controller will send the further challenge before serving the requested action. It remembers the user requestURL so if the challenge passed, it serves what user asked, etc. The same concept can apply to the required communication level for each action so you can appropriately serve each request based on what user wants, etc. You don't have to be 1 size fit all. We love this simple and rigorous process and do not want to break its design principal. Have a good day and good weekend. :-) BaTien - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 31, 2003 1:44 AM Subject: Re: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) Hi, I agree with u that u can have another layer of abstraction(like helper beans) between action and Service layer.So that same code ecan be reused. But this some disadvangates. Firstly U are then not really using the power of Struts Configuration file which allows you to use logical mappings in Action classes And to change the Flow,U can just change the config file (So long as all required parametzers are being passed in new flow as well..).Because in our project, we had this requirement many a times.After we had done one release, the business gusy will come up with a suggestion some thing like, After AccountDetails PAge, can we go to AccountList üpage instead of Summary page etc etc .And because of Reusable actions, this was just a matter of changing the struts config file and in one of cases may be make the new caller pass a few more parameters.But there was no code duplication. So as i said in my original mail,If your services are not tied to actions, then in that case I don't see any problem in action chainning.ANd it seems to me the best thing to really harness the power of Struts..Or is there any other preformance or design issue which i have missed? Any comments:-))?? regards, Shirish -Original Message- From: batien.duong [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 30, 2003 5:09 PM To: struts-user Subject: Re: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) We achieve what you describe as a chain of actions for re-use with helper beans and follow Struts design principal as Ted described. The helper beans can be ready in cache or service pool for reuse. Look at http://myportal.myb2cb2b.com/com.dbgroups.ppf/model/web/dao.html Hope this may help. BaTien - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 30, 2003 3:34 AM Subject: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) Hi All, I have a very basic design question about struts action design..We have been developing a fairly large and complex web application involving struts and struts has proved to be a great help :-)) But after reading the book by Mr. Husted et al., Struts in action,I have some basic questions about the way we have done our project and the way it is described in the book. TO quote Mr. Husted...(Section 8.4 Chaining Actions .Note at the end of Section8.4.1. Starting fresh..) Speaking as a Software architect,chainning actions in any way is not something that I like to do.Ideally you should be able to call the business objects from any Action where they are needed.Wanting to forward control to another action implies that the Business object my be too tightly coupled.Or it may imply that the actions should descend from a common super class with hotspots that sub classes should overrideThere are occasions when chainning actions makes sense-for example if the other action is being used to render the response in lieu of a presentation
Re: design question about action chainning(As quoted in :Struts in action...byTed Husted et al..)
Isn't the action becoming part of an API a good thing? Having reusable action classes that can be strung together through struts-config is pretty useful in that you don't have to have as much coding. You can then have a work pipeline of sorts without having to create extra action classes or modify more code. BAL From: Ted Husted [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) Date: Fri, 31 Jan 2003 13:06:30 -0500 The best example of waht I'm calling an Action relay is how Struts handles validation. If validation fails, the request is forwarded to the input property, which could be another Action. This is done to complete the response, rather than continue with processing the action. This same technique is often used after a lookup, where one Action does the lookup but another Action is used to complete the response, usually to setup any tools the page might need to render. In an Action chain, control is not forwarded simply to complete the response but to continue processing. One action doesn't do some similar activity because that's the another actions job. The request/response transaction begins to be distributed between several Action, and this is where Action stop being destinations and start becoming an API. Most often, whatever processing the Action in a chain are supposed to be doing can be refactored into base actions or utility classes, so the funcationality can be reused using standard object-orientated techniques. -Ted. -- Ted Husted, Struts in Action http://husted.com/struts/book.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..)
Ted, will you give me your opinion on my post of Mon 1/27/2003 5:21 PM with a subject of RE: Two ActionForms colliding on property name? I am wondering whether you see my splitting of actions into post-actions and pre-actions as action relays or action chaining. To use the input attribute in validation to point to a previous action, the input element needs to point to what I call a pre-action but not the post-action. So this requires a separation between pre-actions and post-actions. I am not arbitrarily partioning the request/response transaction; I am drawing a well-defined line between processing necessary to complete the last user/system interaction and processing necessary to initiate the next user/system interaction. Overall, I am not grokking your division between completing the response and continuing processing. Perhaps because, in my mind, completing the response requires continued processing and why continue processing if not to complete the response (unless it is to complete the request, as in my post-action). -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, January 31, 2003 1:07 PM To: Struts Users Mailing List Subject: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) The best example of waht I'm calling an Action relay is how Struts handles validation. If validation fails, the request is forwarded to the input property, which could be another Action. This is done to complete the response, rather than continue with processing the action. This same technique is often used after a lookup, where one Action does the lookup but another Action is used to complete the response, usually to setup any tools the page might need to render. In an Action chain, control is not forwarded simply to complete the response but to continue processing. One action doesn't do some similar activity because that's the another actions job. The request/response transaction begins to be distributed between several Action, and this is where Action stop being destinations and start becoming an API. Most often, whatever processing the Action in a chain are supposed to be doing can be refactored into base actions or utility classes, so the funcationality can be reused using standard object-orientated techniques. -Ted. -- Ted Husted, Struts in Action http://husted.com/struts/book.html - 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: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..)
You've stated it correctly when you said that Actions are your flow controllers. In the case of your login/getAccounts example, you should have a business object that handles login, and a business object that gets accounts. You would then have a login action (use case controller) that would use both business objects, assuming the login was successful. You would also have a displayAccounts action (use case controller) that uses the accounts business object very similar to the way the login action uses it. So, my understanding is that the Actions you define are your use case controllers. They basically give you all the options you have with your application, but the logic of the application itself resides in the business objects. You may have lots of actins with some repeated code in a few, or you may be able to define just a few parameterized actions that handle all your use cases somewhat generically. Now, the case you've defined is that the outcome of one use case causes another use case to be executed. While I probably wouldn't check for a login that way, I'm not yet convinced that the approach itself is inherently bad. BTW, I don't see actions as handling errors so much as responding to them, and acting as an adapter layer between your application's error handling and Struts. You should probably have some error-handling mechanism in your business layer and the Action classes will interpret what comes out of the business layer and translate it into Struts errors. Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 30, 2003 4:34 AM To: [EMAIL PROTECTED] Subject: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) Hi All, I have a very basic design question about struts action design..We have been developing a fairly large and complex web application involving struts and struts has proved to be a great help :-)) But after reading the book by Mr. Husted et al., Struts in action,I have some basic questions about the way we have done our project and the way it is described in the book. TO quote Mr. Husted...(Section 8.4 Chaining Actions .Note at the end of Section8.4.1. Starting fresh..) Speaking as a Software architect,chainning actions in any way is not something that I like to do.Ideally you should be able to call the business objects from any Action where they are needed.Wanting to forward control to another action implies that the Business object my be too tightly coupled.Or it may imply that the actions should descend from a common super class with hotspots that sub classes should overrideThere are occasions when chainning actions makes sense-for example if the other action is being used to render the response in lieu of a presentation page.But valid use cases are rare.The best general practice is to stay with one-request ,one action regimen. * And also after searching the archives for action chainnign , I found another reply from Mr. Husted which says.. Wanting to chain actions is a warning sign that there is too much business logic is creeping into the Actions and they are becoming the API, rather than an adaptor for the API. (Struts should not *be* your application, it should be a gateway *to* your application.) ** ** * I have a high regard for Mr. Ted Husted and that's why I would like to clarify some of my doubts about the design strategy he has advocated in his book from the exüperienced users of this list and Mr Husted himself if possible. I dont understand what is the disadvantage in Chainning actions?HAs it some thing to do with performance?I totally agree that the business objects shuld not be tightly coupled with actions and should be callable from any where .But even after following this principal, most of the time you will end up chainning actions if u really want reusable actions.Example can be loging process of a user.So the request for loging form a user can result in 2 actions being called.1:CheckLogin(which checks user credentials) It forwards control to 2:getUserAccountList which gets the list of accounts for the user. So now the getUserAccountList action I can call from any where else by passing right params and it becomes reusable.But if i had done all of this(check log in and then get accunts)in login action, i need to write another action to get account for another page.And I am using calls to different services(LoginService and AccountService..)which are still reusable from any action here.. So the
Re: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..)
We achieve what you describe as a chain of actions for re-use with helper beans and follow Struts design principal as Ted described. The helper beans can be ready in cache or service pool for reuse. Look at http://myportal.myb2cb2b.com/com.dbgroups.ppf/model/web/dao.html Hope this may help. BaTien - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 30, 2003 3:34 AM Subject: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) Hi All, I have a very basic design question about struts action design..We have been developing a fairly large and complex web application involving struts and struts has proved to be a great help :-)) But after reading the book by Mr. Husted et al., Struts in action,I have some basic questions about the way we have done our project and the way it is described in the book. TO quote Mr. Husted...(Section 8.4 Chaining Actions .Note at the end of Section8.4.1. Starting fresh..) Speaking as a Software architect,chainning actions in any way is not something that I like to do.Ideally you should be able to call the business objects from any Action where they are needed.Wanting to forward control to another action implies that the Business object my be too tightly coupled.Or it may imply that the actions should descend from a common super class with hotspots that sub classes should overrideThere are occasions when chainning actions makes sense-for example if the other action is being used to render the response in lieu of a presentation page.But valid use cases are rare.The best general practice is to stay with one-request ,one action regimen. * And also after searching the archives for action chainnign , I found another reply from Mr. Husted which says.. Wanting to chain actions is a warning sign that there is too much business logic is creeping into the Actions and they are becoming the API, rather than an adaptor for the API. (Struts should not *be* your application, it should be a gateway *to* your application.) * I have a high regard for Mr. Ted Husted and that's why I would like to clarify some of my doubts about the design strategy he has advocated in his book from the exüperienced users of this list and Mr Husted himself if possible. I dont understand what is the disadvantage in Chainning actions?HAs it some thing to do with performance?I totally agree that the business objects shuld not be tightly coupled with actions and should be callable from any where .But even after following this principal, most of the time you will end up chainning actions if u really want reusable actions.Example can be loging process of a user.So the request for loging form a user can result in 2 actions being called.1:CheckLogin(which checks user credentials) It forwards control to 2:getUserAccountList which gets the list of accounts for the user. So now the getUserAccountList action I can call from any where else by passing right params and it becomes reusable.But if i had done all of this(check log in and then get accunts)in login action, i need to write another action to get account for another page.And I am using calls to different services(LoginService and AccountService..)which are still reusable from any action here.. So the chainning of actions this way has perfectly solved all the problems...And instead of this being a rare iuse case, most of the time , this is the pattern u will have for any use case.(Update some thing and get some data to screen...)So what is the advantage of following one-request ,one action regimen? Also I didnt understand what he means by (Struts should not *be* your application, it should be a gateway *to* your application.)As I see it,the service layer handles the business logic .But Ultimately the actions end up delegating the requests to service and so doing error handling as well as handling flow control(Some thing like if this error, go to page 1, for that request go to page 2..)So they are very much part of the application...Infact they handle the application flow.Is this right or Am i missing some thing very bascic here? This is important as We have the next phase of development starting next week and we are in the process of evaluating our architecture and finding any flaws..So any help will be highly appreciated... Sory for being tooo verbose.But i couldn't have exlained it any other way. regards, Shirish Shirish Sakhare Application Developer (CEFS PROJECT) (CEFS) Corporate Employee Financial Services UBS AG Stauffacherstrasse 41 P.O. Box,
RE: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..)
But you still have to duplicate code in the actions, right? Even if that code is as simple as: Service service = Service.getService(SERVICE_KEY); Foo[] foos = service.getFoos(); request.setAttribute(FOO_KEY, foos); Action chaining allows this code to be written once and used many times. Thus you get reuse of presentation code, not just business logic. -Original Message- From: BaTien Duong [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 30, 2003 11:09 AM To: Struts Users Mailing List Subject: Re: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) We achieve what you describe as a chain of actions for re-use with helper beans and follow Struts design principal as Ted described. The helper beans can be ready in cache or service pool for reuse. Look at http://myportal.myb2cb2b.com/com.dbgroups.ppf/model/web/dao.html Hope this may help. BaTien - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 30, 2003 3:34 AM Subject: design question about action chainning(As quoted in :Struts in action...by Ted Husted et al..) Hi All, I have a very basic design question about struts action design..We have been developing a fairly large and complex web application involving struts and struts has proved to be a great help :-)) But after reading the book by Mr. Husted et al., Struts in action,I have some basic questions about the way we have done our project and the way it is described in the book. TO quote Mr. Husted...(Section 8.4 Chaining Actions .Note at the end of Section8.4.1. Starting fresh..) Speaking as a Software architect,chainning actions in any way is not something that I like to do.Ideally you should be able to call the business objects from any Action where they are needed.Wanting to forward control to another action implies that the Business object my be too tightly coupled.Or it may imply that the actions should descend from a common super class with hotspots that sub classes should overrideThere are occasions when chainning actions makes sense-for example if the other action is being used to render the response in lieu of a presentation page.But valid use cases are rare.The best general practice is to stay with one-request ,one action regimen. * And also after searching the archives for action chainnign , I found another reply from Mr. Husted which says.. Wanting to chain actions is a warning sign that there is too much business logic is creeping into the Actions and they are becoming the API, rather than an adaptor for the API. (Struts should not *be* your application, it should be a gateway *to* your application.) ** ** * I have a high regard for Mr. Ted Husted and that's why I would like to clarify some of my doubts about the design strategy he has advocated in his book from the exüperienced users of this list and Mr Husted himself if possible. I dont understand what is the disadvantage in Chainning actions?HAs it some thing to do with performance?I totally agree that the business objects shuld not be tightly coupled with actions and should be callable from any where .But even after following this principal, most of the time you will end up chainning actions if u really want reusable actions.Example can be loging process of a user.So the request for loging form a user can result in 2 actions being called.1:CheckLogin(which checks user credentials) It forwards control to 2:getUserAccountList which gets the list of accounts for the user. So now the getUserAccountList action I can call from any where else by passing right params and it becomes reusable.But if i had done all of this(check log in and then get accunts)in login action, i need to write another action to get account for another page.And I am using calls to different services(LoginService and AccountService..)which are still reusable from any action here.. So the chainning of actions this way has perfectly solved all the problems...And instead of this being a rare iuse case, most of the time , this is the pattern u will have for any use case.(Update some thing and get some data to screen...)So what is the advantage of following one-request ,one action regimen? Also I didnt understand what he means by (Struts should not *be* your application, it should be a gateway *to* your application.)As I see it,the service layer handles the business logic .But Ultimately the actions end up delegating
RE: Design Question regarding navigation menu
I could not follow your question. A good practices that I use is to have centralized navigation in XML, using Struts menu from sf.net. So the question is: in StrutsMenu, how do you highlight the currently selected menu item? Another question about StrutsMenu: is it possible to get a string that represents the current path to the currently selected menu item: something like 'Main Part1 Subpart1 Item3'... This e-mail is intended only for the above addressee. It may contain privileged information. If you are not the addressee you must not copy, distribute, disclose or use any of the information in it. If you have received it in error please delete it and immediately notify the sender. Security Notice: all e-mail, sent to or from this address, may be accessed by someone other than the recipient, for system management and security reasons. This access is controlled under Regulation of Investigatory Powers Act 2000, Lawful Business Practises. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Design Question regarding navigation menu
I could not follow your question. A good practices that I use is to have centralized navigation in XML, using Struts menu from sf.net. .V Mark Conlin wrote: Design question regarding navigation menu. (I am using tiles) Suppose I have a navigation menu with several choices/sections, I would like to highlight the choice/section the user is currently in. Example: choice A, choice B, choice C Which is the proper approach? Create a separate menu with each choice highlighted and then have each of my tile-definitions override to the correct one. OR Create one menu header and have it make the decision as to which menu choice to highlight based on some value (value would be set/altered by an Action) OR Create one menu header that makes a decision as to which menu choice to highlight based on the URL. I am leaning towards choice two. but I am not sure what the proper way is. Any suggestions/Examples would be great. Thank you Mark -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Design question Struts - EJB.
Bryan - Looking at Struts as a Model, View, Controller architecture, EJB access is a strategy that is generally used IN MODEL COMPONENTS. - The View components are primarily the JSP's that are used for presentation. - The Controller components are the Action classes you write. These must extend org.apache.struts.action.Action in order for Struts to work. These two parts of Struts are the basic framework that control the request/response flow and build the html pages. - Model components provide access to back-end data stores or services. The provide a programming Model that make it easy for code in the Action classes to interact with the back-end data and services. This is where EJB's generally are useful. The Event model in Petstore is similar to how Action classes are used in Struts: - In petstore, incoming requests were translated into Events that were then used to execute the business logic of the request - In Struts, Action classes coordinate the execution of the business logic. The parallel isn't perfect, but it's reasonable putting on fire-proof underwear here in anticipation of flames. Of course, the real question to ask is if you really need EJB's anymore once you're using Struts. You may, but you may not. Here are some places it may be useful to use EJB's in Struts - note all these are Model component-based. (Others on the list may have other thoughts to contribute here...): - As in the Blueprints, there may be a session-ejb facade that provides a front-end into a whole series of ejb's in the back-end. This session facade would be accessed from the Action class. The Session Facade should return Value Objects similar to petstore - these would be passed to the Views (jsp pages) for presentation to the end-users. - Entity beans may be used in a couple ways: - In the Action (Controller) class you may directly access an Entity bean that is itself acting as a model component. - From the Action class, you may access a DAO (or some similar pattern) that in turn access an entity bean - In either of these two cases Value Objects (sometimes referred to as Data Transfer Objects or- DTOs) should be returned. - From the Action class you may access a web service that is a wrapper for a stateless bean on some container somewhere. The common theme is this: - The View and Controller components in Struts manage interaction with and presentation to the User. - Model components encapsulate interaction with a back-end service or data-store. This is where EJB's are most useful. Best of luck, Kevin bryan hansen [EMAIL PROTECTED] on 06/26/2002 06:54:33 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc:(bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Design question Struts - EJB. I was really looking forward to read the chapter in the book on review at theserverside.com on Struts and EJBs. We are currently implementing a system and are going to use struts for the web framework and ejbs for the model. The java blueprints return an Event from the would be action class for comparison in struts. The struts class returns an ActionForward instead of an Event. I think it is really elegant how they are handling this because they can just pass an Event to an EJBController and then get an EventResponse back. Is there an easy way that just isn't presenting itself where I am looking? How are other people integrating EJBs without just opening up the entire model? Thanks, Bryan __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design question on roles and tasks
Hi Chong, Container based security is a topic that comes up regularly on the list try searching on it. When you use container based security your authenticated user will be associated with one or more roles. This is a J2EE feature. Struts can use the 'role' information in several ways: - the tile and template extensions provide a 'role' tag to conditionally include content depending upon a users role. - within your action class your can call request.isUserInRole (role) and execute code depending on the result. - within the struts-config you can set a role against an action-mapping so that only users in the given role can access the action. Never used this feature so I'm not sure what happens if the user is not in the role. Jon Ridgway -Original Message- From: Chong Oh [mailto:[EMAIL PROTECTED]] Sent: 08 May 2002 21:10 To: 'Struts Users Mailing List' Subject: Design question on roles and tasks All: If this has been discussed already, I apologize. I am implementing an user access based on roles and tasks, where a user has roles and each role has tasks. Ideally, each task has a one to one relationship with each link on the JSP, whereby the access to those links depends on user's role/s. All roles and tasks are persisted. Upon successful login, user's roles will be accessed and all tasks associated will be retrieved. All links associated with tasks will be shown on the JSP via logic tags. Has anyone implement this with struts yet. Could you share your experience with me, particularly the question whether this is a good design in the first place? Thanks in advance Chong -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] The contents of this email are intended only for the named addressees and may contain confidential and/or privileged material. If received in error please contact UPCO on +44 (0) 113 201 0600 and then delete the entire e-mail from your system. Unauthorised review, distribution, disclosure or other use of this information could constitute a breach of confidence. Your co-operation in this matter is greatly appreciated. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Design question
If you're using Apache, create a rewrite rule that rewrites anything ending in .jsp to .do. Or a rewrite rule that filters only URI's in your webapp and forwards them to a home page if a .jsp is requested. I don't think there can be a Struts'only solution. The issue is that any URI ending in .jsp could be requested - Struts works by recognizing certain URI's (those specified by the definition of the primary Action servlet in yout web.xml), and routing them to the central Action servlet for processing. If a URI is requested (ending in jsp or not) that doesn't match the URI pattern for the Action servlet, then Struts won't even see it. A generic jsp approach might be to create a custom tag (like, CheckValidRequest or something similar) that looks for a bean or something similar that should be in the Session. If it's not there then redirect to a home page or something. Will Spies/Towers Perrin [EMAIL PROTECTED] on 04/29/2002 04:08:04 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc:(bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Re: Design question Good idea but the other problem is your web server doesn't mix with non-Struts applications. I was kinda hoping for a struts only solution. Thanks for the idea though! ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Kevin.Bedell@sunlcc: (bcc: Will Spies/Towers Perrin) ife.com Subject: Re: Design question 04/29/02 03:51 PM Please respond to Struts Users Mailing List Configure the web server to not recognize the .jsp mime type. Then any link to a .jsp page will generate an Error 404 Page Not Found. The servlet mappings should still work fine. That being said, I've found that whenever I make a decision like this based on a design preference, I almost always find some unusual case where it really makes sense to do things the way I've said shouldn't be done. FWIW - Kevin Will Spies/Towers Perrin [EMAIL PROTECTED] on 04/29/2002 03:53:16 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc:(bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Design question In my opinion, most ( if not all ) links should be Action URIs. What I mean is, struts views should not post to urls which are JSP struts views. Rather, valid URLs that are posted to ( or even referenced in ) should always be controllers. For those who agree with this philosophy, can you give me some suggestions on how I can force this? One idea I've had is to place a customized on top of all JSP views which checks for a hidden request variable that only my controllers know about. So, if this request variable is not found than the view craps out. Any other ideas? ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] --- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. --- -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] --- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. --- -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL
Re: Design question
Thanks for all the ideas. Looks like my best option is , as was suggested, to place all JSPs below WEB-INF. This way they are invisible to the browser but visible to the struts forwarding mechanism. In addition, I can then create a tag to do some extra checking as you suggest. Thanks to all again! ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Kevin.Bedell@sunlcc: (bcc: Will Spies/Towers Perrin) ife.com Subject: Re: Design question 04/30/02 08:10 AM Please respond to Struts Users Mailing List If you're using Apache, create a rewrite rule that rewrites anything ending in .jsp to .do. Or a rewrite rule that filters only URI's in your webapp and forwards them to a home page if a .jsp is requested. I don't think there can be a Struts'only solution. The issue is that any URI ending in .jsp could be requested - Struts works by recognizing certain URI's (those specified by the definition of the primary Action servlet in yout web.xml), and routing them to the central Action servlet for processing. If a URI is requested (ending in jsp or not) that doesn't match the URI pattern for the Action servlet, then Struts won't even see it. A generic jsp approach might be to create a custom tag (like, CheckValidRequest or something similar) that looks for a bean or something similar that should be in the Session. If it's not there then redirect to a home page or something. Will Spies/Towers Perrin [EMAIL PROTECTED] on 04/29/2002 04:08:04 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc:(bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Re: Design question Good idea but the other problem is your web server doesn't mix with non-Struts applications. I was kinda hoping for a struts only solution. Thanks for the idea though! ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Kevin.Bedell@sunlcc: (bcc: Will Spies/Towers Perrin) ife.com Subject: Re: Design question 04/29/02 03:51 PM Please respond to Struts Users Mailing List Configure the web server to not recognize the .jsp mime type. Then any link to a .jsp page will generate an Error 404 Page Not Found. The servlet mappings should still work fine. That being said, I've found that whenever I make a decision like this based on a design preference, I almost always find some unusual case where it really makes sense to do things the way I've said shouldn't be done. FWIW - Kevin Will Spies/Towers Perrin [EMAIL PROTECTED] on 04/29/2002 03:53:16 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc:(bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Design question In my opinion, most ( if not all ) links should be Action URIs. What I mean is, struts views should not post to urls which are JSP struts views. Rather, valid URLs that are posted to ( or even referenced in ) should always be controllers. For those who agree with this philosophy, can you give me some suggestions on how I can force this? One idea I've had is to place a customized on top of all JSP views which
Re: Design question
Configure the web server to not recognize the .jsp mime type. Then any link to a .jsp page will generate an Error 404 Page Not Found. The servlet mappings should still work fine. That being said, I've found that whenever I make a decision like this based on a design preference, I almost always find some unusual case where it really makes sense to do things the way I've said shouldn't be done. FWIW - Kevin Will Spies/Towers Perrin [EMAIL PROTECTED] on 04/29/2002 03:53:16 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc:(bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Design question In my opinion, most ( if not all ) links should be Action URIs. What I mean is, struts views should not post to urls which are JSP struts views. Rather, valid URLs that are posted to ( or even referenced in ) should always be controllers. For those who agree with this philosophy, can you give me some suggestions on how I can force this? One idea I've had is to place a customized on top of all JSP views which checks for a hidden request variable that only my controllers know about. So, if this request variable is not found than the view craps out. Any other ideas? ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] --- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. --- -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Design question
Good idea but the other problem is your web server doesn't mix with non-Struts applications. I was kinda hoping for a struts only solution. Thanks for the idea though! ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Kevin.Bedell@sunlcc: (bcc: Will Spies/Towers Perrin) ife.com Subject: Re: Design question 04/29/02 03:51 PM Please respond to Struts Users Mailing List Configure the web server to not recognize the .jsp mime type. Then any link to a .jsp page will generate an Error 404 Page Not Found. The servlet mappings should still work fine. That being said, I've found that whenever I make a decision like this based on a design preference, I almost always find some unusual case where it really makes sense to do things the way I've said shouldn't be done. FWIW - Kevin Will Spies/Towers Perrin [EMAIL PROTECTED] on 04/29/2002 03:53:16 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc:(bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Design question In my opinion, most ( if not all ) links should be Action URIs. What I mean is, struts views should not post to urls which are JSP struts views. Rather, valid URLs that are posted to ( or even referenced in ) should always be controllers. For those who agree with this philosophy, can you give me some suggestions on how I can force this? One idea I've had is to place a customized on top of all JSP views which checks for a hidden request variable that only my controllers know about. So, if this request variable is not found than the view craps out. Any other ideas? ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] --- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. --- -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design question
Or you could put your jsp's under the WEB-INF directory. Search posts from a few weeks ago about this. It's quite a lengthy and enlightening thread. JM -Original Message- From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 4:08 PM To: Struts Users Mailing List Subject: Re: Design question Good idea but the other problem is your web server doesn't mix with non-Struts applications. I was kinda hoping for a struts only solution. Thanks for the idea though! ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Kevin.Bedell@sunlcc: (bcc: Will Spies/Towers Perrin) ife.com Subject: Re: Design question 04/29/02 03:51 PM Please respond to Struts Users Mailing List Configure the web server to not recognize the .jsp mime type. Then any link to a .jsp page will generate an Error 404 Page Not Found. The servlet mappings should still work fine. That being said, I've found that whenever I make a decision like this based on a design preference, I almost always find some unusual case where it really makes sense to do things the way I've said shouldn't be done. FWIW - Kevin Will Spies/Towers Perrin [EMAIL PROTECTED] on 04/29/2002 03:53:16 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc:(bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Design question In my opinion, most ( if not all ) links should be Action URIs. What I mean is, struts views should not post to urls which are JSP struts views. Rather, valid URLs that are posted to ( or even referenced in ) should always be controllers. For those who agree with this philosophy, can you give me some suggestions on how I can force this? One idea I've had is to place a customized on top of all JSP views which checks for a hidden request variable that only my controllers know about. So, if this request variable is not found than the view craps out. Any other ideas? ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- - This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. -- - -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design question
Couldn't you just configure your web.xml file to map all .jsp requests to some standard error page? amir [EMAIL PROTECTED] 6:02:54 PM 04/29/02 Or you could put your jsp's under the WEB-INF directory. Search posts from a few weeks ago about this. It's quite a lengthy and enlightening thread. JM -Original Message- From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 4:08 PM To: Struts Users Mailing List Subject: Re: Design question Good idea but the other problem is your web server doesn't mix with non-Struts applications. I was kinda hoping for a struts only solution. Thanks for the idea though! ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Kevin.Bedell@sunlcc: (bcc: Will Spies/Towers Perrin) ife.com Subject: Re: Design question 04/29/02 03:51 PM Please respond to Struts Users Mailing List Configure the web server to not recognize the .jsp mime type. Then any link to a .jsp page will generate an Error 404 Page Not Found. The servlet mappings should still work fine. That being said, I've found that whenever I make a decision like this based on a design preference, I almost always find some unusual case where it really makes sense to do things the way I've said shouldn't be done. FWIW - Kevin Will Spies/Towers Perrin [EMAIL PROTECTED] on 04/29/2002 03:53:16 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc:(bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Design question In my opinion, most ( if not all ) links should be Action URIs. What I mean is, struts views should not post to urls which are JSP struts views. Rather, valid URLs that are posted to ( or even referenced in ) should always be controllers. For those who agree with this philosophy, can you give me some suggestions on how I can force this? One idea I've had is to place a customized on top of all JSP views which checks for a hidden request variable that only my controllers know about. So, if this request variable is not found than the view craps out. Any other ideas? ___ Will Spies Towers Perrin Phone: (215)246-7145 e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- - This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. -- - -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: design question
I'm sure I've seen some notes on this in the Struts resources to get common behaviour Create your own action class that extends the struts Actions to hold common function calls Have your specific actions extend this default Action You can further subclass the default action e.g. we have a subclass DefaulCRUDAction with specific behaviours Some where I've seen a variation on this where the base class action perform calls a different method on each specific action Ah found it see Ted Husted's Struts Catalog Quote . Use a Base Action for your application Often, the Actions in your application will need to perform some basic tasks. To ensure these tasks are implement consistently, create a base Action for the others in your application to subclass. If key tasks needs to be completed in each Action's perform() method, a good approach is to create a new abstract methods for your subclasses to use in lieu of perform(). The base Action class does its business, and if all is well, then returns the result of the new method. This allows you to change the signature of your new method, if there is ever any reason for that, and provides a cleaner flow. public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Application specific behaviour // if everything is kosher call subclass return ( performAction(mapping,form,request,response, myParameter ) ) } where performAction is an abstract method of the base class. ... -Original Message- From: Ronald Haring [mailto:[EMAIL PROTECTED]] Sent: 05 March 2002 12:15 To: '[EMAIL PROTECTED]' Subject: design question Hi all, I've studied the design paper that Ted has put up at his site (http://husted.com/about/scaffolding/strutByStrut.htm) . Very clear explanation Ted, it only left me with one question. In your paper you state that every form should have its own action. However for my last project (and my first struts project) I used the same action for most of the forms. This action would then decide based upon a navigate field in the form : - which formBean to create and populate - which mapping to return based on a large if (navigation.equals(something)) tree. I submitted always to the same form, so that this ControllerAction could perform some default behavious I liked to execute (e.g. dynamic change of language, default SQLException handling) and that all the navigation was in the same class. Somehow I have the feeling that this is not the way to go. However on the detail screens there are links to other detail screens. These are simple links like a href=javascipt:goSubmit('showFirstDetailsScreen') ... a href=javascipt:goSubmit('showSecondeDetailsScreen') etc etc. (where goSubmit is a javascript function that will fill the navigate field with the given value and then submit the form). If I want a action for every form how should I set this so that showFirstDetailsScreen will go to the right action, without using multiple forms (since this really screws up the html lay-out) Gr Ronald Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer --- *** This email message contains confidential information for the above addressee only. If you are not the intended addressee you must not disclose or use the information in any manner whatsoever. Any opinion or views contained in this email message are those of the sender, do not represent those of the Company in any way and reliance should not be placed upon its contents. Unless otherwise stated this email message is not intended to be contractually binding. Where an Agreement exists between our respective companies and there is conflict between the contents of this email message and the Agreement then the terms of that Agreement shall prevail. Abbey National Treasury Services plc. Registered in England. Registered Office: Abbey House, Baker Street, London NW1 6XL. Company Registration No: 2338548. Regulated by the FSA *** -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For
RE: design question
If key tasks needs to be completed in each Action's perform() method, a good approach is to create a new abstract methods for your subclasses to use in lieu of perform(). The base Action class does its business, and if all is well, then returns the result of the new method. This allows you to change the signature of your new method, if there is ever any reason for that, and provides a cleaner flow. public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Application specific behaviour // if everything is kosher call subclass return ( performAction(mapping,form,request,response, myParameter ) yes indeed, this will be cleaner and better then my solution. However I am still stuck with the submit to different actions aspect, for which I used the general controller. (Quoting myself, finally I got quoted ;) However on the detail screens there are links to other detail screens. These are simple links like a href=javascipt:goSubmit('showFirstDetailsScreen') ... a href=javascipt:goSubmit('showSecondeDetailsScreen') etc etc. (where goSubmit is a javascript function that will fill the navigate field with the given value and then submit the form). If I want a action for every form how should I set this so that showFirstDetailsScreen will go to the right action, without using multiple forms (since this really screws up the html lay-out) Gr Ronald Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer ---
RE: design question
i see I am looking to build something similar and I am thinking of managing this through the action mappings. I am hoping to manage this as follows using the same action and keeping the form in the session. I plan to read up on building wizard type forms but from my small knowledge i think this wwould work e.g. action path=/editPage1 forward=/editDataSet.do parameter=PAGE1 type=.mo..web.EditAction name=DatabaseTypeForm scope=session validate=false forward name=success path=/editPage2.do/ /action action path=/editPage2 forward=/CriteriaEdit.jsp etc /action action path=/editPage3 forward=/FactorEdit.jsp etc /action action path=/editPage4 forward=/DataEdit.jsp etc /action -Original Message- From: Ronald Haring [mailto:[EMAIL PROTECTED]] Sent: 05 March 2002 12:51 To: 'Struts Users Mailing List' Subject: RE: design question If key tasks needs to be completed in each Action's perform() method, a good approach is to create a new abstract methods for your subclasses to use in lieu of perform(). The base Action class does its business, and if all is well, then returns the result of the new method. This allows you to change the signature of your new method, if there is ever any reason for that, and provides a cleaner flow. public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Application specific behaviour // if everything is kosher call subclass return ( performAction(mapping,form,request,response, myParameter ) yes indeed, this will be cleaner and better then my solution. However I am still stuck with the submit to different actions aspect, for which I used the general controller. (Quoting myself, finally I got quoted ;) However on the detail screens there are links to other detail screens. These are simple links like a href=javascipt:goSubmit('showFirstDetailsScreen') ... a href=javascipt:goSubmit('showSecondeDetailsScreen') etc etc. (where goSubmit is a javascript function that will fill the navigate field with the given value and then submit the form). If I want a action for every form how should I set this so that showFirstDetailsScreen will go to the right action, without using multiple forms (since this really screws up the html lay-out) Gr Ronald Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer --- *** This email message contains confidential information for the above addressee only. If you are not the intended addressee you must not disclose or use the information in any manner whatsoever. Any opinion or views contained in this email message are those of the sender, do not represent those of the Company in any way and reliance should not be placed upon its contents. Unless otherwise stated this email message is not intended to be contractually binding. Where an Agreement exists between our respective companies and there is conflict between the contents of this email message and the Agreement then the terms of that Agreement shall prevail. Abbey National Treasury Services plc. Registered in England. Registered Office: Abbey House, Baker Street, London NW1 6XL. Company Registration No: 2338548. Regulated by the FSA *** -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: design question
Ah yes, that is a solution. But then you have to keep the general data in session indeed, which I never feel to comfortable about. But thx for the pointer. Gr Ronald i see I am looking to build something similar and I am thinking of managing this through the action mappings. I am hoping to manage this as follows using the same action and keeping the form in the session. I plan to read up on building wizard type forms but from my small knowledge i think this wwould work e.g. action path=/editPage1 forward=/editDataSet.do parameter=PAGE1 type=.mo..web.EditAction name=DatabaseTypeForm scope=session validate=false forward name=success path=/editPage2.do/ /action action path=/editPage2 forward=/CriteriaEdit.jsp etc /action action path=/editPage3 forward=/FactorEdit.jsp etc /action action path=/editPage4 forward=/DataEdit.jsp etc /action Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer ---
RE: design question
You have to keep the data in the session or write it to the database. (Storing it on each form as hidden fields seems too fiddly to me). Unless you have huge volumes I actually prefer to save it on the database have a status field that indicates the data is incomplete. --- Ronald Haring [EMAIL PROTECTED] wrote: Ah yes, that is a solution. But then you have to keep the general data in session indeed, which I never feel to comfortable about. But thx for the pointer. Gr Ronald i see I am looking to build something similar and I am thinking of managing this through the action mappings. I am hoping to manage this as follows using the same action and keeping the form in the session. I plan to read up on building wizard type forms but from my small knowledge i think this wwould work e.g. action path=/editPage1 forward=/editDataSet.do parameter=PAGE1 type=.mo..web.EditAction name=DatabaseTypeForm scope=session validate=false forward name=success path=/editPage2.do/ /action action path=/editPage2 forward=/CriteriaEdit.jsp etc /action action path=/editPage3 forward=/FactorEdit.jsp etc /action action path=/editPage4 forward=/DataEdit.jsp etc /action Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer --- = ~~ Search the archive:- http://www.mail-archive.com/struts-user%40jakarta.apache.org/ ~~ Keith Bacon - Looking for struts work - South-East UK. phone UK 07960 011275 __ Do You Yahoo!? Try FREE Yahoo! Mail - the world's greatest free email! http://mail.yahoo.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: design question
There's really no reason not to keep the data in the session. The session is server-side and is not transmitted to the client, so it's secure. I can't think of any other reason you would be uncomfortable with using the session, but if you have a different concern please feel free to voice it. HTH, Eddie - Original Message - From: Ronald Haring [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Tuesday, March 05, 2002 7:07 AM Subject: RE: design question Ah yes, that is a solution. But then you have to keep the general data in session indeed, which I never feel to comfortable about. But thx for the pointer. Gr Ronald i see I am looking to build something similar and I am thinking of managing this through the action mappings. I am hoping to manage this as follows using the same action and keeping the form in the session. I plan to read up on building wizard type forms but from my small knowledge i think this wwould work e.g. action path=/editPage1 forward=/editDataSet.do parameter=PAGE1 type=.mo..web.EditAction name=DatabaseTypeForm scope=session validate=false forward name=success path=/editPage2.do/ /action action path=/editPage2 forward=/CriteriaEdit.jsp etc /action action path=/editPage3 forward=/FactorEdit.jsp etc /action action path=/editPage4 forward=/DataEdit.jsp etc /action Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 -- -- --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer -- -- --- -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: design question
I have one big problem and one minor problem with keeping information in sessions - it takes memory, and you have no way of telling when this will released (sure if session timeouts, then you might suspect that it will be cleaned any time soon, but its always up to the gc to do that, so never sure) - when using load balancing you have to use sticky redirection to the server maintaining the session object for this user (but this is not very important yet and I know you will have to do that with only a sessionid key in the client object as well) Gr Ronald -Original Message- From: Eddie Bush [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 05, 2002 3:47 PM To: Struts Users Mailing List Subject: Re: design question There's really no reason not to keep the data in the session. The session is server-side and is not transmitted to the client, so it's secure. I can't think of any other reason you would be uncomfortable with using the session, but if you have a different concern please feel free to voice it. HTH, Eddie - Original Message - From: Ronald Haring [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Tuesday, March 05, 2002 7:07 AM Subject: RE: design question Ah yes, that is a solution. But then you have to keep the general data in session indeed, which I never feel to comfortable about. But thx for the pointer. Gr Ronald i see I am looking to build something similar and I am thinking of managing this through the action mappings. I am hoping to manage this as follows using the same action and keeping the form in the session. I plan to read up on building wizard type forms but from my small knowledge i think this wwould work e.g. action path=/editPage1 forward=/editDataSet.do parameter=PAGE1 type=.mo..web.EditAction name=DatabaseTypeForm scope=session validate=false forward name=success path=/editPage2.do/ /action action path=/editPage2 forward=/CriteriaEdit.jsp etc /action action path=/editPage3 forward=/FactorEdit.jsp etc /action action path=/editPage4 forward=/DataEdit.jsp etc /action Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 -- -- --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer -- -- --- -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer ---
RE: design question
You have to keep the data in the session or write it to the database. (Storing it on each form as hidden fields seems too fiddly to me). Unless you have huge volumes I actually prefer to save it on the database have a status field that indicates the data is incomplete. that is true for data entry screens. Not for various display screens where you only need an identifier to retrieve your information from a database. For data entry screens I think I will have to rely on sessions, since I like my data in the database to be complete otherwise you should have a worker thread to check your database for incomplete fields and destroy these incomplete records after a number of time/days/weeks. Gr Ronald Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer ---
Re: design question
A third option people have mentioned is to serialize the form-bean as a single hidden field. As part of validate, you can repopulate any null fields. Never actually tried this one myself, but it seems clever. -- Ted Husted, Husted dot Com, Fairport NY US -- Developing Java Web Applications with Struts -- Tel: +1 585 737-3463 -- Web: http://husted.com/about/services keithBacon wrote: You have to keep the data in the session or write it to the database. (Storing it on each form as hidden fields seems too fiddly to me). Unless you have huge volumes I actually prefer to save it on the database have a status field that indicates the data is incomplete. --- Ronald Haring [EMAIL PROTECTED] wrote: Ah yes, that is a solution. But then you have to keep the general data in session indeed, which I never feel to comfortable about. But thx for the pointer. Gr Ronald i see I am looking to build something similar and I am thinking of managing this through the action mappings. I am hoping to manage this as follows using the same action and keeping the form in the session. I plan to read up on building wizard type forms but from my small knowledge i think this wwould work e.g. action path=/editPage1 forward=/editDataSet.do parameter=PAGE1 type=.mo..web.EditAction name=DatabaseTypeForm scope=session validate=false forward name=success path=/editPage2.do/ /action action path=/editPage2 forward=/CriteriaEdit.jsp etc /action action path=/editPage3 forward=/FactorEdit.jsp etc /action action path=/editPage4 forward=/DataEdit.jsp etc /action Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer --- = ~~ Search the archive:- http://www.mail-archive.com/struts-user%40jakarta.apache.org/ ~~ Keith Bacon - Looking for struts work - South-East UK. phone UK 07960 011275 __ Do You Yahoo!? Try FREE Yahoo! Mail - the world's greatest free email! http://mail.yahoo.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: design question
At this point, I rarely write custom Actions any more. Now I try to use a framework action to handle all the usual action-stuff, and pass it the name of a business bean to invoke as part of the ActionMapping. At this point, I'm creating moderately complex application using only the stock actions in the scaffold package. Lots and lots of business beans, but very action classes. http://cvs.apache.org/viewcvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/ What I'm thinking about now is extending ActionMapping so that it has the same type of functionality embedded in the DispatchAction. To wit, let you specify an object to instantiate and a method to call from the ActionMapping. There could actually be a couple of different method signatures to call, maybe a perform, an execute, and then an invoke that just took a single object (the ActionForm), but have them each return a collection. There could also be an attribute to give whatever they return a name, and pop it into a context. I think we can really dispense with most actions almost completely, and configure most everything from the Struts config, as Craig envisioned in his workflow proposal. Most of what the Actions do is very predictible, it's just the wee-bit of business logic in the middle that makes one different from the other. -- Ted Husted, Husted dot Com, Fairport NY US -- Developing Java Web Applications with Struts -- Tel: +1 585 737-3463 -- Web: http://husted.com/about/services Ronald Haring wrote: Hi all, I've studied the design paper that Ted has put up at his site (http://husted.com/about/scaffolding/strutByStrut.htm) . Very clear explanation Ted, it only left me with one question. In your paper you state that every form should have its own action. However for my last project (and my first struts project) I used the same action for most of the forms. This action would then decide based upon a navigate field in the form : - which formBean to create and populate - which mapping to return based on a large if (navigation.equals(something)) tree. I submitted always to the same form, so that this ControllerAction could perform some default behavious I liked to execute (e.g. dynamic change of language, default SQLException handling) and that all the navigation was in the same class. Somehow I have the feeling that this is not the way to go. However on the detail screens there are links to other detail screens. These are simple links like a href=javascipt:goSubmit('showFirstDetailsScreen') ... a href=javascipt:goSubmit('showSecondeDetailsScreen') etc etc. (where goSubmit is a javascript function that will fill the navigate field with the given value and then submit the form). If I want a action for every form how should I set this so that showFirstDetailsScreen will go to the right action, without using multiple forms (since this really screws up the html lay-out) Gr Ronald Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer --- -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: design question
this looks very nice indeed. I will look into this some more. Thx Ted Gr Ronald At this point, I rarely write custom Actions any more. Now I try to use a framework action to handle all the usual action-stuff, and pass it the name of a business bean to invoke as part of the ActionMapping. At this point, I'm creating moderately complex application using only the stock actions in the scaffold package. Lots and lots of business beans, but very action classes. http://cvs.apache.org/viewcvs/jakarta-struts/contrib/scaffold/ src/framework/main/org/apache/scaffold/http/ What I'm thinking about now is extending ActionMapping so that it has the same type of functionality embedded in the DispatchAction. To wit, let you specify an object to instantiate and a method to call from the ActionMapping. There could actually be a couple of different method signatures to call, maybe a perform, an execute, and then an invoke that just took a single object (the ActionForm), but have them each return a collection. There could also be an attribute to give whatever they return a name, and pop it into a context. I think we can really dispense with most actions almost completely, and configure most everything from the Struts config, as Craig envisioned in his workflow proposal. Most of what the Actions do is very predictible, it's just the wee-bit of business logic in the middle that makes one different from the other. Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer ---
Re: Design question about ActionForm's validate method
Hi Ted, I was implementing this and noticed a problem in V1.0.1 1. Struts config is as below action path=/str/adminsessionview_srchpost type=com.db.eqpcs.mercstruts.struts.AdminSessionViewSrchAction name=adminsessionviewSrchForm scope=request input=/jsp/adminsessionviewsrch.jsp validate=true forward name=display_row path=/str/adminsessionview_maintget.do/ /action action path=/str/adminsessionview_maintget type=org.apache.struts.actions.ForwardAction parameter=/jsp/adminsessionview.jsp name=adminsessionviewForm scope=request validate=false / 2. The code for AdminSessionViewSrchAction does the following: AdminSessionViewForm form_obj = sess_bean.maintainStrutSearchAdminSessionViewForm(params); request.setAttribute(adminsessionviewForm, form_obj); // Now want to forward to the correct jsp, including the params return (mapping.findForward(display_row)); 3. OK, so we are seeing an action setting up the form for the following page, and that following page is being accessed via an ForwardAction, validate false. Well, it doesn't work. The prepopulated form does not display, all the fields have been reset to nothing. 4. Is this a bug, or is this a problem with my config? If display_row simlpy redirects to the jsp page directly then it works fine. Jonathan Message History From: Ted Husted [EMAIL PROTECTED] on 06/02/2002 18:47 EST Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc: Subject: Re: Design question about ActionForm's validate method In 1.0.x, it is often suggested that each link at least be represented by an ActionForward. This centralizes control over the hyperlinks in the Struts Config, which yields a number of benefits. In Struts 1.1, now the Nightly Build, support has been added for multiple Struts configuration files. In order for this feature to work, any request for a presentation page that uses elements from the configuration file (ActionForms, forwards, mappings) must be routed through the controller. This allows the controller to make the appropriate configuration available for a given page. This is becoming a common pattern, since the Velocity support, and I believe the X2 servlet, also need you to do the same thing for the same reason. The controller needs to touch the request to prepare it for the presentation layer. Many other features in advanced applications, including security, logging, and screen definitins, are easier to implement when everything passes through the controller. In a strict MVC implementation, the controller is responsible for interacting with the user. It then follows that all requests from the user should flow through the controller. Some of us had been counting the ActionForwards as flowing through the controller, but as the framework expands, and more services are being plugged in, passing the actual request through the controller becomes more and more desirable, until it's really not worth making the occasional exception any more. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Java Web Development with Struts. -- Tel +1 585 737-3463. -- Web http://www.husted.com/struts/ Alex Paransky wrote: So do you mean, all pages go through the Action? Even those which are not forms and for display purposes only? Could you shed some light as to why this is preferred? Thanks. -AP_ http://www.alexparansky.com -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 05, 2002 2:02 PM To: Struts Users Mailing List Subject: Re: Design question about ActionForm's validate method The best practice now is to use ActionMappings for everything, so that the reqeust passes through the controller. This buys you several important capabilities that become important as applications grow. Not the least of which is the new support for multiple applications in the Nightly Build. The ActionMapping has a validate property that you can use to turn off validation when the mapping is used to initialize a new form. So, typically, you will have an ActionMapping for each circumstance. action path=/item/Add type=org.apache.struts.actions.ForwardAction parameter=/pages/item/Form.jsp name=itemForm scope=request validate=false /action action path=/item/Store type=org.apache.gavel.item.http.Store name=itemForm scope=request validate=true input=/pages/item/Form.jsp
Re: Design question about ActionForm's validate method
Unfortunately, we don't have free reign on conventions, and are restricted to the patterns that the container will match. The container gets the request first, and then passes it along to Struts. For the best compatibility, a single, very simple pattern is best. One way to think about it is that the Actions are your applications API, its command set. They represent everything that your application knows how to do. One thing it does is display a form for adding a new record. Another thing might to display a page summarizing the entered data, or a page for editing the data. Displaying a form is sometimes a simple process. Often times, it is not, since dropdown boxes must be populated, security parmeters might need to be checked, other customizations might need to be performed. In practice, there is sometimes a lot to do even to simply display a data entry form. I tend to break my applications into modules, which sometimes correspond to the major tables in a database, or at least the major databases views. So I would tend to represent the URIs you mentioned as /adddress/Form.do /address/Store.do /address/View.do or /do/adddress/Form /do/address/Store /do/address/View -Ted. Alex Paransky wrote: Ok, I understand how forcing all requests through the controller is a good thing. Now, I have various types of pages: Forms - html:form... Actions - .do action of the form View - basic .jsp page to view and link to a form for further edit Is there a naming convention that you found works for you? Since, I am using .do extension for everything, it seems like I have URL's which look like this: AddressForm.do AddressSaveAction.do AddressView.do I think it would be nice to have: Address.form AddressSave.action Address.view Or something like this. The .do extension makes me think of action and I don't see a form or a view as an action. I could always map *.view and *.form to execute the servlet as well, but then Address.form and Address.view are ambiguous. Any suggestion on naming conventions? Thanks. -AP_ http://www.alexparansky.com -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 06, 2002 3:47 PM To: Struts Users Mailing List Subject: Re: Design question about ActionForm's validate method In 1.0.x, it is often suggested that each link at least be represented by an ActionForward. This centralizes control over the hyperlinks in the Struts Config, which yields a number of benefits. In Struts 1.1, now the Nightly Build, support has been added for multiple Struts configuration files. In order for this feature to work, any request for a presentation page that uses elements from the configuration file (ActionForms, forwards, mappings) must be routed through the controller. This allows the controller to make the appropriate configuration available for a given page. This is becoming a common pattern, since the Velocity support, and I believe the X2 servlet, also need you to do the same thing for the same reason. The controller needs to touch the request to prepare it for the presentation layer. Many other features in advanced applications, including security, logging, and screen definitins, are easier to implement when everything passes through the controller. In a strict MVC implementation, the controller is responsible for interacting with the user. It then follows that all requests from the user should flow through the controller. Some of us had been counting the ActionForwards as flowing through the controller, but as the framework expands, and more services are being plugged in, passing the actual request through the controller becomes more and more desirable, until it's really not worth making the occasional exception any more. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Java Web Development with Struts. -- Tel +1 585 737-3463. -- Web http://www.husted.com/struts/ Alex Paransky wrote: So do you mean, all pages go through the Action? Even those which are not forms and for display purposes only? Could you shed some light as to why this is preferred? Thanks. -AP_ http://www.alexparansky.com -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 05, 2002 2:02 PM To: Struts Users Mailing List Subject: Re: Design question about ActionForm's validate method The best practice now is to use ActionMappings for everything, so that the reqeust passes through the controller. This buys you several important capabilities that become important as applications grow. Not the least of which is the new support for multiple applications in the Nightly Build. The ActionMapping has a validate property that you can use to turn off validation when the mapping is used to initialize a new form. So, typically, you will have an ActionMapping for each circumstance. action