• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP Radio button value retrieval

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have thee columns in table, Id, Date and Description.

From the main page I am setting all values and forwarding the struts action to maint page

request.setAttribute("specialResult", allItems);
return mapping.findForward("maint"); //points to Maint.jsp in struts-config.xml

**********My Maint.jsp page *********
.....

<table border="2" cellspacing="0" cellpadding="5">
<logic:notEmpty name="specialResult" scope="request">
<logic:iterate name="specialResult" id="specialResult"
indexId="index">
<tr align="center">
<td width="15%"><INPUT type="radio" value="upId"
name="radio"/></td>
<td width="15%"><bean:write name="specialResult"
property="upholidayDate" /></td>
<td width="15%"><bean:write name="specialResult"
property="upholidayDesc" /></td>
</tr>
</logic:iterate>
</logic:notEmpty>

</table>
<table align="center">
<tr>
<td valign=top><input type="button" property="update"
value="UPDATE" onclick="doUpdate()"></td>
<td valign=top><input type="button" property="delete"
value="DELETE" onclick="doDel()"></td>
<td valign=top><input type="button" property=cancel
value="GO BACK" onclick="doCancel()"></td>
</tr>
</table>
.....

I need to retrieve that "upId" which the radio button is selected.

I cannot set the radio button value as value="<%=upId%>" as the JSP will not load.

Can i get that radio button upId (this is primary key in table) within my action .

String upId = request.getParameter("upId");
//but this is retrieving the first row id and not the selected id.

Please help.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My maint.jsp page



My doDel Action
*************
 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help please, how to send the random "upId" retrieved from database to my action class for the radio button selected?
 
Ranch Hand
Posts: 69
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your list Contain upId Property then try the following code
No need of this <%String upId = request.getParameter("upId"); %>

and in your action class get the value using form bean

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

M sallu wrote:Any help please, how to send the random "upId" retrieved from database to my action class for the radio button selected?



Hi Sallu,

Please see this post. Radio Button Values and especially read the suggestion given by Dom Lassy. I hope that would be helpful for you.


 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not able to check my radio buttons...they are not selectable

 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured, there was name attibute missing



And my struts action class...shall I just getParameter and get the values

 
Fidel Edwards
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

M sallu wrote:I figured, there was name attibute missing



Good Sallu! It is good that you are trying hard, understanding and removing the shortcomings.


Please add name attribute in your radio button



Then only you can access this radio button's value in your Action class as
 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it worked and I am getting variable value for my radio button by


Thanks for all the help
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic