Solved

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

Posted on 2009-05-18
7
938 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert ArrayList of custom objects to JSON 4 62
Spring Controller - inheritance in request parameter 3 60
stringclean challenge 26 74
eclipse formatting 6 92
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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.

832 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