Solved

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

Posted on 2009-05-18
7
934 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
factory design pattern vs abstract factoy design pattern 2 100
sumHeights2  challenge 7 88
json format text only 4 76
wordcount challenge 11 109
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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.

895 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

12 Experts available now in Live!

Get 1:1 Help Now