This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

select a radio button

 
Marie
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone tell what is the correct way to select one radio button when displaying a response to the client in struts based JSP page.

Tried following with checked attribute does not work

<logic:match name="<%=sessionValue%>" property="type" value="C">
<html:radio checked="checked" name="<%=sessionValue%>" property="type" value="I"/>Internal
</logic:match>
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the html:radio tag automatically checks or unchecks the radio button based on the value of the "type" property in your ActionForm, the solution is to set the value of the "type" property prior to forwarding to the JSP.

So, in the Action that forwards to this jsp you will code:

myForm.setType("I");

and in your JSP you will code:

<html:radio property="type" value="I"/>


If you do this, Struts will automatically cause this button to display as checked.
 
Marie
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the setter setType in the action class, It displays on the WAS console too. But it does not set to the correct value taken from the DB.

I need a <logic:match done correctly. I think the logic tag attributes are wrong.

<logic:match name="<%=sessionValue%>" property="type" value="E"> ---???
<html:radio name="<%=sessionValue%>" property="type" value="I"/>Internal
<html:radio name="<%=sessionValue%>" property="type" value="E"/>External
</logic:match>
 
Pratik Shah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you be more clear with what you exactly expect your code to do..
as in while displaying the response which specific radio button do you want to be selected
for e.g: you want every time the first radio button to be selected and so on..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic