Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java SE 8u111  Lot of stuff broke 11 69
more than one jdk and one jre 1 41
varialbe initialization 11 32
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 32
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

774 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