aspose file tools*
The moose likes Struts and the fly likes How to generate a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to generate a "real dynamic" form bean?" Watch "How to generate a "real dynamic" form bean?" New topic
Author

How to generate a "real dynamic" form bean?

Yongping Wang
Ranch Hand

Joined: May 15, 2001
Posts: 40
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

Joined: Nov 09, 2000
Posts: 6450
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

Joined: Feb 05, 2003
Posts: 4727


[ January 24, 2005: Message edited by: Marc Peabody ]

A good workman is known by his tools.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Beaten to the post yet again.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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() + ")" %>'/>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to generate a "real dynamic" form bean?
 
Similar Threads
deploy the bean
XML to HTML
Passing data to two servlets?
Bean versus Form
Can I use Entity class as my managed bean?