Re: [Rife-users] array/multiple beans from form submission
Emmanuel Okyere wrote: [snipped] You are pretty much on the money with what the discussion is about; it's not possible to 'generate' a form in the manner you mention here, but you can sort of 'simulate' that; what I am doing on the petstore app for instance, requires that every cart item be shown as part of the cart form... this in itself is something rife easily allows you to do by having a a value placeholder and blocks that you can iteratively process and append per bean instance... the added complexity comes in because as per the cart reqts, I have to have a quantity textfield that allows the user to update qty per item. rife currently supports a getSubmissionBean(BeanType.class) method which allows you to easily get an instace of the bean returned from teh form, and do validation against that... it would be nice (and I might have to look into this) to be able to make a similar call, only this time to retrieve a list/array of the beantype you require. Currently, I am sending back parameters in my submission; like: submission name=process param name=id / param name=iid / param name=quantity / /submission and using getParameterIntValues(paramString) call in my Element implementation to iterate over these values and recreate the beans just as I would have expected a call to a proposed getSubmissionBeans to have worked. We might hv to think this through and see if it's possible/feasible to implement something of the sort as a feature of the framework. Cheers, Emmanuel Emmanuel, I join this discussion a little bit late, I guess, but I thought what I had to share might be useful to you. Why don't you create a CartBean class that has array properties? For example: class CartBean { private String[] ids; // assuming your ids are of type String private String[] iids; private long[] quantities; ... and so on } Then, in your template, whether you use JavaScript or not, use the same names as the properties in your bean for your input controls. getSubmissionBean(Class) is clever enough to fill in array values into the properties of the submitted bean, which you can then process. In short, you shouldn't have to use a bean per item; you need only use one bean for the cart. Regards, Eddy -- http://coding.mu http://priscimon.com/blog ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] array/multiple beans from form submission
Hi Geert, Actually, what you can do if you really want to isolate and componentize the handling of these beans, you can use embedded elements and provide it with a data object during processEmbeddedElement (which will be each bean). This is only supported in 1.5 though. Indeed, I am using embedded elements for this, and on 1.5 too; I had, however, been using the method of forcing the embedding element to implement an XXXBeanProvider interface to store an instance of the item to be processed by the embedded element, but this new method is more elegant; I saw a mention of it in the changelist for 1.5, but it did not make sense until now... sweet! What this means then is I have to iterate over the quantities sent, and push them into the bean instances, and then just pass these on to the embedded elements and do validation on those. Would have been nicer if we could do a getSubmissionBeans(BeanType.class) call in this regard, but this shd work for me now. Thanks, Emmanuel -- Benjamin Disraeli - Nurture your minds with great thoughts. To believe in the heroic makes heroes. ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] array/multiple beans from form submission
Geert, the embedded elements and do validation on those. Would have been nicer if we could do a getSubmissionBeans(BeanType.class) call in this regard I don't really follow, how would that work? there's already a getSubmissionBean(BeanType.class) implementation... which prepulates a bean with param values... I was just thinking aloud on if we could have a getSubmissionBeans(BeanType.class) imp where a ListBeanType is returned instead, as happens to be what, in a sense, I am trying to achieve here. Cheers, Emmanuel -- Benjamin Disraeli - Nurture your minds with great thoughts. To believe in the heroic makes heroes. ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] array/multiple beans from form submission
Hmm that shouldn't be too hard to add. Maybe you could take a crack at it ;-) On 29 May 2006, at 11:48, Emmanuel Okyere wrote: Geert, the embedded elements and do validation on those. Would have been nicer if we could do a getSubmissionBeans(BeanType.class) call in this regard I don't really follow, how would that work? there's already a getSubmissionBean(BeanType.class) implementation... which prepulates a bean with param values... I was just thinking aloud on if we could have a getSubmissionBeans(BeanType.class) imp where a ListBeanType is returned instead, as happens to be what, in a sense, I am trying to achieve here. Cheers, Emmanuel -- Benjamin Disraeli - Nurture your minds with great thoughts. To believe in the heroic makes heroes. ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users -- Geert Bevin Uwyn Use what you need - http://uwyn.com RIFE Java application framework - http://rifers.org Music and words - http://gbevin.com ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] array/multiple beans from form submission
Quoting Geert Bevin: there's already a getSubmissionBean(BeanType.class) implementation... which prepulates a bean with param values... I was just thinking aloud on if we could have a getSubmissionBeans(BeanType.class) imp where a ListBeanType is returned instead, as happens to be what, in a sense, I am trying to achieve here. Hmm that shouldn't be too hard to add. Maybe you could take a crack at it ;-) Then there really _would_ be bidirectional templates ! And there's plenty of Javascript out there for clicking to add a new row to a table. Then table/list editing could be done 100% locally before POST'ing it. my 0,02e fred ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] array/multiple beans from form submission
Quoting Geert Bevin: Hmm that shouldn't be too hard to add. Maybe you could take a crack at it ;-) Then there really _would_ be bidirectional templates ! And there's plenty of Javascript out there for clicking to add a new row to a table. Then table/list editing could be done 100% locally before POST'ing it. Not really sure I'm following you :-/ It's always possible that I'm full of balonie :) How does Javascript fit in this picture, or how does this interact with bidirectionality? Rife Forms are truly bidirectional, and can use HTML field validation too. Rife also makes it easy to append to Value tags, in order to generate HTML tables with N rows. But is it possible to generate a Form with N rows, by appending additional rows, where each row is another instance of the same bean type ? That would make it possible to have N-record Forms that are bidirectional and that use HTML field validation. Then the next logical step is to attach some JS that adds an (N+1)th record at the end of the Form. Is this making any sense ? Isn't this more or less what is under discussion, or did I manage to miss the point entirely ? BR fred -- F.Baube* Georgetown/MSFS/1988 * Think pangalactically. fbaube#saunalahti.fi * Act locally. gsm +358 41 536 8192 * wmd 60°11'10.8N 24°57'36.9E ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] array/multiple beans from form submission
Fred, Hmm that shouldn't be too hard to add. Maybe you could take a crack at it ;-) Then there really _would_ be bidirectional templates ! And there's plenty of Javascript out there for clicking to add a new row to a table. Then table/list editing could be done 100% locally before POST'ing it. Not really sure I'm following you :-/ It's always possible that I'm full of balonie :) How does Javascript fit in this picture, or how does this interact with bidirectionality? Rife Forms are truly bidirectional, and can use HTML field validation too. Rife also makes it easy to append to Value tags, in order to generate HTML tables with N rows. But is it possible to generate a Form with N rows, by appending additional rows, where each row is another instance of the same bean type ? That would make it possible to have N-record Forms that are bidirectional and that use HTML field validation. Then the next logical step is to attach some JS that adds an (N+1)th record at the end of the Form. Is this making any sense ? Isn't this more or less what is under discussion, or did I manage to miss the point entirely ? You are pretty much on the money with what the discussion is about; it's not possible to 'generate' a form in the manner you mention here, but you can sort of 'simulate' that; what I am doing on the petstore app for instance, requires that every cart item be shown as part of the cart form... this in itself is something rife easily allows you to do by having a a value placeholder and blocks that you can iteratively process and append per bean instance... the added complexity comes in because as per the cart reqts, I have to have a quantity textfield that allows the user to update qty per item. rife currently supports a getSubmissionBean(BeanType.class) method which allows you to easily get an instace of the bean returned from teh form, and do validation against that... it would be nice (and I might have to look into this) to be able to make a similar call, only this time to retrieve a list/array of the beantype you require. Currently, I am sending back parameters in my submission; like: submission name=process param name=id / param name=iid / param name=quantity / /submission and using getParameterIntValues(paramString) call in my Element implementation to iterate over these values and recreate the beans just as I would have expected a call to a proposed getSubmissionBeans to have worked. We might hv to think this through and see if it's possible/feasible to implement something of the sort as a feature of the framework. Cheers, Emmanuel -- Benjamin Disraeli - Nurture your minds with great thoughts. To believe in the heroic makes heroes. ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] array/multiple beans from form submission
Hi Emmanuel, 1// how do i locate which bean a particular quantity maps to when the form is submitted; 1.1// changing the form method to a GET, with 2 items in the cart (one with qty 1, the other with 4), i get a submission uri that looks like: http://localhost:8080/$%7Bv%20SUBMISSION:FORM:submit/%7D? quantity=1quantity=4update.x=34update.y=17 These should normally respect the order of the beans that you used to create the cart items. Can you use that? Another alternative is to add a hidden form tag with the id of the bean. 2// is there a way to use the id of the input with form submissions 2.1//rife doesn't seem to allow nested value tags.. ideally, i wanted to use the id of the cartitem as it's id. so, it would have been nice to be ablel to do: ${v FORM:INPUT:quantity}id=${v id/} style=text-align: right; maxlength=3 size=3${/v}, but rife barfs at this. ${v FORM:INPUT:quantity}id=${v id/} style=text-align: right; maxlength=3 size=3${/v} can be written as ${v FORM:INPUT:quantity/} ${bv FORM:INPUT:quantity}id=${v id/} style=text-align: right; maxlength=3 size=3${/bv} that should give you what you're looking for Added support for nested value tags is planned but I sadly haven't got enough time to get everything done. RIFE could really benefit from some new framework developers ;-) Hope this helps, Geert -- Geert Bevin Uwyn Use what you need - http://uwyn.com RIFE Java application framework - http://rifers.org Music and words - http://gbevin.com ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] array/multiple beans from form submission
Geert, As always, thx for the quick response; 1// how do i locate which bean a particular quantity maps to when the form is submitted; 1.1// changing the form method to a GET, with 2 items in the cart (one with qty 1, the other with 4), i get a submission uri that looks like: http://localhost:8080/$%7Bv%20SUBMISSION:FORM:submit/%7D? quantity=1quantity=4update.x=34update.y=17 These should normally respect the order of the beans that you used to create the cart items. Can you use that? Another alternative is to add a hidden form tag with the id of the bean. Yes, I figured that the order is maintained and yes that works; i guess what I am kinda wondering is how I to get validation/error marking working with my current template. 2// is there a way to use the id of the input with form submissions 2.1//rife doesn't seem to allow nested value tags.. ideally, i wanted to use the id of the cartitem as it's id. so, it would have been nice to be ablel to do: ${v FORM:INPUT:quantity}id=${v id/} style=text-align: right; maxlength=3 size=3${/v}, but rife barfs at this. ${v FORM:INPUT:quantity}id=${v id/} style=text-align: right; maxlength=3 size=3${/v} can be written as ${v FORM:INPUT:quantity/} ${bv FORM:INPUT:quantity}id=${v id/} style=text-align: right; maxlength=3 size=3${/bv} that should give you what you're looking for yup; perfect! thx Added support for nested value tags is planned but I sadly haven't got enough time to get everything done. RIFE could really benefit from some new framework developers ;-) true.. it's been crazy busy around here (which is why even petstore is still not up); but plans to add/improve bits of the framework have alywas been right up there :) thx, Emmanuel -- Benjamin Disraeli - Nurture your minds with great thoughts. To believe in the heroic makes heroes. ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users