?
Solved

How can I populate a bean from the parameters of an HttpServletRequest?

Posted on 2008-10-21
1
Medium Priority
?
292 Views
Last Modified: 2012-05-05
I am using extjs to submit form information to a servlet. The parameters are named whatever I want, so let's say "id"="123" and "names[0]"="abc".

I want to populate a bean using that info. Let's say the bean is something like:
  class SomeBean {
    int id;
    List<String> names;
  }
I want to populate that bean by doing something like
  SomeBean bean = PopulateBean(request,new SomeBean());
so that bean.id=123 and bean.names is a list containing one entry which is "abc".

I know that I could manually do it, but I would hope that there was a general interface for this given that all the different frameworks like JSF and stripes and struts all do this sort of thing (although the old struts didn't do it very well for lists of lists of lists.).


0
Comment
Question by:HappyEngineer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
marklorenz earned 2000 total points
ID: 22766311
Is this what you're looking for?

In order to populate the bean, first create the bean, then call the populate method.
http://www.cs.fiu.edu/~downeyt/cgs4825/beans.html

HTH, Mark
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question