RE: dynamic form
Use indices properties... Danny Trieu Internet Business Group Downey Savings and Loan Association, F.A. [EMAIL PROTECTED] (949) 509-4564 The beginning of knowledge is the discovery of something we do not understand. - Frank Herbert (1920-1986) The essence of knowledge is, having it, to apply it; not having it, to confess your ignorance. - Confucius (551-479 BC) -Original Message- From: Otávio Augusto [mailto:[EMAIL PROTECTED] Sent: Friday, January 16, 2004 7:29 AM To: [EMAIL PROTECTED] Subject: dynamic form Hi all I have a form which has as many fields as are informed in a previous form. For instance: form 1 asks the number of fields i want in form 2. After inputting that number, i go to form 2, and there I must find the number of fields (same fields, they are going to be indexed=true). What should I implement in the ActionForm class to handle such fields? How to catch such fields in the ActionForm class and in the Action class? Thanks a lot Otávio Augusto - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message and any attachments are for the intended recipient(s) only and may contain privileged, confidential and/or proprietary information about Downey Savings or its customers, which Downey Savings does not intend to disclose to the public. If you received this message by mistake, please notify the sender by reply e-mail and delete the message and attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dynamic form
I don't understand what you mean. I know how to index the properties inside the iterator tag.but how to declare those properties dynamically in the ActionForm class? Thanks Otávio Augusto On Fri, 16 Jan 2004 08:56:16 -0800 Trieu, Danny [EMAIL PROTECTED] wrote: Use indices properties... Danny Trieu Internet Business Group Downey Savings and Loan Association, F.A. [EMAIL PROTECTED] (949) 509-4564 The beginning of knowledge is the discovery of something we do not understand. - Frank Herbert (1920-1986) The essence of knowledge is, having it, to apply it; not having it, to confess your ignorance. - Confucius (551-479 BC) -Original Message- From: Otávio Augusto [mailto:[EMAIL PROTECTED] Sent: Friday, January 16, 2004 7:29 AM To: [EMAIL PROTECTED] Subject: dynamic form Hi all I have a form which has as many fields as are informed in a previous form. For instance: form 1 asks the number of fields i want in form 2. After inputting that number, i go to form 2, and there I must find the number of fields (same fields, they are going to be indexed=true). What should I implement in the ActionForm class to handle such fields? How to catch such fields in the ActionForm class and in the Action class? Thanks a lot Otávio Augusto - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message and any attachments are for the intended recipient(s) only and may contain privileged, confidential and/or proprietary information about Downey Savings or its customers, which Downey Savings does not intend to disclose to the public. If you received this message by mistake, please notify the sender by reply e-mail and delete the message and attachments. - 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: Dynamic form property names
Anyone got any ideas? Thanks, Paul Paul-J Woodward paul-j.woodward+exterTo: Struts Users Mailing List [EMAIL PROTECTED] [EMAIL PROTECTED] cc: Subject: Dynamic form property names 29/12/2003 19:55 Please respond to Struts Users Mailing List Dear All, I have been struggling with this all day, It'll take a bit of background to explain what I am trying to do: I am creating an online wizard to populate templatised web pages, and hence create a dynamic struts/tiles-based site. Each template has various containers for content, each container can be filled by a set of different tiles. The templates are defined in a database. The definition for a template associates each container with the category of tile that it can hold, for instance a template may have containers for navigation and menu tiles. The database also contains a list of tiles that fit into each category of container. I would like to create a single form that lists the categories, that has radio button for every tile in each category. My code looks like this: logic:iterate id=elementCategory name=selectedTemplate property=elementCategories type=com.db.gci.ge.epg.actions.addcontent.TemplateElementCategory p bbean:write name=elementCategory property=category //b bean:write name=elementCategory property=description / Compatible elements in this category:br ul logic:iterate id=compatibleElement name=elementCategory property=compatibleElements type=com.db.gci.ge.epg.actions.addcontent.TemplateElement html:radio property=value(%= elementCategory.getName() %) idName=compatibleElement value=name bbean:write name=compatibleElement property=name //bbr bean:write name=compatibleElement property=description / /html:radio /logic:iterate /ul /p /logic:iterate The issue is this: I need to make the action form map-backed (I think) because the number of radio buttons is only know at runtime, but I can't find any way to name the radio buttons by the name of the category that is being selected. What I would like to use is value(%= elementCategory.getName() %) where my action form has a map and a setValue(String key, Object object) function. Thanks in advance, Paul -- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --
Re: Dynamic form property names
Sorry but I haven't quite catch what you looking for... Do you want to create a form in runtime? Is that it? If you're using a DynaForm it already has map. You can't set new properties to the form (it was built based on a DynaClass) but, if you extend DynaForm to a XDynaForm and make XDynaForm implement Map maybe you can set new properties on your new form. I used this approach (the DynaBean/Map extension) to start using DynaBeans with JSTL and, maybe... just maybe it can help you set new properties on your form. I can send you the class, if you want. As I said, I haven't tried this (the runtime form approach) and I don't know if this is what you are looking for... Pedro Salgado On 30/12/2003 13:34, Paul-J Woodward [EMAIL PROTECTED] wrote: Anyone got any ideas? Thanks, Paul Paul-J Woodward paul-j.woodward+exterTo: Struts Users Mailing List [EMAIL PROTECTED] [EMAIL PROTECTED] cc: Subject: Dynamic form property names 29/12/2003 19:55 Please respond to Struts Users Mailing List Dear All, I have been struggling with this all day, It'll take a bit of background to explain what I am trying to do: I am creating an online wizard to populate templatised web pages, and hence create a dynamic struts/tiles-based site. Each template has various containers for content, each container can be filled by a set of different tiles. The templates are defined in a database. The definition for a template associates each container with the category of tile that it can hold, for instance a template may have containers for navigation and menu tiles. The database also contains a list of tiles that fit into each category of container. I would like to create a single form that lists the categories, that has radio button for every tile in each category. My code looks like this: logic:iterate id=elementCategory name=selectedTemplate property=elementCategories type=com.db.gci.ge.epg.actions.addcontent.TemplateElementCategory p bbean:write name=elementCategory property=category //b bean:write name=elementCategory property=description / Compatible elements in this category:br ul logic:iterate id=compatibleElement name=elementCategory property=compatibleElements type=com.db.gci.ge.epg.actions.addcontent.TemplateElement html:radio property=value(%= elementCategory.getName() %) idName=compatibleElement value=name bbean:write name=compatibleElement property=name //bbr bean:write name=compatibleElement property=description / /html:radio /logic:iterate /ul /p /logic:iterate The issue is this: I need to make the action form map-backed (I think) because the number of radio buttons is only know at runtime, but I can't find any way to name the radio buttons by the name of the category that is being selected. What I would like to use is value(%= elementCategory.getName() %) where my action form has a map and a setValue(String key, Object object) function. Thanks in advance, Paul -- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. - 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: Dynamic form property names
Hi Pedro, I would be very grateful if you could send me the code. Thanks, Paul Pedro Salgado [EMAIL PROTECTED]To: Struts Users Mailing List [EMAIL PROTECTED] .comcc: Subject: Re: Dynamic form property names 30/12/2003 16:39 Please respond to Struts Users Mailing List Sorry but I haven't quite catch what you looking for... Do you want to create a form in runtime? Is that it? If you're using a DynaForm it already has map. You can't set new properties to the form (it was built based on a DynaClass) but, if you extend DynaForm to a XDynaForm and make XDynaForm implement Map maybe you can set new properties on your new form. I used this approach (the DynaBean/Map extension) to start using DynaBeans with JSTL and, maybe... just maybe it can help you set new properties on your form. I can send you the class, if you want. As I said, I haven't tried this (the runtime form approach) and I don't know if this is what you are looking for... Pedro Salgado On 30/12/2003 13:34, Paul-J Woodward [EMAIL PROTECTED] wrote: Anyone got any ideas? Thanks, Paul Paul-J Woodward paul-j.woodward+exterTo: Struts Users Mailing List [EMAIL PROTECTED] [EMAIL PROTECTED] cc: Subject: Dynamic form property names 29/12/2003 19:55 Please respond to Struts Users Mailing List Dear All, I have been struggling with this all day, It'll take a bit of background to explain what I am trying to do: I am creating an online wizard to populate templatised web pages, and hence create a dynamic struts/tiles-based site. Each template has various containers for content, each container can be filled by a set of different tiles. The templates are defined in a database. The definition for a template associates each container with the category of tile that it can hold, for instance a template may have containers for navigation and menu tiles. The database also contains a list of tiles that fit into each category of container. I would like to create a single form that lists the categories, that has radio button for every tile in each category. My code looks like this: logic:iterate id=elementCategory name=selectedTemplate property=elementCategories type=com.db.gci.ge.epg.actions.addcontent.TemplateElementCategory p bbean:write name=elementCategory property=category //b bean:write name=elementCategory property=description / Compatible elements in this category:br ul logic:iterate id=compatibleElement name=elementCategory property=compatibleElements type=com.db.gci.ge.epg.actions.addcontent.TemplateElement html:radio property
Re: Dynamic form fields on ActionForm
I thought there was something slightly awry in your thinking. I guess that's where examples really do help. Good luck with it, Adam On 10/09/2003 03:15 AM Cornellious Mann wrote: Adam, I missed the point about adding the index to the input field name. I was simply naming the field the same thing. It actually worked, but it worried me. Thansk for all of the help! :) --- Adam Hardy [EMAIL PROTECTED] wrote: They're indexed! 0 becomes 0, 1 becomes 1 etc., i.e. the order they went out with remains the same when they come back in. I think you must be missing the point here somewhere On 10/08/2003 10:34 PM Cornellious Mann wrote: This worked. :) Do you know if the order is guaranteed? From my testing it looks like the values appear in the array in the same order the parameters in the URL line. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes, but because they're indexed, you will see the result as an array. On 10/08/2003 07:45 PM Cornellious Mann wrote: I'm not sure about one thing though. If I name all of my inputs on the HTML page the same name, when I submit the form, won't only one of the inputs be passed along? --- Adam Hardy [EMAIL PROTECTED] wrote: I think I see what you mean. If all you want is a list of product Id's and the number of units per id, then your priority is to use indexed properties, rather than DynaForm or normal Form. If you are using indexed properties, you just name the field one name, e.g. productId, and the indexing gives the field unique names when in a list, e.g. productId[0], productId[1] etc. Similarly with units[0], units[1] On 10/08/2003 04:47 PM Cornellious Mann wrote: Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam On 10/07/2003 09:48 PM Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam On 10/07/2003 09:48 PM Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam On 10/07/2003 09:48 PM Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam On 10/07/2003 09:48 PM Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
I think I see what you mean. If all you want is a list of product Id's and the number of units per id, then your priority is to use indexed properties, rather than DynaForm or normal Form. If you are using indexed properties, you just name the field one name, e.g. productId, and the indexing gives the field unique names when in a list, e.g. productId[0], productId[1] etc. Similarly with units[0], units[1] On 10/08/2003 04:47 PM Cornellious Mann wrote: Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam On 10/07/2003 09:48 PM Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
I'm not sure about one thing though. If I name all of my inputs on the HTML page the same name, when I submit the form, won't only one of the inputs be passed along? --- Adam Hardy [EMAIL PROTECTED] wrote: I think I see what you mean. If all you want is a list of product Id's and the number of units per id, then your priority is to use indexed properties, rather than DynaForm or normal Form. If you are using indexed properties, you just name the field one name, e.g. productId, and the indexing gives the field unique names when in a list, e.g. productId[0], productId[1] etc. Similarly with units[0], units[1] On 10/08/2003 04:47 PM Cornellious Mann wrote: Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam On 10/07/2003 09:48 PM Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
Yes, but because they're indexed, you will see the result as an array. On 10/08/2003 07:45 PM Cornellious Mann wrote: I'm not sure about one thing though. If I name all of my inputs on the HTML page the same name, when I submit the form, won't only one of the inputs be passed along? --- Adam Hardy [EMAIL PROTECTED] wrote: I think I see what you mean. If all you want is a list of product Id's and the number of units per id, then your priority is to use indexed properties, rather than DynaForm or normal Form. If you are using indexed properties, you just name the field one name, e.g. productId, and the indexing gives the field unique names when in a list, e.g. productId[0], productId[1] etc. Similarly with units[0], units[1] On 10/08/2003 04:47 PM Cornellious Mann wrote: Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam On 10/07/2003 09:48 PM Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
This worked. :) Do you know if the order is guaranteed? From my testing it looks like the values appear in the array in the same order the parameters in the URL line. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes, but because they're indexed, you will see the result as an array. On 10/08/2003 07:45 PM Cornellious Mann wrote: I'm not sure about one thing though. If I name all of my inputs on the HTML page the same name, when I submit the form, won't only one of the inputs be passed along? --- Adam Hardy [EMAIL PROTECTED] wrote: I think I see what you mean. If all you want is a list of product Id's and the number of units per id, then your priority is to use indexed properties, rather than DynaForm or normal Form. If you are using indexed properties, you just name the field one name, e.g. productId, and the indexing gives the field unique names when in a list, e.g. productId[0], productId[1] etc. Similarly with units[0], units[1] On 10/08/2003 04:47 PM Cornellious Mann wrote: Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
They're indexed! 0 becomes 0, 1 becomes 1 etc., i.e. the order they went out with remains the same when they come back in. I think you must be missing the point here somewhere On 10/08/2003 10:34 PM Cornellious Mann wrote: This worked. :) Do you know if the order is guaranteed? From my testing it looks like the values appear in the array in the same order the parameters in the URL line. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes, but because they're indexed, you will see the result as an array. On 10/08/2003 07:45 PM Cornellious Mann wrote: I'm not sure about one thing though. If I name all of my inputs on the HTML page the same name, when I submit the form, won't only one of the inputs be passed along? --- Adam Hardy [EMAIL PROTECTED] wrote: I think I see what you mean. If all you want is a list of product Id's and the number of units per id, then your priority is to use indexed properties, rather than DynaForm or normal Form. If you are using indexed properties, you just name the field one name, e.g. productId, and the indexing gives the field unique names when in a list, e.g. productId[0], productId[1] etc. Similarly with units[0], units[1] On 10/08/2003 04:47 PM Cornellious Mann wrote: Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
I just did this, maybe an example will help Read the database and stuff the data into an arraylist. Stuff the arraylist into the form. Call the page and get something like this tr td class=datainput type=checkbox name=feelistinfo[0].associated value=Y checked=checked class=checkbox/td td class=datainput type=text name=feelistinfo[0].feeTypeDescription value=Application Fee/td td class=datainput type=text name=feelistinfo[0].price value=1300.0/td /tr tr td class=datainput type=checkbox name=feelistinfo[1].associated value=Y class=checkbox/td td class=datainput type=text name=feelistinfo[1].feeTypeDescription value=Appraisal Fee/td td class=datainput type=text name=feelistinfo[1].price value=0.0/td /tr change the data and submit.. Back in the action you can access the array in your form and loop through the values returned. Watch out for the checkboxes though since they dont return a value unless checked. If you want the detailed code for the different pieces let me know. --- Adam Hardy [EMAIL PROTECTED] wrote: They're indexed! 0 becomes 0, 1 becomes 1 etc., i.e. the order they went out with remains the same when they come back in. I think you must be missing the point here somewhere On 10/08/2003 10:34 PM Cornellious Mann wrote: This worked. :) Do you know if the order is guaranteed? From my testing it looks like the values appear in the array in the same order the parameters in the URL line. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes, but because they're indexed, you will see the result as an array. On 10/08/2003 07:45 PM Cornellious Mann wrote: I'm not sure about one thing though. If I name all of my inputs on the HTML page the same name, when I submit the form, won't only one of the inputs be passed along? --- Adam Hardy [EMAIL PROTECTED] wrote: I think I see what you mean. If all you want is a list of product Id's and the number of units per id, then your priority is to use indexed properties, rather than DynaForm or normal Form. If you are using indexed properties, you just name the field one name, e.g. productId, and the indexing gives the field unique names when in a list, e.g. productId[0], productId[1] etc. Similarly with units[0], units[1] On 10/08/2003 04:47 PM Cornellious Mann wrote: Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
Re: Dynamic form fields on ActionForm
I guess my question about order was more of HTML/submit question than a question about arrays. I just want to guarantee that the order of the values being sumitted stay in the order they are on the page. I was simply giving every input field the same name such as product and catching the values in a String array in the ActionForm. I needed to worry about sort order in order to associate the values to their ids. Great example, I didn't think of creating an array of object like you to keep all of the data on one record together. --- Lynn Guy [EMAIL PROTECTED] wrote: I just did this, maybe an example will help Read the database and stuff the data into an arraylist. Stuff the arraylist into the form. Call the page and get something like this tr td class=datainput type=checkbox name=feelistinfo[0].associated value=Y checked=checked class=checkbox/td td class=datainput type=text name=feelistinfo[0].feeTypeDescription value=Application Fee/td td class=datainput type=text name=feelistinfo[0].price value=1300.0/td /tr tr td class=datainput type=checkbox name=feelistinfo[1].associated value=Y class=checkbox/td td class=datainput type=text name=feelistinfo[1].feeTypeDescription value=Appraisal Fee/td td class=datainput type=text name=feelistinfo[1].price value=0.0/td /tr change the data and submit.. Back in the action you can access the array in your form and loop through the values returned. Watch out for the checkboxes though since they dont return a value unless checked. If you want the detailed code for the different pieces let me know. --- Adam Hardy [EMAIL PROTECTED] wrote: They're indexed! 0 becomes 0, 1 becomes 1 etc., i.e. the order they went out with remains the same when they come back in. I think you must be missing the point here somewhere On 10/08/2003 10:34 PM Cornellious Mann wrote: This worked. :) Do you know if the order is guaranteed? From my testing it looks like the values appear in the array in the same order the parameters in the URL line. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes, but because they're indexed, you will see the result as an array. On 10/08/2003 07:45 PM Cornellious Mann wrote: I'm not sure about one thing though. If I name all of my inputs on the HTML page the same name, when I submit the form, won't only one of the inputs be passed along? --- Adam Hardy [EMAIL PROTECTED] wrote: I think I see what you mean. If all you want is a list of product Id's and the number of units per id, then your priority is to use indexed properties, rather than DynaForm or normal Form. If you are using indexed properties, you just name the field one name, e.g. productId, and the indexing gives the field unique names when in a list, e.g. productId[0], productId[1] etc. Similarly with units[0], units[1] On 10/08/2003 04:47 PM Cornellious Mann wrote: Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
Adam, I missed the point about adding the index to the input field name. I was simply naming the field the same thing. It actually worked, but it worried me. Thansk for all of the help! :) --- Adam Hardy [EMAIL PROTECTED] wrote: They're indexed! 0 becomes 0, 1 becomes 1 etc., i.e. the order they went out with remains the same when they come back in. I think you must be missing the point here somewhere On 10/08/2003 10:34 PM Cornellious Mann wrote: This worked. :) Do you know if the order is guaranteed? From my testing it looks like the values appear in the array in the same order the parameters in the URL line. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes, but because they're indexed, you will see the result as an array. On 10/08/2003 07:45 PM Cornellious Mann wrote: I'm not sure about one thing though. If I name all of my inputs on the HTML page the same name, when I submit the form, won't only one of the inputs be passed along? --- Adam Hardy [EMAIL PROTECTED] wrote: I think I see what you mean. If all you want is a list of product Id's and the number of units per id, then your priority is to use indexed properties, rather than DynaForm or normal Form. If you are using indexed properties, you just name the field one name, e.g. productId, and the indexing gives the field unique names when in a list, e.g. productId[0], productId[1] etc. Similarly with units[0], units[1] On 10/08/2003 04:47 PM Cornellious Mann wrote: Currently, we are a stateless application. So on each request we will read the database and get a list of products. Then our JSP will generate a from a list of products. Each product will have an input that can accept the number of units per product. The problem I have is that each input field needs a different name. How can I map these different names back to a list on a ActionForm? Also, I don't really see how DynaForm helps this problem. --- Adam Hardy [EMAIL PROTECTED] wrote: Yes you can have indexed properties dynaforms. I do not use them, I prefer nested properties. But I think the docs are quite good on this topic. Re: your problem, I was just asking about categories because I have no concept of how your database stores your products. Looking at your database should give you ideas how to design the data model in your business view layers. Do you store / 'persist' your products somehow? Or do they only last as long as the user's session? Do you use a database? On 10/08/2003 03:01 PM Cornellious Mann wrote: All we have is a product ID. There is no category. How do you think category could help? Also, have you used an indexed property and DynaForm? --- Adam Hardy [EMAIL PROTECTED] wrote: Still it depends. How does the database handle the new products? Can you at least categorise them? On 10/08/2003 06:19 AM Cornellious Mann wrote: Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From === message truncated === = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam On 10/07/2003 09:48 PM Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form fields on ActionForm
Indexed form property is what you want.. I'll avoid any clever explanations, grandiose meta language or to try and sell you a book.. And give you an example.. form-bean name=productForm form-property name=product type=java.util.ArrayList / .. action name=productForm path=/products scope=session... ... DynaActionForm theForm = (DynaActionForm) form; ArrayList productList = theForm.set(product,productList); //and for some stange reason.. try without the following first session.setAttribute(product,productList); ... logic:iterate id=product name=productForm property=product html:text name=product property=price / ... DynaActionForm theForm = (DynaActionForm) form; ArrayList productList = (ArrayList) theForm.get(product); for(int i = 0;i productList.size();i++) { Product prod = (Product) productList.get(i); System.out.println( prod.getPrice() ); } ... This should help.. Cheers Mark On Tuesday, October 7, 2003, at 08:48 PM, Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.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: Dynamic form fields on ActionForm
Unfortunately, products can be added at runtime and therefore I don't know what the full set is. From the research I have done it sounds like ActionForms can not handle this situation and I will need to handle it myself in the Action. Do you agree? --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Cornellious, it depends whether you know beforehand what the full set of possible fields could be, or whether the fields themselves are not limited in name or type. If the former, then it would be easy to make a form that defined them all, and to use logic tags to display the needed fields or not in JSP. Adam On 10/07/2003 09:48 PM Cornellious Mann wrote: I am wondering what is the best approach to handle dynamic form fields within an ActionForm. I have a JSP page that will display quantity input fields for a dynamic list of products. I don't know how many products will be in the list until runtime. How can I set up my ActionForm to handle the list in input parameters? Thanks for any help. = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Best Regards, Cornellious Mann __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic Form help
I guess conceptually I'm just not understanding how this can work. For presentation what I would ideally like is: [X]Permission NamePermission Description [ ]Permission NamePermission Description Where each permission name is unique, the checkbox could be turned on or off depending on a variable linked to the permission name, and also a permission description. So on the display page there would need to be some kind of iterator that iterates through the list of permissions, creating a checkbox with the parameter being the permission name and its value being on or off, the permissions name in a text field, and also a permission description text field. I have classes built that represent a permission and a user, and classes extending vector that hold a list of users and permissions. The user class can retrieve a list of the permissions it has. The permissions class can goto the database and make a vector containing permission elements to represent all the permissions that are capable on the server. Anyway I guess I am having a really hard time designing the form in such a way that something can be iterateable in it, probably the permission name, but also be able to get/store the permission name, description, and if the user has it or not. Sorry if im not more clear... been sitting here for around 3 hours trying to figure out how to even start attacking this and ive read a lot but am drawing a blank. Thanks a ton in advance.. -David - Original Message - From: Mark Lowe [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 12:54 PM Subject: Re: Dynamic Form help You use indexed property. html:text property=permission indexed=true / This stuff i quite well documented, what isn't well documented is how to dynamically change the length of an indexed property. I've been using ArrayList for this.. form-property name=permission type=java.util.ArrayList / You'll need to scope you form to session, as you get null pointers all over the show. ArrayList myList = new ArrayList(); while(myObject.hasMoreStuff()) { myList.add(myObject.next())' } theForm.set(permission, myList); //also put the arraylist in an available context. request.setAttribute(permissions, myList.toArray()); //jsp logic:iterate id=perm name=permissions html:text name=perm property=deleteUser indexed=true / /logic:iterate I'm still working on how to store the properties in the form when the size of the form property is changed. But I think this approach with solve what you're doing. Cheers Mark On Wednesday, August 13, 2003, at 07:22 PM, David Erickson wrote: I'm developing some administrative functions for our web app, currently im working on a page where it will list all the permissions available with a checkbox by each, and the ones the current user has will be checked. I'm trying to decide the best way to go about it, becaues the permissions are pulled from a database and so they could change everytime the page is loaded, and obviously every user will have different permissions which need to be checked. It shouldnt be a problem to iterate through a list of permissions, but the question I have is when I go to submit a the form to modify the users permissions, the names of each checkbox (permission) will change, so how would I develop a form to handle that? And is there an easy way to populate all the checkboxes when the page loads? I'm using JSP's to handle it.. would love to use struts html:XXX tags if possible. Reccomendations welcome =) 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic Form help
You use indexed property. html:text property=permission indexed=true / This stuff i quite well documented, what isn't well documented is how to dynamically change the length of an indexed property. I've been using ArrayList for this.. form-property name=permission type=java.util.ArrayList / You'll need to scope you form to session, as you get null pointers all over the show. ArrayList myList = new ArrayList(); while(myObject.hasMoreStuff()) { myList.add(myObject.next())' } theForm.set(permission, myList); //also put the arraylist in an available context. request.setAttribute(permissions, myList.toArray()); //jsp logic:iterate id=perm name=permissions html:text name=perm property=deleteUser indexed=true / /logic:iterate I'm still working on how to store the properties in the form when the size of the form property is changed. But I think this approach with solve what you're doing. Cheers Mark On Wednesday, August 13, 2003, at 07:22 PM, David Erickson wrote: I'm developing some administrative functions for our web app, currently im working on a page where it will list all the permissions available with a checkbox by each, and the ones the current user has will be checked. I'm trying to decide the best way to go about it, becaues the permissions are pulled from a database and so they could change everytime the page is loaded, and obviously every user will have different permissions which need to be checked. It shouldnt be a problem to iterate through a list of permissions, but the question I have is when I go to submit a the form to modify the users permissions, the names of each checkbox (permission) will change, so how would I develop a form to handle that? And is there an easy way to populate all the checkboxes when the page loads? I'm using JSP's to handle it.. would love to use struts html:XXX tags if possible. Reccomendations welcome =) 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: Dynamic Form Fields
Currently, I have a DynaValidatorForm defined in my web app. Some of the properties of this form will be completely dynamic. I will read a database and retrieve an ArrayList. This ArrayList will contain the If I understand you correctly for (Iterator iter = al.iterator (); iter.hasNext (); ) { Field f = (Field) iter.next (); myForm.set (f.getName (), f.getValue ()); } In this case your form will have to be declared in struts-config.xml Having all the possible f.getName () though, otherwise you will get IllegalArgumentException. There is another method in DynaActionForm called getMap () this is your map of key (name) / value pairs. I am not sure if it is mutable, I can't see any setMap (), but you can try that out too. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 'dynamic' form elements in a ActionForm
Struts 1.1 supports map-backed forms, but that doesn't resolve the input form issue. I guess the key would be some type of tag that took a map and then generated a column of input fields. (Wouldn't work for everyone, since a lot of forms must be designed just so.) For extra credit, the entry names could (optionally) be resource keys that were used to find the label text. Text fields would be easy. Others would need some type of JavaBean with properties to tell the tag what to output. A bit of work, but obviously doable. I imagine it's possible to use the validator in a non-declarative way, but I don't know anyone whose doing that. If you can do a db query to get the information about the form, I imagine you could also do a query to get the information about validations for the form. It would probably be easier to write your own engine than adopt the validator. (It's not really that complicated to do.) People often ask about this sort of thing, but most of us just can't get our head around the use case. It's hard to understand what you do with the dynamic data when it comes back. Most application don't allow you to input or update an arbitrary (e.g. dynamic) set of fields. -T. Hi Ted, I was looking at the struts mailing list archives for information on generating dynamic forms/pages and came across a response you posted(http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]msgNo=30062). I'm very interested in this since I'm working on a project that requires me to create an input form that's composed of fields defined dynamically from a database. In this regard, would you mind my asking some questions: In http://jguru.com/forums/view.jsp?EID=567079, you mentioned that the solution doesn't address dynamically writing tags or dynamic validation. Do you have any recommendations in this regard? For ex. if user selects form A, I do a db query to determine what fields are in form A (i.e field name; data type-numeric, date, varchar; widget type-checkbox, text, textarea, etc; and if a selection type widget, what the valid choices are). Since your response was posted last Dec 2001, I was wondering if you know of any new features or if you can point me to any resources that would help me render the proper type of widget and validate based on data type. Is there any way to take advantage of the validator framework in a non-declarative way? On the Jakarta Struts extensions site, there was a link to http://husted.com/struts/resources/DynamicProperties.htm. This code was based on Struts 1.0. Do you know if v1.1 makes creation of the classes mentioned in this URL unnessary? I was just curious since in your response to the 'dynamic' form question, you mentioned that: It's difficult to do this in the 1.0.x release, but simple as pie in the 1.1 beta and nightly build. What feature in 1.1 made it much simpler to do than in 1.0? I'm sorry to bother you with these questions. I'm quite new to Struts. If you can spare the time to answer any of the above or offer any suggestions, I'd really appreciate it. Thanks a lot, -- 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: Dynamic form actions
Mark, Please, correct me if I'm wrong, but I think the action attribute in the html:form tag is a run time expression, so there's no need to extend the FormTag class in order to use a dynamic form action. Regards Jose Mark wrote: I just wanted to pass on a tidbit that might help one or two people out there. I have a search page that displays the results with checkboxes. There are two or three different places that i use this same search page, so rather than writing or copying the search results jsp page to several copies (to allow me to post the form thats on the results page to a different forward definition) i made a modifiecation to struts. In the FormTag.java I added some code to peek in the formbean for a property called formaction. If it finds one, it uses this new action instead of the hard coded one in the jsp page. Thus, in my action class i do this: MyBean myBean=(MyBean)actionForm; myBean.setFormaction(/Some/other/url); return mapping.findforward(default); now i have a jsp page which i can reuse its functionality in several places in my code. I had thought about using a hidden field, but the problem really stems from the statically coded form action=/Url part. Since struts doesnt allow us much flexibility here by default, I decided to add my own and it works great! Regards, Mark - 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: Dynamic form actions
No, its not a runtime expression. If you look at the code in FormTag you'll see that its not results.append(\ action=\); results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); results.append(\); It simply pulls the action mapping from the config. I changed my code to results.append(\ action=\); // check if we have a bean thats exposing a formaction property, if so, use that property, otherwise use our assigned action value in the jsp page try { Object value = RequestUtils.lookup(pageContext, beanName,formaction, null); if (value != null !value.toString().equals()) { this.action=ResponseUtils.filter(value.toString()); System.out.println(value.toString()); } } catch (Exception e) { e.printStackTrace(); } results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); *** REPLY SEPARATOR *** On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote: Mark, Please, correct me if I'm wrong, but I think the action attribute in the html:form tag is a run time expression, so there's no need to extend the FormTag class in order to use a dynamic form action. Regards Jose Mark wrote: I just wanted to pass on a tidbit that might help one or two people out there. I have a search page that displays the results with checkboxes. There are two or three different places that i use this same search page, so rather than writing or copying the search results jsp page to several copies (to allow me to post the form thats on the results page to a different forward definition) i made a modifiecation to struts. In the FormTag.java I added some code to peek in the formbean for a property called formaction. If it finds one, it uses this new action instead of the hard coded one in the jsp page. Thus, in my action class i do this: MyBean myBean=(MyBean)actionForm; myBean.setFormaction(/Some/other/url); return mapping.findforward(default); now i have a jsp page which i can reuse its functionality in several places in my code. I had thought about using a hidden field, but the problem really stems from the statically coded form action=/Url part. Since struts doesnt allow us much flexibility here by default, I decided to add my own and it works great! Regards, Mark - 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: Dynamic form actions
The code you've quoted has no impact on whether or not the html:form tag's action attribute is an rtexpr. Look at struts-html.tld: tag nameform/name tagclassorg.apache.struts.taglib.html.FormTag/tagclass bodycontentJSP/bodycontent attribute nameaction/name requiredtrue/required rtexprvaluetrue/rtexprvalue /attribute ... Quoting Mark [EMAIL PROTECTED]: No, its not a runtime expression. If you look at the code in FormTag you'll see that its not results.append(\ action=\); results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); results.append(\); It simply pulls the action mapping from the config. I changed my code to results.append(\ action=\); // check if we have a bean thats exposing a formaction property, if so, use that property, otherwise use our assigned action value in the jsp page try { Object value = RequestUtils.lookup(pageContext, beanName,formaction, null); if (value != null !value.toString().equals()) { this.action=ResponseUtils.filter(value.toString()); System.out.println(value.toString()); } } catch (Exception e) { e.printStackTrace(); } results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); *** REPLY SEPARATOR *** On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote: Mark, Please, correct me if I'm wrong, but I think the action attribute in the html:form tag is a run time expression, so there's no need to extend the FormTag class in order to use a dynamic form action. Regards Jose Mark wrote: I just wanted to pass on a tidbit that might help one or two people out there. I have a search page that displays the results with checkboxes. There are two or three different places that i use this same search page, so rather than writing or copying the search results jsp page to several copies (to allow me to post the form thats on the results page to a different forward definition) i made a modifiecation to struts. In the FormTag.java I added some code to peek in the formbean for a property called formaction. If it finds one, it uses this new action instead of the hard coded one in the jsp page. Thus, in my action class i do this: MyBean myBean=(MyBean)actionForm; myBean.setFormaction(/Some/other/url); return mapping.findforward(default); now i have a jsp page which i can reuse its functionality in several places in my code. I had thought about using a hidden field, but the problem really stems from the statically coded form action=/Url part. Since struts doesnt allow us much flexibility here by default, I decided to add my own and it works great! Regards, Mark - 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] -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic form actions
All that means is you can have mysimpleTag value=%=scripletVariable%/ false means you cannot have a scriplet variable as a value That's not quite what i wanted to do, but in a way accomplishes a similar task without modifying struts. Its not sexy enough for me ;) The whole point of MVC is seperation presentation, business logic, code html:form action=%=request.getAttribute(formaction)!=null?(String)request.getAttribute(formaction):/Default/url% method=post/ If i start putting scriptlets like that in my code, im basically breaking the MVC design pattern. Because now, my JSP page is dependent upon that scriptlet variable being in the environment, and if it used an object, say like this: html:form action=%=request.getAttribute(myForm)!=null?(MyForm)request.getAttribute(formaction).getFormaction():/Default/url% method=post/ The method I used, I believe, is a tad better because the JSP page will still function in the absence of that scriptlet variable, and is cleaner JSP code. Regards, Mark *** REPLY SEPARATOR *** On 03/14/2003 at 9:27 AM Kris Schneider wrote: The code you've quoted has no impact on whether or not the html:form tag's action attribute is an rtexpr. Look at struts-html.tld: tag nameform/name tagclassorg.apache.struts.taglib.html.FormTag/tagclass bodycontentJSP/bodycontent attribute nameaction/name requiredtrue/required rtexprvaluetrue/rtexprvalue /attribute ... Quoting Mark [EMAIL PROTECTED]: No, its not a runtime expression. If you look at the code in FormTag you'll see that its not results.append(\ action=\); results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); results.append(\); It simply pulls the action mapping from the config. I changed my code to results.append(\ action=\); // check if we have a bean thats exposing a formaction property, if so, use that property, otherwise use our assigned action value in the jsp page try { Object value = RequestUtils.lookup(pageContext, beanName,formaction, null); if (value != null !value.toString().equals()) { this.action=ResponseUtils.filter(value.toString()); System.out.println(value.toString()); } } catch (Exception e) { e.printStackTrace(); } results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); *** REPLY SEPARATOR *** On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote: Mark, Please, correct me if I'm wrong, but I think the action attribute in the html:form tag is a run time expression, so there's no need to extend the FormTag class in order to use a dynamic form action. Regards Jose Mark wrote: I just wanted to pass on a tidbit that might help one or two people out there. I have a search page that displays the results with checkboxes. There are two or three different places that i use this same search page, so rather than writing or copying the search results jsp page to several copies (to allow me to post the form thats on the results page to a different forward definition) i made a modifiecation to struts. In the FormTag.java I added some code to peek in the formbean for a property called formaction. If it finds one, it uses this new action instead of the hard coded one in the jsp page. Thus, in my action class i do this: MyBean myBean=(MyBean)actionForm; myBean.setFormaction(/Some/other/url); return mapping.findforward(default); now i have a jsp page which i can reuse its functionality in several places in my code. I had thought about using a hidden field, but the problem really stems from the statically coded form action=/Url part. Since struts doesnt allow us much flexibility here by default, I decided to add my own and it works great! Regards, Mark - 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] -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.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: Dynamic form actions
Right, so you'd put the code to determine the appropriate value for the action attribute in your action, not in a JSP expression. That value could be stored in a request attribute and accessed simply as: html:form action='%= request.getAttribute(formaction) %' html-el:form might even let you do (never used it): html-el:form action=${formaction} Of course, this assumes you're doing the MVC thing of disallowing direct client access to your JSP pages. It just seems confusing to have an attribute that may or may not be used. I'd rather have the attribute value always static or always dynamic. But that's personal preference, I really just wanted to correct the statement about the request-time value. Whether that's of any use in your case is another issue. Quoting Mark [EMAIL PROTECTED]: All that means is you can have mysimpleTag value=%=scripletVariable%/ false means you cannot have a scriplet variable as a value That's not quite what i wanted to do, but in a way accomplishes a similar task without modifying struts. Its not sexy enough for me ;) The whole point of MVC is seperation presentation, business logic, code html:form action=%=request.getAttribute(formaction)!=null?(String)request.getAttribute(formaction):/Default/url% method=post/ If i start putting scriptlets like that in my code, im basically breaking the MVC design pattern. Because now, my JSP page is dependent upon that scriptlet variable being in the environment, and if it used an object, say like this: html:form action=%=request.getAttribute(myForm)!=null?(MyForm)request.getAttribute(formaction).getFormaction():/Default/url% method=post/ The method I used, I believe, is a tad better because the JSP page will still function in the absence of that scriptlet variable, and is cleaner JSP code. Regards, Mark *** REPLY SEPARATOR *** On 03/14/2003 at 9:27 AM Kris Schneider wrote: The code you've quoted has no impact on whether or not the html:form tag's action attribute is an rtexpr. Look at struts-html.tld: tag nameform/name tagclassorg.apache.struts.taglib.html.FormTag/tagclass bodycontentJSP/bodycontent attribute nameaction/name requiredtrue/required rtexprvaluetrue/rtexprvalue /attribute ... Quoting Mark [EMAIL PROTECTED]: No, its not a runtime expression. If you look at the code in FormTag you'll see that its not results.append(\ action=\); results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); results.append(\); It simply pulls the action mapping from the config. I changed my code to results.append(\ action=\); // check if we have a bean thats exposing a formaction property, if so, use that property, otherwise use our assigned action value in the jsp page try { Object value = RequestUtils.lookup(pageContext, beanName,formaction, null); if (value != null !value.toString().equals()) { this.action=ResponseUtils.filter(value.toString()); System.out.println(value.toString()); } } catch (Exception e) { e.printStackTrace(); } results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); *** REPLY SEPARATOR *** On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote: Mark, Please, correct me if I'm wrong, but I think the action attribute in the html:form tag is a run time expression, so there's no need to extend the FormTag class in order to use a dynamic form action. Regards Jose Mark wrote: I just wanted to pass on a tidbit that might help one or two people out there. I have a search page that displays the results with checkboxes. There are two or three different places that i use this same search page, so rather than writing or copying the search results jsp page to several copies (to allow me to post the form thats on the results page to a different forward definition) i made a modifiecation to struts. In the FormTag.java I added some code to peek in the formbean for a property called formaction. If it finds one, it uses this new action instead of the hard coded one in the jsp page. Thus, in my action class i do this: MyBean myBean=(MyBean)actionForm; myBean.setFormaction(/Some/other/url); return mapping.findforward(default); now i have a jsp page which i can reuse its functionality in several places in my code. I had thought about using a hidden field, but the problem really stems from the statically coded form action=/Url part. Since struts doesnt allow us much flexibility here by default, I decided to add my own and it works great! Regards, Mark
Re: Dynamic form actions
thanks, good ideas *** REPLY SEPARATOR *** On 03/14/2003 at 10:24 AM Kris Schneider wrote: Right, so you'd put the code to determine the appropriate value for the action attribute in your action, not in a JSP expression. That value could be stored in a request attribute and accessed simply as: html:form action='%= request.getAttribute(formaction) %' html-el:form might even let you do (never used it): html-el:form action=${formaction} Of course, this assumes you're doing the MVC thing of disallowing direct client access to your JSP pages. It just seems confusing to have an attribute that may or may not be used. I'd rather have the attribute value always static or always dynamic. But that's personal preference, I really just wanted to correct the statement about the request-time value. Whether that's of any use in your case is another issue. Quoting Mark [EMAIL PROTECTED]: All that means is you can have mysimpleTag value=%=scripletVariable%/ false means you cannot have a scriplet variable as a value That's not quite what i wanted to do, but in a way accomplishes a similar task without modifying struts. Its not sexy enough for me ;) The whole point of MVC is seperation presentation, business logic, code html:form action=%=request.getAttribute(formaction)!=null?(String)request.getAttribute(formaction):/Default/url% method=post/ If i start putting scriptlets like that in my code, im basically breaking the MVC design pattern. Because now, my JSP page is dependent upon that scriptlet variable being in the environment, and if it used an object, say like this: html:form action=%=request.getAttribute(myForm)!=null?(MyForm)request.getAttribute(formaction).getFormaction():/Default/url% method=post/ The method I used, I believe, is a tad better because the JSP page will still function in the absence of that scriptlet variable, and is cleaner JSP code. Regards, Mark *** REPLY SEPARATOR *** On 03/14/2003 at 9:27 AM Kris Schneider wrote: The code you've quoted has no impact on whether or not the html:form tag's action attribute is an rtexpr. Look at struts-html.tld: tag nameform/name tagclassorg.apache.struts.taglib.html.FormTag/tagclass bodycontentJSP/bodycontent attribute nameaction/name requiredtrue/required rtexprvaluetrue/rtexprvalue /attribute ... Quoting Mark [EMAIL PROTECTED]: No, its not a runtime expression. If you look at the code in FormTag you'll see that its not results.append(\ action=\); results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); results.append(\); It simply pulls the action mapping from the config. I changed my code to results.append(\ action=\); // check if we have a bean thats exposing a formaction property, if so, use that property, otherwise use our assigned action value in the jsp page try { Object value = RequestUtils.lookup(pageContext, beanName,formaction, null); if (value != null !value.toString().equals()) { this.action=ResponseUtils.filter(value.toString()); System.out.println(value.toString()); } } catch (Exception e) { e.printStackTrace(); } results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, pageContext))); *** REPLY SEPARATOR *** On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote: Mark, Please, correct me if I'm wrong, but I think the action attribute in the html:form tag is a run time expression, so there's no need to extend the FormTag class in order to use a dynamic form action. Regards Jose Mark wrote: I just wanted to pass on a tidbit that might help one or two people out there. I have a search page that displays the results with checkboxes. There are two or three different places that i use this same search page, so rather than writing or copying the search results jsp page to several copies (to allow me to post the form thats on the results page to a different forward definition) i made a modifiecation to struts. In the FormTag.java I added some code to peek in the formbean for a property called formaction. If it finds one, it uses this new action instead of the hard coded one in the jsp page. Thus, in my action class i do this: MyBean myBean=(MyBean)actionForm; myBean.setFormaction(/Some/other/url); return mapping.findforward(default); now i have a jsp page which i can reuse its functionality in several places in my code. I had thought about using a hidden field, but the problem really stems from the statically coded form action=/Url part. Since struts doesnt allow us much flexibility here by default, I decided to add my own and it works great! Regards, Mark
Re: Dynamic form actions
We'll i kind of interested in trying your solution. Can you post some jsp codes in here. I think many people will appreciate it. Thanks. - Original Message - From: Mark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, March 14, 2003 11:52 AM Subject: Dynamic form actions I just wanted to pass on a tidbit that might help one or two people out there. I have a search page that displays the results with checkboxes. There are two or three different places that i use this same search page, so rather than writing or copying the search results jsp page to several copies (to allow me to post the form thats on the results page to a different forward definition) i made a modifiecation to struts. In the FormTag.java I added some code to peek in the formbean for a property called formaction. If it finds one, it uses this new action instead of the hard coded one in the jsp page. Thus, in my action class i do this: MyBean myBean=(MyBean)actionForm; myBean.setFormaction(/Some/other/url); return mapping.findforward(default); now i have a jsp page which i can reuse its functionality in several places in my code. I had thought about using a hidden field, but the problem really stems from the statically coded form action=/Url part. Since struts doesnt allow us much flexibility here by default, I decided to add my own and it works great! Regards, Mark - 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: Dynamic form value replacements???
Can you put them in an array? - Original Message - From: Jason Long [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 9:38 PM Subject: Dynamic form value replacements??? I have a form that is dynamically created as a jsp in xml syntax. There are an arbitrary number of text fields that need to be validated. Could someone point me to an example of how to do this? I have no way of creating the set and get methods in the form class unless I dynamically create the java code and recompile. This is not an option. Thank you for your time, Jason Long - CEO and Chief Software Engineer Supernova Software - supernovasoftware.com BS Physics, MS Chemical Engineering -Original Message- From: louis majanja [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 6:27 PM To: Struts Users Mailing List Subject: [HELP] ActionMessages html:messages / i have this in my actionForm: ActionMessages messages = new ActionMessages(); messages.add(message, new ActionMessage(message.login.confirmation)); saveMessage(request,messages); in my jsp i have html:messages / it doesn't work, i have tried the following options which don't work either html:messages message=true/ html:messages id=msg property=messages message=true c:out value=${msg}/ /html:messages - 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: Dynamic form value replacements???
According to this you can. I have not tried though. Makes the other constuctors obsolete. http://jakarta.apache.org/struts/api/org/apache/struts/action/ActionError.ht ml Do you know to use DynaActionForm? I do not understand how to get the values kept when validation fails. It currently loses all changes because I do not know the name of all the text fields beforehand and cannot create get and set methods. Jason Long - CEO and Chief Software Engineer Supernova Software - supernovasoftware.com BS Physics, MS Chemical Engineering -Original Message- From: Ian Hunter [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 8:43 PM To: Struts Users Mailing List Subject: Re: Dynamic form value replacements??? Can you put them in an array? - Original Message - From: Jason Long [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 9:38 PM Subject: Dynamic form value replacements??? I have a form that is dynamically created as a jsp in xml syntax. There are an arbitrary number of text fields that need to be validated. Could someone point me to an example of how to do this? I have no way of creating the set and get methods in the form class unless I dynamically create the java code and recompile. This is not an option. Thank you for your time, Jason Long - CEO and Chief Software Engineer Supernova Software - supernovasoftware.com BS Physics, MS Chemical Engineering -Original Message- From: louis majanja [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 6:27 PM To: Struts Users Mailing List Subject: [HELP] ActionMessages html:messages / i have this in my actionForm: ActionMessages messages = new ActionMessages(); messages.add(message, new ActionMessage(message.login.confirmation)); saveMessage(request,messages); in my jsp i have html:messages / it doesn't work, i have tried the following options which don't work either html:messages message=true/ html:messages id=msg property=messages message=true c:out value=${msg}/ /html:messages - 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: Dynamic form and Upload
On Sat, 2 Nov 2002, Mr Alireza Fattahi wrote: Date: Sat, 2 Nov 2002 05:21:12 + (GMT) From: Mr Alireza Fattahi [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Dynamic form and Upload Hi, I want to use struts dynamic form feature. There is form which has an upload file filed and some input text. Using form beans (either standard ActionForm subclasses or using DynaActionForm/DynaValidatorActionForm) is not sufficient for supporting file upload functionality. You must explisitly use the file upload support provided by Struts directly (in 1.0) or indirectly via the commons-fileupload module( in 1.1). For an example of the required programming techiques, see the struts-upload example app that is included with the Struts distribution. Craig -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: Dynamic form and Upload
Thanks for your reply, I have seen the example and an work with it, But my problem is I can not do that in an dynamic form. How should I do it in dynamic form, and what should I put in struts.config.xml? As I told I got the class cast expetion. Thanks __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: dynamic form properties
Hi, Mark, How can I keep a form bean in a session scope? In addition how can I access a form bean from a jsp page directly, instead of using the jsp tags? Thanks, Daka - Original Message - From: Galbreath, Mark [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Thursday, June 06, 2002 5:58 AM Subject: RE: dynamic form properties What do you want to know? I use maps and collections in form beans now to capture multi-select list key-value pairs and checkbox array booleans, respectively. I think it would be a simple extrapolation to map key-values for an entire HTML form, permitting a single action form to capture states for every HTML form in the application if the form bean is kept in session scope with an empty reset(). Mark -Original Message- From: Zhihua Xu [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 06, 2002 2:10 AM In Struts 1.1 beta, a Map can be used instead of individual properties on an ActionForm. In the future, I foresee Struts developers using the same base ActionForm in all their projects, without going through the hassle of defining all these String properites. Does anyone have an example of the above usage? Thanks, Daka -- 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: dynamic form properties
1. Declare the bean's scope as session as an attribute of the form-bean declaration in struts-config.xml and provide an empty reset() method in the bean class; 2. Use java scriplets (though I do not recommend this) as in % List myBean = (List) session.getAttribute( myBean); Iterator i = myBean.iterator(); while( i.hasNext()) { out.println( td + i.next().toString() + /td); } % Goot Morgdah, Mark -Original Message- From: Zhihua Xu [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 25, 2002 2:38 PM Hi, Mark, How can I keep a form bean in a session scope? In addition how can I access a form bean from a jsp page directly, instead of using the jsp tags? Thanks, Daka -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: dynamic form properties
Mark, My scenario is a database application where the number of properties and the actual property labels, which will be used in an entry form, can only be determined at run time. How can I get the number of properties and the corresponding property labels to the jsp and the form bean? Thanks, Daka - Original Message - From: Galbreath, Mark [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Thursday, June 06, 2002 5:58 AM Subject: RE: dynamic form properties What do you want to know? I use maps and collections in form beans now to capture multi-select list key-value pairs and checkbox array booleans, respectively. I think it would be a simple extrapolation to map key-values for an entire HTML form, permitting a single action form to capture states for every HTML form in the application if the form bean is kept in session scope with an empty reset(). Mark -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: dynamic form properties
What do you want to know? I use maps and collections in form beans now to capture multi-select list key-value pairs and checkbox array booleans, respectively. I think it would be a simple extrapolation to map key-values for an entire HTML form, permitting a single action form to capture states for every HTML form in the application if the form bean is kept in session scope with an empty reset(). Mark -Original Message- From: Zhihua Xu [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 06, 2002 2:10 AM In Struts 1.1 beta, a Map can be used instead of individual properties on an ActionForm. In the future, I foresee Struts developers using the same base ActionForm in all their projects, without going through the hassle of defining all these String properites. Does anyone have an example of the above usage? Thanks, Daka -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: dynamic form properties
Are you talking about the DynaActionForm? James Mitchell Software Engineer\Struts Evangelist Struts-Atlanta, the Open Minded Developer Network http://struts-atlanta.open-tools.org ICQ: 27651409 AOLIM: jmitchtx (and NO I dont use AOL;) -Original Message- From: Zhihua Xu [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 06, 2002 2:10 AM To: [EMAIL PROTECTED] Subject: dynamic form properties Hi, there, I have learned the following, In Struts 1.1 beta, a Map can be used instead of individual properties on an ActionForm. In the future, I foresee Struts developers using the same base ActionForm in all their projects, without going through the hassle of defining all these String properites. Does anyone have an example of the above usage? Thanks, Daka -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: dynamic form using nested:file?
Your first statement, ...I have a form that can have N number of images... Does not warrant the use of nested tag library. Simply use the standard iterator, and indexed properties of the html:file tag, to properly output your file names as file[1], file[2], file[3]. -AP_ http://www.alexparansky.com Java/J2EE Architect/Consultant http://www.myprofiles.com/member/view.do?profileId=127 -Original Message- From: Elijah Jacobs [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 11, 2002 8:49 AM To: Struts Users Mailing List Subject: dynamic form using nested:file? hi all, I have a form that can have N number of images. So in essence it's like the Monkey struts example by Arron Bates except where he has bananas, i have images. The problems is that I have to associate a FormFile for each image, since each image can be updated (hence an image upload is needed for that particular image).. for example if N=3 then a user can update image 2 to another image. A user can also add an image increasing N to 4 I am using the nested tags for struts 1.0 (nested_tags_10.jar). So I have this set up: start of code = FormBean.java pivate ArrayList slideImageList;(with associating set/get methods) .. contains a list of ImageItem ImageItem.java -- what is contained in the slideImageList private Image image; // and image object containing image_name, url, etc... private FormFile file;// the FormFile I want to associate to the image above. Idealy I would want this on my JSP page: nested:iterate property=slideImageList nested:nest property=image nested:write property=url/ /font /nested:nest nested:file property=file/ /td%!-- this is where i get in trouble --% /nested:iterate === end of code Since the nested tag does not have an associating html:file tag then I'm stuck. Does anyone know a way to get around this? thanks, - ej -- 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: dynamic form using nested:file?
Elijah, Sorry about the lack of the tag. It's on its way. Pick it up in the next nightly build. Arron. Elijah Jacobs wrote: hi all, I have a form that can have N number of images. So in essence it's like the Monkey struts example by Arron Bates except where he has bananas, i have images. The problems is that I have to associate a FormFile for each image, since each image can be updated (hence an image upload is needed for that particular image).. for example if N=3 then a user can update image 2 to another image. A user can also add an image increasing N to 4 I am using the nested tags for struts 1.0 (nested_tags_10.jar). So I have this set up: start of code = FormBean.java pivate ArrayList slideImageList;(with associating set/get methods) .. contains a list of ImageItem ImageItem.java -- what is contained in the slideImageList private Image image; // and image object containing image_name, url, etc... private FormFile file;// the FormFile I want to associate to the image above. Idealy I would want this on my JSP page: nested:iterate property=slideImageList nested:nest property=image nested:write property=url/ /font /nested:nest nested:file property=file/ /td%!-- this is where i get in trouble --% /nested:iterate === end of code Since the nested tag does not have an associating html:file tag then I'm stuck. Does anyone know a way to get around this? thanks, - ej -- 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: 'dynamic' form elements in a ActionForm
It's difficult to do this in the 1.0.x release, but simple as pie in the 1.1 beta and nightly build. http://jguru.com/forums/view.jsp?EID=567079 -- 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 Struts Newsgroup (@Basebeans.com) wrote: Subject: 'dynamic' form elements in a ActionForm From: Greg Tillbrook [EMAIL PROTECTED] === Hi Ive been tryig to use an ActionForm bean for a form which can have a variable number of form elements (as defined by a 'meta' configuration file). Ive hit on the problem though that each parameter in a form bean matched to a form element has to declared when implementing the bean. Is it possible to specify a list (i.e. vector or hashtable) in the form bean that will contain all of these 'dynamic' parameters or is there a better way? I have looked at the documentation/web/this newsgroup but have found nothing that seemed appropriate. Apologies if Ive missed something obvious but Im pretty new to struts atm. cheers Greg -- 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: dynamic form action flow
SavePhoneNumberAction.java -- editPhoneNumbers.do It may be that this is looking up the original phone number again. If so, this is also where the recyling message could be coming into it. Do you want to go back through the edit action, or straight to the display page? -- Ted Husted, Husted dot Com, Fairport NY USA. -- Java Web Development with Struts. -- Tel +1 585 737-3463. -- Web http://www.husted.com/struts/ Jeff Oberlander wrote: Ok, I've wasted an embarrassing amount of time on this and would appreciate any help. Its night now and no progress has been made. This is another action flow question. Maybe there is a sample somewhere that does this? I apologize that this is long. I have an action form that contains an ArrayList of items (lets say phone numbers). The form allows me to edit existing numbers or add new ones. When I go to the editPhoneNumbers.jsp page, it displays all of my phone numbers based on the ArrayList with a button to add another and a button to save the form. I start with a single phone number - e.g. my home number. If you hit add, the form should be re-displayed with 2 phone number fields - my home one, and a new blank one - both editable. This is the action flow I currently have: editPhoneNumbers.do -- EditPhoneNumberAction.java (input is PhoneNumberForm - containing an ArrayList of numbers) - this loads my current phone numbers from the data store into the form. EditPhoneNumberAction -- editPhoneNumber.jsp - this displays the form. editPhoneNumber.jsp -- SavePhoneNumberAction.java (action = add | save) SavePhoneNumberAction.java - if the action is add, I add an empty PhoneNumber object to the ActionForm ArrayList, then I want to redisplay the form with the original item, and the blank new one. SavePhoneNumberAction.java -- editPhoneNumbers.do Loop is complete. I thought this would be as simple as adding a new item to the ArrayList in the form and forwarding on the original form. It doesn't work. I keep getting back (in the display) only my home phone number (the original form without the new object) I suspect it is related to this log message: Recycling existing ActionForm bean instance of class . Another interesting point is even though I explicitly set the action property of the form in SavePhoneNumberAction, it always comes into EditPhoneNumberAction as null. -- 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: dynamic form action flow
Actually, it doesn't. I've been through that example pretty thouroughly. To add a new subscription, it puts up a form with only the fields for the new subscription (a separate page). It doesn't dynamically new form fields to an existing page. -Original Message- From: Jon.Ridgway [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 2:05 AM To: 'Struts Users Mailing List' Subject: RE: dynamic form action flow Hi Jeff, The struts-example.war app does just this, except it uses subscriptions instead of phone numbers. It's part of the struts download, under webapps. Jon. -Original Message- From: Jeff Oberlander [mailto:[EMAIL PROTECTED]] Sent: 01 February 2002 06:08 To: '[EMAIL PROTECTED]' Subject: dynamic form action flow Ok, I've wasted an embarrassing amount of time on this and would appreciate any help. Its night now and no progress has been made. This is another action flow question. Maybe there is a sample somewhere that does this? I apologize that this is long. I have an action form that contains an ArrayList of items (lets say phone numbers). The form allows me to edit existing numbers or add new ones. When I go to the editPhoneNumbers.jsp page, it displays all of my phone numbers based on the ArrayList with a button to add another and a button to save the form. I start with a single phone number - e.g. my home number. If you hit add, the form should be re-displayed with 2 phone number fields - my home one, and a new blank one - both editable. This is the action flow I currently have: editPhoneNumbers.do -- EditPhoneNumberAction.java (input is PhoneNumberForm - containing an ArrayList of numbers) - this loads my current phone numbers from the data store into the form. EditPhoneNumberAction -- editPhoneNumber.jsp - this displays the form. editPhoneNumber.jsp -- SavePhoneNumberAction.java (action = add | save) SavePhoneNumberAction.java - if the action is add, I add an empty PhoneNumber object to the ActionForm ArrayList, then I want to redisplay the form with the original item, and the blank new one. SavePhoneNumberAction.java -- editPhoneNumbers.do Loop is complete. I thought this would be as simple as adding a new item to the ArrayList in the form and forwarding on the original form. It doesn't work. I keep getting back (in the display) only my home phone number (the original form without the new object) I suspect it is related to this log message: Recycling existing ActionForm bean instance of class . Another interesting point is even though I explicitly set the action property of the form in SavePhoneNumberAction, it always comes into EditPhoneNumberAction as null. -- 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: dynamic form action flow
I've tried going straight to the display page and then I get the new, blank element and form, but lose the prior existing form fields (home phone). -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 4:14 AM To: Struts Users Mailing List Subject: Re: dynamic form action flow SavePhoneNumberAction.java -- editPhoneNumbers.do It may be that this is looking up the original phone number again. If so, this is also where the recyling message could be coming into it. Do you want to go back through the edit action, or straight to the display page? -- Ted Husted, Husted dot Com, Fairport NY USA. -- Java Web Development with Struts. -- Tel +1 585 737-3463. -- Web http://www.husted.com/struts/ Jeff Oberlander wrote: Ok, I've wasted an embarrassing amount of time on this and would appreciate any help. Its night now and no progress has been made. This is another action flow question. Maybe there is a sample somewhere that does this? I apologize that this is long. I have an action form that contains an ArrayList of items (lets say phone numbers). The form allows me to edit existing numbers or add new ones. When I go to the editPhoneNumbers.jsp page, it displays all of my phone numbers based on the ArrayList with a button to add another and a button to save the form. I start with a single phone number - e.g. my home number. If you hit add, the form should be re-displayed with 2 phone number fields - my home one, and a new blank one - both editable. This is the action flow I currently have: editPhoneNumbers.do -- EditPhoneNumberAction.java (input is PhoneNumberForm - containing an ArrayList of numbers) - this loads my current phone numbers from the data store into the form. EditPhoneNumberAction -- editPhoneNumber.jsp - this displays the form. editPhoneNumber.jsp -- SavePhoneNumberAction.java (action = add | save) SavePhoneNumberAction.java - if the action is add, I add an empty PhoneNumber object to the ActionForm ArrayList, then I want to redisplay the form with the original item, and the blank new one. SavePhoneNumberAction.java -- editPhoneNumbers.do Loop is complete. I thought this would be as simple as adding a new item to the ArrayList in the form and forwarding on the original form. It doesn't work. I keep getting back (in the display) only my home phone number (the original form without the new object) I suspect it is related to this log message: Recycling existing ActionForm bean instance of class . Another interesting point is even though I explicitly set the action property of the form in SavePhoneNumberAction, it always comes into EditPhoneNumberAction as null. -- 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: dynamic form action flow
I figured this out finally, thanks to the Vectors in Form thread today, which turned out to be similar It was 2 things: 1) The scope in my struts-config was request and should have been session. 2) Upon adding a new blank object to the ArrayList for re-display, instead of forwarding to the editPhoneNumbers.do action, directly re-display the jsp. -Original Message- From: Jeff Oberlander Sent: Friday, February 01, 2002 7:39 AM To: 'Struts Users Mailing List' Subject: RE: dynamic form action flow I've tried going straight to the display page and then I get the new, blank element and form, but lose the prior existing form fields (home phone). -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 4:14 AM To: Struts Users Mailing List Subject: Re: dynamic form action flow SavePhoneNumberAction.java -- editPhoneNumbers.do It may be that this is looking up the original phone number again. If so, this is also where the recyling message could be coming into it. Do you want to go back through the edit action, or straight to the display page? -- Ted Husted, Husted dot Com, Fairport NY USA. -- Java Web Development with Struts. -- Tel +1 585 737-3463. -- Web http://www.husted.com/struts/ Jeff Oberlander wrote: Ok, I've wasted an embarrassing amount of time on this and would appreciate any help. Its night now and no progress has been made. This is another action flow question. Maybe there is a sample somewhere that does this? I apologize that this is long. I have an action form that contains an ArrayList of items (lets say phone numbers). The form allows me to edit existing numbers or add new ones. When I go to the editPhoneNumbers.jsp page, it displays all of my phone numbers based on the ArrayList with a button to add another and a button to save the form. I start with a single phone number - e.g. my home number. If you hit add, the form should be re-displayed with 2 phone number fields - my home one, and a new blank one - both editable. This is the action flow I currently have: editPhoneNumbers.do -- EditPhoneNumberAction.java (input is PhoneNumberForm - containing an ArrayList of numbers) - this loads my current phone numbers from the data store into the form. EditPhoneNumberAction -- editPhoneNumber.jsp - this displays the form. editPhoneNumber.jsp -- SavePhoneNumberAction.java (action = add | save) SavePhoneNumberAction.java - if the action is add, I add an empty PhoneNumber object to the ActionForm ArrayList, then I want to redisplay the form with the original item, and the blank new one. SavePhoneNumberAction.java -- editPhoneNumbers.do Loop is complete. I thought this would be as simple as adding a new item to the ArrayList in the form and forwarding on the original form. It doesn't work. I keep getting back (in the display) only my home phone number (the original form without the new object) I suspect it is related to this log message: Recycling existing ActionForm bean instance of class . Another interesting point is even though I explicitly set the action property of the form in SavePhoneNumberAction, it always comes into EditPhoneNumberAction as null. -- 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: Dynamic Form Beans?
Hi John, Are you able to slove this problem?if so, Can you help me out? Stephen. -Original Message- From: John Townsend [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, August 29, 2001 8:19 PM To: [EMAIL PROTECTED]; 'Luis Olivares' Subject: RE: Dynamic Form Beans? The one idea that I had was to create a new subclass of ActionForm called ActionDataForm. This form would have get and put methods that use keys instead of the usual pattern of numerous getters/setters. For the process of saving form data, we could add a new override to RequestUtils.processPopulate(..) which would take an ActionDataForm instead of an ActionForm as its form instance. Then we would implement this method to use get and put with keys instead of getters/setters. One problem: I don't know how the populate works from the other side (meaning when you want to prepopulate a form based on the contents of a JavaBean in the session, etc.). I imagine that logic is contained in the HTML tag libraries or some other tag library. I guess what I am wondering is that since a number of people have run into this and needed a solution I assumed that there might already be a solution to this problem. If not, maybe we can find a solution and then submit a patch to Struts for 1.1 or something. Anyone else have any thoughts on this? -- John Townsend PS. One thing I just thought of: I wonder if there is a JavaBeans solution to this problem? If there is, that might be a better way to go. -Original Message- From: Luis Olivares [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 29, 2001 11:28 AM To: [EMAIL PROTECTED] Subject: Re: Dynamic Form Beans? I have the same 'problem'. I would like to be able to create a form dynamically depending on the structure of a table (I used to do this with 'plain' JSP). Any ideas? Regards. Luis Olivares. [EMAIL PROTECTED] -- Intelligence is the ability to avoid doing work, yet getting the work done --Linus Torvalds-- - Original Message - From: John Townsend [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 29, 2001 12:54 PM Subject: Dynamic Form Beans? I am working on a project where is would be nice to have the ability to define a dynamic form bean (i.e. a form bean where the fields are defined at runtime). The most obvious (but perhaps not the best) solution to this problem would be if the ActionServlet could handle saving data in a form bean that was a hashtable. Has someone else run into this problem and come up with a solution? Thanks, -- John Townsend
RE: Dynamic Form Beans?
One part of the solution is to use the MappedProperty feature recently added to the jakarta-commons bean-utils. The original submission is in this message: http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03005.html It has been integrated into the commons source, as indicated by this message: http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03596.html Also look at this message for a bug that needs to be fixed (hopefully the patch will be committed soon): http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03897.html Other relevant messages are referenced in this one: http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03429.html Hope this helps, Fr. -Original Message- From: John Townsend [mailto:[EMAIL PROTECTED]] Sent: 29 August 2001 19:54 To: [EMAIL PROTECTED] Subject: Dynamic Form Beans? I am working on a project where is would be nice to have the ability to define a dynamic form bean (i.e. a form bean where the fields are defined at runtime). The most obvious (but perhaps not the best) solution to this problem would be if the ActionServlet could handle saving data in a form bean that was a hashtable. Has someone else run into this problem and come up with a solution? Thanks, -- John Townsend The information in this email is confidential and is intended solely for the addressee(s). Access to this email by anyone else is unauthorised. If you are not an intended recipient, you must not read, use or disseminate the information contained in the email. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Capco. http://www.capco.com ***
Re: Dynamic Form Beans?
I have the same 'problem'. I would like to be able to create a form dynamically depending on the structure of a table (I used to do this with 'plain' JSP). Any ideas? Regards. Luis Olivares. [EMAIL PROTECTED] -- Intelligence is the ability to avoid doing work, yet getting the work done --Linus Torvalds-- - Original Message - From: John Townsend [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 29, 2001 12:54 PM Subject: Dynamic Form Beans? I am working on a project where is would be nice to have the ability to define a dynamic form bean (i.e. a form bean where the fields are defined at runtime). The most obvious (but perhaps not the best) solution to this problem would be if the ActionServlet could handle saving data in a form bean that was a hashtable. Has someone else run into this problem and come up with a solution? Thanks, -- John Townsend
RE: Dynamic Form Beans?
I heard Struts 1.1 will address this issue. In the mean time, I too am interested to a working solution. Thanks, Thinh -Original Message- From: Luis Olivares [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 29, 2001 1:28 PM To: [EMAIL PROTECTED] Subject: Re: Dynamic Form Beans? I have the same 'problem'. I would like to be able to create a form dynamically depending on the structure of a table (I used to do this with 'plain' JSP). Any ideas? Regards. Luis Olivares. [EMAIL PROTECTED] -- Intelligence is the ability to avoid doing work, yet getting the work done --Linus Torvalds-- - Original Message - From: John Townsend [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 29, 2001 12:54 PM Subject: Dynamic Form Beans? I am working on a project where is would be nice to have the ability to define a dynamic form bean (i.e. a form bean where the fields are defined at runtime). The most obvious (but perhaps not the best) solution to this problem would be if the ActionServlet could handle saving data in a form bean that was a hashtable. Has someone else run into this problem and come up with a solution? Thanks, -- John Townsend
RE: Dynamic Form Beans?
The one idea that I had was to create a new subclass of ActionForm called ActionDataForm. This form would have get and put methods that use keys instead of the usual pattern of numerous getters/setters. For the process of saving form data, we could add a new override to RequestUtils.processPopulate(..) which would take an ActionDataForm instead of an ActionForm as its form instance. Then we would implement this method to use get and put with keys instead of getters/setters. One problem: I don't know how the populate works from the other side (meaning when you want to prepopulate a form based on the contents of a JavaBean in the session, etc.). I imagine that logic is contained in the HTML tag libraries or some other tag library. I guess what I am wondering is that since a number of people have run into this and needed a solution I assumed that there might already be a solution to this problem. If not, maybe we can find a solution and then submit a patch to Struts for 1.1 or something. Anyone else have any thoughts on this? -- John Townsend PS. One thing I just thought of: I wonder if there is a JavaBeans solution to this problem? If there is, that might be a better way to go. -Original Message- From: Luis Olivares [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 29, 2001 11:28 AM To: [EMAIL PROTECTED] Subject: Re: Dynamic Form Beans? I have the same 'problem'. I would like to be able to create a form dynamically depending on the structure of a table (I used to do this with 'plain' JSP). Any ideas? Regards. Luis Olivares. [EMAIL PROTECTED] -- Intelligence is the ability to avoid doing work, yet getting the work done --Linus Torvalds-- - Original Message - From: John Townsend [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 29, 2001 12:54 PM Subject: Dynamic Form Beans? I am working on a project where is would be nice to have the ability to define a dynamic form bean (i.e. a form bean where the fields are defined at runtime). The most obvious (but perhaps not the best) solution to this problem would be if the ActionServlet could handle saving data in a form bean that was a hashtable. Has someone else run into this problem and come up with a solution? Thanks, -- John Townsend
Re: Dynamic Form Beans?
I have the same problem too, and I'm sure there are many more like us. I believe this is a problem struts has not addressed yet. Fortunately, they are working on Dynamic form generation feature for struts1.1. I don't know when it is going to be ready!! Here is a work-around: Make your JSPs without using FormBeans (you should have your won Java classes to dynamically generate the form), and extract input parameters from request in your action and stuff them into a Hashtable for further processing. However, someone should clarify if this approach violates struts recommended architecture. I would definitely like to see a better solution. I have posted similar questions earlier on this topic, but I have got no response. Sastry. At 01:27 PM 8/29/2001 -0500, you wrote: I have the same 'problem'. I would like to be able to create a form dynamically depending on the structure of a table (I used to do this with 'plain' JSP). Any ideas? Regards. Luis Olivares. [EMAIL PROTECTED] -- Intelligence is the ability to avoid doing work, yet getting the work done --Linus Torvalds-- - Original Message - From: John Townsend [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 29, 2001 12:54 PM Subject: Dynamic Form Beans? I am working on a project where is would be nice to have the ability to define a dynamic form bean (i.e. a form bean where the fields are defined at runtime). The most obvious (but perhaps not the best) solution to this problem would be if the ActionServlet could handle saving data in a form bean that was a hashtable. Has someone else run into this problem and come up with a solution? Thanks, -- John Townsend Sastry Varanasi Tel : 408-526-6278 INSMBU, Cisco Systems
Re: Dynamic Form Beans?
On the input side, it sounds like what you want is a map that is basically a copy of the map usually used internally by the servlet container to represent parameters. If you don't mind having copies in the map of what's also in any explicit form bean fields, you could just use this at the top of the reset() method in your form bean (or a base class). HashMap map = new HashMap(); // Actually, this would be an instance variable for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String name = (String)e.nextElement(); map.put(name, request.getParameterValues(name)); } The output side is a little different because the Struts tags are set up to look only for explicit fields. There's been at least one proposal for changing that, though. However, this is what I refer to as an uncontrolled dynamic form bean. More interesting would be a controlled dynamic form bean, where the valid fields are actually controlled externally, rather than being at the whim of the request (or other code). But then, that's a bunch more work. :-) -- Martin Cooper - Original Message - From: John Townsend [EMAIL PROTECTED] To: [EMAIL PROTECTED]; 'Luis Olivares' [EMAIL PROTECTED] Sent: Wednesday, August 29, 2001 12:19 PM Subject: RE: Dynamic Form Beans? The one idea that I had was to create a new subclass of ActionForm called ActionDataForm. This form would have get and put methods that use keys instead of the usual pattern of numerous getters/setters. For the process of saving form data, we could add a new override to RequestUtils.processPopulate(..) which would take an ActionDataForm instead of an ActionForm as its form instance. Then we would implement this method to use get and put with keys instead of getters/setters. One problem: I don't know how the populate works from the other side (meaning when you want to prepopulate a form based on the contents of a JavaBean in the session, etc.). I imagine that logic is contained in the HTML tag libraries or some other tag library. I guess what I am wondering is that since a number of people have run into this and needed a solution I assumed that there might already be a solution to this problem. If not, maybe we can find a solution and then submit a patch to Struts for 1.1 or something. Anyone else have any thoughts on this? -- John Townsend PS. One thing I just thought of: I wonder if there is a JavaBeans solution to this problem? If there is, that might be a better way to go. -Original Message- From: Luis Olivares [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 29, 2001 11:28 AM To: [EMAIL PROTECTED] Subject: Re: Dynamic Form Beans? I have the same 'problem'. I would like to be able to create a form dynamically depending on the structure of a table (I used to do this with 'plain' JSP). Any ideas? Regards. Luis Olivares. [EMAIL PROTECTED] -- Intelligence is the ability to avoid doing work, yet getting the work done --Linus Torvalds-- - Original Message - From: John Townsend [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 29, 2001 12:54 PM Subject: Dynamic Form Beans? I am working on a project where is would be nice to have the ability to define a dynamic form bean (i.e. a form bean where the fields are defined at runtime). The most obvious (but perhaps not the best) solution to this problem would be if the ActionServlet could handle saving data in a form bean that was a hashtable. Has someone else run into this problem and come up with a solution? Thanks, -- John Townsend
Re: Dynamic form action?
Peter Alfors wrote: Currently, we do not use the html:form tag. I haven't had a chance to look into them yet. I would think that the action attribute would not be required, but maybe there is a good reason for it to be? Someone with more experience with the html tags will have to help you there. Anyone? The action attribute is used for two things: * Create the destination hyperlink to submit to (which you don't need in this scenario) * To look up the corresponding ActionMapping entry and, from there, determine what form bean to use. This information is used by all the nested field tags. If you don't need either of these features, you probably don't need the html:form tag. Pete Craig
Re: Dynamic form action?
Currently, we do not use the html:form tag. I haven't had a chance to look into them yet. I would think that the action attribute would not be required, but maybe there is a good reason for it to be? Someone with more experience with the html tags will have to help you there. Anyone? Pete Tom Janofsky wrote: Then do I take it that you don't use the html:form tag? Or is there a way to make it happy with no action? I tried setting the action to be non-existent (no action attribute), or null (action = "null"), but both blow up on load because the corresponding mapping isn't found in the action-mappings in struts-config.xml. Or do you just put a dummy entry in there? --tom Peter Alfors wrote: We chose to use one Action class per user action as well. To do this, we use javascript to switch the form action. Our buttons call a generic javascript function (that we have as a javascript import file) that simply sets the form action. The method requires the form, and action to call as parameters. This allows up to use one JSP page for viewing, editing, and adding it we would like. JavaScript: function performAction(theForm, theAction) { theForm.action = theAction; theForm.submit(theForm); } Page button: onClick="performAction(document.myForm, 'MyAction.do') As a default, we do not set an action in the form tag on any of our pages. Each button is responsible for setting the action that it would like to initiate. HTH, Pete Tom Janofsky wrote: Hi: I'm relatively new to Struts and I'm trying to figure out if there's an easy way to do the following. I'm trying to solve a classic Add/Edit/Delete problem, and I want to know if there is a way to dynamically change the action that the form is posting to, based on an attribute of the bean. I want to do this because I want to be able to have the following architecture: [1 JSP view] |-addAction - (forwards to view) |-editAction - (forwards to view) |-deleteAction - (forwards to view) All of which use the same form bean, and all forward back to the same view, which has a different button and differnt target (action) if adding or editing. I've written one jsp that does the add, a form bean that has all the fields, and 3 actions that add, edit and delete. Add is easy, it's the action of the form, delete is easy, it keys off links in the jsp, but I'd like to use the same jsp for the edit screen, but change the url the form is posting to (to the edit action) and also change the buttons. In servlet world, this was: if (action.equlas("add")){ out.println("form action="addURL""); else {//edit out.println("form action="editURL"); } and similarly for the buttons. I've been through the example app looking for this might have worked, but it doesn't really seem to work that way (i.e., EditSubscription looks at the hidden field does create or edit, and Save does save, or delete, also based on the action field.) I'd rather not embed checking the action in the the "Action" class (this being the bane of heavy controller servlets past, but I want to go with one "Action" per user action. One alternative (based off an example dug out of the archives) seems to be another "Controller" action, which looks at the action field in the bean, and picks, and destination based off that, but I don't like that, because that seems like the very type of problem Struts is trying to solve. Or would a Struts guru care to make a case for what I want to do not being a best practice? --tom janofsky begin:vcard n:; x-mozilla-html:FALSE org:BRIMG SRC="http://www.irista.com/logo/irista.gif"BRBRFONT Color=#80FONT SIZE=2BBringing Vision to Your Supply Chain adr:;; version:2.1 end:vcard
Re: Dynamic form action?
In order to use forwards (that depend on the user action), wouldn't you need some sort of router action class. Would all the pages then call this class and set some flag to notify it which action to take? Ted Husted wrote: On 1/29/2001 at 3:12 PM Tom Janofsky wrote: Or would a Struts guru care to make a case for what I want to do not being a best practice? I tucked this away for a FAQ . In addition to the controller and JavaScript approaches, Craig has also suggested using an ActionForward: forward name="action1" path="/action1.do"/ details below. *** REPLY SEPARATOR *** On 1/12/2001 at 5:32 PM De Smet Koen wrote: Dear all, I've been investigation a little about how to call different actions from 1 form with multiple buttons. Here's a possible solution, what do you think about it and/or do you see any possible problems? The way I did it was to add a Dispatcher class, which is called from the form, and which will call the correct action depending on which button has been pressed. form:form action="dispatcher.do" name="customForm" type="custom.CustomForm" form:submit value="Button 1" property="SUBMIT_ButOneAction.do" / form:submit value="Button 2" property="SUBMIT_ButTwoAction.do" / We give each button a name, starting with SUBMIT_xxx. This xxx will be the name of the mapping we will have to use for the action to be called. ***Little remark: Make always sure that when having more then 1 form with multiple buttons, to give the action and actionForm in the form:form tag a different name, and in struts-config make sure that there are 2 different mappings, with 2 different names and 2 different actionForms, but both going to the same Digester class which always controls the forwards to Action Classes. In this dispatcher class you can retrieve the button pressed, by going through the request parameters, and then extracting the name of the mapping from the parameter. (SUBMIT_ButOneAction.do becomes ButOneAction) The next step is to find the Action instance that has been created by the ActionServlet for a mapping. The problem here is that the "actions" HashMap, stored in the ActionServlet, has been defined as protected, so the way to solve this is to create an own ActionServlet, with a getAction() function which will return the correct action. Now, you can call the perform() method on this action, which will return an ActionForward. (You can also go via struts-config and find the correct mapping, like you normally would do with only one button, but my way of working, calling the perform() method directly, is -I believe- faster, so better performance). Your comments please! Who sees any problems? Thanks, Koen P.S.: When I asked some weeks ago how to solve the problem of multiple buttons in 1 form, people suggested to use JavaScript. We tried that and it works, but the bad thing is you still rely on the JavaScript interpretation on the clientside and in the way I suggested above, it's more JSP / Struts related. *** REPLY SEPARATOR *** Crag McClanahan writes: The proposed approach is one way to deal with the "different actions for one form" issue, and I cannot see any particular problems with it. To deal with getting the correct action, how about setting up ActionForward entries that correspond to other actions instead of JSP pages? forward name="action1" path="/action1.do"/ This would "loop back" to the controller servlet and execute the alternative action for you. An alternative strategy would be to use client-side JavaScript to change the submit destination (on the underlying HTML form) at run time. If you go this way, you will want to make sure that all the actions you might send the form to take the same ActionForm bean (or at least beans with the same set of properties). *** REPLY SEPARATOR *** On 1/29/2001 at 3:12 PM Tom Janofsky wrote: Hi: I'm relatively new to Struts and I'm trying to figure out if there's an easy way to do the following. I'm trying to solve a classic Add/Edit/Delete problem, and I want to know if there is a way to dynamically change the action that the form is posting to, based on an attribute of the bean. I want to do this because I want to be able to have the following architecture: [1 JSP view] |-addAction - (forwards to view) |-editAction - (forwards to view) |-deleteAction - (forwards to view) All of which use the same form bean, and all forward back to the same view, which has a different button and differnt target (action) if adding or editing. I've written one jsp that does the add, a form bean that has all the fields, and 3 actions that add, edit and delete. Add is easy, it's the action of the form, delete is easy, it keys off links in the jsp, but I'd like to use the same jsp for the edit screen, but change the url the form is posting to (to the edit
Re: Dynamic form
Wong Kok Wai wrote: What's the recommended way to implement a dynamic form using Struts? Typical scenario: an address book for email where the number of contacts varies. No problem with renderering the form in the JSP but how do I associate the "input" with an attribute in an instance of the ActionForm? Struts 1.0 does not really address the issue of dynamic forms -- it is more focused on "static forms where the names of the request parameters, and thus the names of the corresponding properties on your ActionForm bean, are known. Elegant support for dynamic forms will be a focus area for Struts 1.1. TIA! Craig McClanahan