• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 964
  • Last Modified:

how to get the bean values in struts2 please help me urget

Hi Experts,

my requirement is i'm setting some values into bean that bean object i'm adding into list
this bean value i want to display into jsp
like <select>
<option value=here bean id>>here bean name</option>
</select>
in for there i want to send to db bean id only not for bean name

i'm adding my action class like this

 list=new ArrayList();
        for(int i=1;i<5;i++){
            bean=new Bean();
            bean.setId(i);
            bean.setName("balu"+i);
            list.add(bean);
           
        }

i want to display dropdown in jsp
value should be "ID" display name "Name"
could you send me some code thanks.

0
massmen
Asked:
massmen
  • 2
  • 2
  • 2
  • +1
1 Solution
 
KuldeepchaturvediCommented:
<html:select property="selectedItem">      <html:options collection="yourlist" property="id" labelProperty="name" /></html:select>

should show your list in HTML.

you will have to put your list in your request by using

request.setAttribute(list,"yourlist");

before you can use it on your jsp.
0
 
eb692550Commented:
This mean Struts Tags.
MVC 2
so you have to learn how to use
the struts tag libraries
0
 
massmenAuthor Commented:
thanks u r replay
but i need struts2 why because struts2 lack of doc. so please if u have any sample could you send me thanks.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Gibu GeorgeChief Technology OfficerCommented:
You can get the struts 2 example here
http://www.roseindia.net/struts/struts2/index.shtml
0
 
Gibu GeorgeChief Technology OfficerCommented:
0
 
eb692550Commented:
<html:select property="privilege" styleId="privilege">
                <html:options name="allGroupPrivs" />
        </html:select>


or you can make
many single <html:option name="optName" />
0
 
massmenAuthor Commented:
Thanks george.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now