Solved

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

Posted on 2009-05-18
7
933 Views
Last Modified: 2013-11-24
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
Comment
Question by:massmen
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 24419060
<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
 

Expert Comment

by:eb692550
ID: 24419475
This mean Struts Tags.
MVC 2
so you have to learn how to use
the struts tag libraries
0
 
LVL 1

Author Comment

by:massmen
ID: 24421177
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 12

Accepted Solution

by:
Gibu George earned 500 total points
ID: 24421300
You can get the struts 2 example here
http://www.roseindia.net/struts/struts2/index.shtml
0
 
LVL 12

Expert Comment

by:Gibu George
ID: 24421320
0
 

Expert Comment

by:eb692550
ID: 24421573
<html:select property="privilege" styleId="privilege">
                <html:options name="allGroupPrivs" />
        </html:select>


or you can make
many single <html:option name="optName" />
0
 
LVL 1

Author Closing Comment

by:massmen
ID: 31582829
Thanks george.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now