?
Solved

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

Posted on 2009-05-18
7
Medium Priority
?
961 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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
LVL 12

Accepted Solution

by:
Gibu George earned 1500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.

589 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