My application has a class called BankAccount and it has four fields called bankId, bankName, accountHolder, country.
And I am retriving the list of bank data through <logic: iterate> and I want to display a radio button along with every row I retrived. I am able to do that by using <html:radio>,but i want to know how to get values of four fields mentioned above if user selects a radio button from the list.
(And how to display user selected values in other pages) pls give me a simple example/code.
My suggestion would be to tie the radio button to the Bank ID. Assuming that this is a field that uniquely identifies each bank, once the form is submitted, you can use the Bank ID to get the rest of the information about the bank from the database and then present a page that updates this information. Example:
Assume you have List named "banks" in request scope that has a list of JavaBeans that represent a bank. You also have an ActionForm bean with a selectedBank property.
Once the form is submitted, the selectedBank property will have the BankId of the bank selected by the user. You can then get the rest from the database.
I am not using oracle as back end, so i can not call based on the bank key selected. please tell me if there is any other way to solve this problem?
Joined: Feb 15, 2005
The solution I showed above is not dependent on having an Oracle back end. It will work with any database.
If there is no database at all in the application (how can you have a real application without a database? Is this just a "toy" application?), then you must be keeping this information in memory somewhere. In That case I'd suggest creating a Hashmap with the Bank ID as key and a Bank object with all the other information as the value. Store the Hashmap in Application scope, and then just look up the bank by its Id when a user selects a Bank ID from the page with the radio buttons.