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.
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.
This mean Struts Tags.
MVC 2
so you have to learn how to use
the struts tag libraries
MVC 2
so you have to learn how to use
the struts tag libraries
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is an example on how to use dropdowns
http://javachamp.blogspot.com/2008/06/struts-2-ajax-drop-down-example.html
http://javachamp.blogspot.com/2008/06/struts-2-ajax-drop-down-example.html
<html:select property="privilege" styleId="privilege">
<html:options name="allGroupPrivs" />
</html:select>
or you can make
many single <html:option name="optName" />
<html:options name="allGroupPrivs" />
</html:select>
or you can make
many single <html:option name="optName" />
ASKER
Thanks george.
should show your list in HTML.
you will have to put your list in your request by using
request.setAttribute(list,
before you can use it on your jsp.