Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to generate a "real dynamic" form bean?

 
Yongping Wang
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I run into a problem when I attempt to write a form bean. Here is the situation. An html page contains a form which holds 10-22 fields. The number of fields are determined by data (pair value) stored in database. These data are updated weekly by admin users.
Now my question is: is there a way to dynamically generate a form bean on the fly?
Thanks in advance.

Y.P.
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These two links should give you enough information to accomplish what you are trying to do:

http://radio.javaranch.com/channel/jason/2004/03/23/1080083794000.html

http://www.javaranch.com/newsletter/200404/Journal200404.jsp#a10
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ January 24, 2005: Message edited by: Marc Peabody ]
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beaten to the post yet again.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, now that I've read Jason's blog entry I think I may have a simpler solution.

You can use map-backed forms easily to accomplish a dynamic number of textfields on your page. Each field just needs its own code or index.

Let's say you name your map-backed method getValue/setValue.
Simply iterate over your beans and do:
<html:text
property='<%= "value(" + bean.getCodeOrIndex() + ")" %>'/>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic