Java+Struts!

Hi Experts, I want to have one of my radio buttons already checked where as another one already disabled using the Struts tag. How can I do it? Below is the html code:
<td width="15%" class="detailbold" valign="top">Opening a London Account?</td>
<td width="15%" class="details" valign="top"><Input type="radio" name="londonacct" value="yes" CHECKED>Yes</input>
&nbsp;&nbsp;
<Input type="radio" name="londonacct" value="no" DISABLED>No</input></td>
Thanks,
KirtipurItagolAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fargoCommented:
<td width="15%" class="detailbold" valign="top">Opening a London Account?</td>
<td width="15%" class="details" valign="top"><html:radio property="londonacct" value="Yes" />
&nbsp;&nbsp;
<html:radio property="londonacct" value="no" disabled="true"/>
</td>

to make radio a default selection, in the Form class assigne the value for the property="londonacct" as Yes.

public yourForm extends ActionForm{
 private String londonacct="Yes";
...
...
}

fargo
0
KirtipurItagolAuthor Commented:
Fargo. should I make any changes in the struts-config.xml file regarding this??
0
fargoCommented:
No. No need to change the struts-config file.

But surely u have to add the struts taglib directive in your jsp page.

<%@ taglib
      uri="/WEB-INF/struts-bean.tld"
      prefix="bean"%>
<%@ taglib
      uri="/WEB-INF/struts-html.tld"
      prefix="html"%>
<%@ taglib
      uri="/WEB-INF/struts-logic.tld"
      prefix="logic"%>

fargo
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

KirtipurItagolAuthor Commented:
awesome......One more question Fargo.
What is the characteristic of value attribute in :
<html:radio property="" value""/>
0
fargoCommented:
Hi,

value attribute is to define the value for the given property in radio tag. It is mandatary attribute and can get runtime expressions too.

Like in your case,

1) <html:radio property="londonacct" value="Yes" />
2) <html:radio property="londonacct" value="no" />

As you know only radio buttons is not multi selected, i mean out of the radio buttons with same property only one can be selected. So whatever is selected the valule will be passed.

In the action form, if you set the value to "Yes", then the first one will be automatically selected.

You can also have values like the following (run time expressions)

<%
String value="Yes";
%>
<html:radio property="londonacct" value="<%=value%>" />

Hope it clears.
fargo
0
KirtipurItagolAuthor Commented:
In the action form, even though we set:
private String londonacct ="Yes";

We still need to have getters and setters for londonacct, isnt' that right??
But Fargo, I'm still confused with value attribute. Such as in here:
<td valign="center" class="detailbold">&nbsp;&nbsp;Zip Code</td>
<td valign="center" colspan="2" class="details">
<html:text property="zip" value="" size="24"/></td>

what is the value attribute doing here?? Any crystal clear advise so that I can proceed??
0
fargoCommented:
We still need to have getters and setters for londonacct, isnt' that right??
>> YES

Ok.
Say for ex:

How do we define the value to be there in text field in normal html?
<input type="text" name="nameOfproperty" >propValue</input>

same in struts is
<html:text property="nameOfproperty" value="propValue" />

Value is basically the value given to the form field.

fargo



0
KirtipurItagolAuthor Commented:
Good discussion but I'm still confused...A good book will be fine, but you are better than a book...so I'm gonna redefine my question again....

See in my first question above I 've :
<Input type="radio" name="londonacct" value="yes" CHECKED>Yes</input>
It has a value="yes" and then another Yes which showed a checked radio button labeled Yes on the side. This is where I got lost....
Clarify me please...
0
KirtipurItagolAuthor Commented:
And property is the name we should use in our action forms, right?? I think I know this!!
0
fargoCommented:
Hi,

I was wrong there...the following html

<Input type="radio" name="londonacct" value="yes" CHECKED>YesLabel</input>
struts equals
<html:radio property="londonacct" value="Yes"/>YesLabel

i just change the label name to clarify.
value attribute pass the value assigned to the radio button and YesLabel is just the label for the radio button.

sorry for confusion.

fargo


0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
http://husted.com/struts/tips/016.html

check out the above link and for a small good book check out "struts complete reference" is simple & ok.
Many online downloadable e-books are available like struts live etc.

About checkinga radio button just set the corresponding property of the radio button to a defult value which you wanted it to be checked.

i.e
String shiva="yes";

<html:radio property="shiva" value="Yes"/>Yes
<html:radio property="shiva" value="no"/>no

here yes will be checked out by default.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.