I am new to struts, and working on a form where a user would use checkboxes to select specific records from a list .The list object is of type 'purchaseOrder' and it can contain 1 or more products. My question is how would the struts action class know which of the product has been clicked.
Change your selectedCheckbox property to selectedProductIds and make it of type String. Then change:
When the form is submitted, the selectedProductIds property will contain an array of the product IDs selected. I'm assuming that the product ID uniquely identifies the line item. [ August 28, 2007: Message edited by: Merrill Higginson ]
I was working on a solution of adding the attribute 'isSelectedCheckBox' to the PurchaseOrderProduct object itself(not the form bean). It works but once the checkbox is checked and submit clicked and if the user is directed to the same originating screen(this wont happen in the end product) the checkbox retains it initial value(i.e. once true, itll stay true forever). dont know how to get round this.
posted 12 years ago
another problem. The text boxes i am using displays values taken from the database/object's values when the form is loaded. If a user change those values , the action class still takes the database values. How can it take the changed values? what changes do i have to make to the form bean .
Thanks in advance.
posted 12 years ago
If you are going to modify the values in the bean and not just display them, you will need to use indexed properties. For more information on how to do this along with a working example, see question 6 of the JavaRanch Struts FAQ.
Thanks for the advice, and pointing me in the right direction. I am now getting the right values. I have one last question , more conceptual one than any coding. I have to give the user option of adding a product to the purchaseOrder from the JSP page. Does this mean i would need an another formbean and a action class for this. How can i add a new PO line to the Purchase Order whilst retaining any changes done on the JSP page.Can you point me in the right direction.