You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "A. Lotfi" <ma...@yahoo.com> on 2007/09/25 03:09:50 UTC
dynamicaly radio buttons from database, please help me
Hi,
I am using struts1.3.8
I just want when the user click in a link (SurveyAction.do) , he will be presented with a form :
ID ---- Title ------ O smal O medium O hight
........
ID ---- Title ------ O smal O medium O hight
SaveSubmitButton
The three radio buttons are all not selected, the user just has to select one of each line then click the Save SubmitButton.
Please help me,
1) How to create the data radio butons in the database tabel ?
Thank you, your help is very aapreciated, I spent lot of time looking for an example like this but did not find anything.
---------------------------------
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us.
Re: dynamicaly radio buttons from database, please help me
Posted by Rick Reumann <ri...@gmail.com>.
On 9/24/07, A. Lotfi <ma...@yahoo.com> wrote:
> Hi,
> I am using struts1.3.8
>
> I just want when the user click in a link (SurveyAction.do) , he will be presented with a form :
>
> ID ---- Title ------ O smal O medium O hight
> ........
> ID ---- Title ------ O smal O medium O hight
>
> SaveSubmitButton
>
>
> The three radio buttons are all not selected, the user just has to select one of each line then click the Save SubmitButton.
>
>
> Please help me,
> 1) How to create the data radio butons in the database tabel ?
Remember the struts property is what you are gathering from the form.
So for example, say your ActionForm for a Person wants to collect the
user's favoriteColor using some radio buttons...
<html:radio property="favoriteColor" value="1"/>Green
<html:radio property="favoriteColor" value="2"/>Blue
<html:radio property="favoriteColor" value="3"/>Orange
If you want that to be dynamic, just query your table for Favorite
colors from the db, populate it in List and stick in request scope
before you go to the form and then just iterate over the colors (it's
exactly like the example I told you to look at in an earlier post with
the Employee CRUD example - see how Departments is populated.)
Then you can just iterate over your colors list and display them...
<c:forEach var="color" items="colors">
<html:radio property="favoriteColor" value="${color.id}"/> ${color.name}
</c:forEach>
(if you don't want to populate the list before hand in a prePopulate
type of Action method...
//top of page:
<jsp:useBean id="colorsService" scope="page"
class="net.whatever.package.service.ColorsService"/>
//in form on page
<c:forEach var="color" items="${colorsService.colors}">
<html:radio property="favoriteColor" value="${color.id}"/> ${color.name}
</c:forEach>
--
Rick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [OT] Re: dynamicaly radio buttons from database, please help me
Posted by Dave Newton <ne...@yahoo.com>.
--- "A. Lotfi" <ma...@yahoo.com> wrote:
> what I am asking is :
> ID is a number.
> Title is a string.
>
> How about the group radio buttons ?
Whatever you want them to be, and it can depend on
what DB you're using.
d.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [OT] Re: dynamicaly radio buttons from database, please help me
Posted by "A. Lotfi" <ma...@yahoo.com>.
what I am asking is :
ID is a number.
Title is a string.
How about the group radio buttons ?
Dave Newton <ne...@yahoo.com> wrote:
--- "A. Lotfi" wrote:
> 1) How to create the data radio buttons in the
> database table?
Are you asking what SQL to use to create the column
that represents the radio button choice?
d.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------
Check out the hottest 2008 models today at Yahoo! Autos.
[OT] Re: dynamicaly radio buttons from database, please help me
Posted by Dave Newton <ne...@yahoo.com>.
--- "A. Lotfi" <ma...@yahoo.com> wrote:
> 1) How to create the data radio buttons in the
> database table?
Are you asking what SQL to use to create the column
that represents the radio button choice?
d.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org