Solved

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

Posted on 2008-10-21
1
282 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 500 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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

691 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