Link to home
Start Free TrialLog in
Avatar of massmen
massmen

asked on

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.

Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

<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.
Avatar of eb692550
eb692550

This mean Struts Tags.
MVC 2
so you have to learn how to use
the struts tag libraries
Avatar of massmen

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Gibu George
Gibu George
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<html:select property="privilege" styleId="privilege">
                <html:options name="allGroupPrivs" />
        </html:select>


or you can make
many single <html:option name="optName" />
Avatar of massmen

ASKER

Thanks george.