• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Many to one Mapping in a ActionForm

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a jsp where in i am getting percentage of mark details in first year, second year, thrid year etc., of graduation. Each one is displayed in a single row. Example

Year Percentage
2008 80%
2009 100%

The above Year and percentage is mapped to a column called year and percentage in database. year and percentage are text box in the jsp

Year is dynamic. Meaning, while rendering the year only i will know how many years we have. My ActionForm has a two properties as below

class PercentageForm extends ActionForm
{
String year;
String percentage;

}

So my question is, how can we map the multiple year, percentage to a single ActionForm in struts?

Regards,
APK
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep,

Please check your private messages for a message regarding an important administrative matter.

Regarding your question:

Make the class with year and percentage properties a regular JavaBean rather than an ActionForm and call it something like StudentMarksBean. Then in your ActionForm, create a property of type java.util.List which contains a list of StudentMarksBeans. You can then use the logic:iterate and bean:write tags in your JSP to iterate over this list of beans and display their contents.
[ July 17, 2008: Message edited by: Merrill Higginson ]
 
Ranch Hand
Posts: 450
1
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Make the element a String[] and to display on the page you can use a Struts custom tag (loop) or make the Year a drop down?

Cheers,
Raj.
 
Pradeep Arun
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply.
My question is not about rendering the form data, but when i submit the jsp, how can i map the unknown number of text fields to the Action Form property.

Many Thanks,
Pradeep
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to do this, you will need to use "indexed properties". See question 15 of our FAQ for details on how to do this, along with a working example.
 
Pradeep Arun
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Thats works for me.

Thanks a lot.
 
You may have just won ten million dollars! Or, maybe a tiny ad.
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!