aspose file tools*
The moose likes Struts and the fly likes select a radio button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "select a radio button" Watch "select a radio button" New topic
Author

select a radio button

Marie
Greenhorn

Joined: May 04, 2005
Posts: 28
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>


Thanks<br />Marie
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Marie
Greenhorn

Joined: May 04, 2005
Posts: 28
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

Joined: Dec 19, 2005
Posts: 2
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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: select a radio button
 
Similar Threads
Radio Buttons
html radio
how to retrieve data into radiobuttons
setting a radio button
logic:match