wood burning stoves*
The moose likes Struts and the fly likes struts radio button alignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


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

struts radio button alignment

usha kotha
Ranch Hand

Joined: Apr 18, 2012
Posts: 33
Struts radio button is not aligned properly. I have used the below struts tag for radio buttons. But the alignment of male and female radio buttons got jumbled. I don't want to convert this struts tag to input tag for UI design purpose. Please help me............ I have googled a lot but couldn't find a solution. I have attached the part of my jsp view which shows you how the radio buttons got jumbled.

<s:radio label="Gender" name="gender" required="true" list="#{'1':'Male','2':'Female'}" />



Please help ASAP


[Radio Alignment.png]

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

See the FAQ Why do the form tags put table tags around controls


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
usha kotha
Ranch Hand

Joined: Apr 18, 2012
Posts: 33
but i have already tried this. it made no impact.




Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Can you show us some code?
usha kotha
Ranch Hand

Joined: Apr 18, 2012
Posts: 33
<s:radio label="Gender" name="gender" required="true" list="#{'1':'Male','2':'Female'}" theme="simple" />


when i put this code the view changed like this..............with no label and more jumbled than before

Joe Ess wrote:Can you show us some code?


[RadioAlignment1.png]

jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Usha,

Can you post your whole jsp as i put the line you mention and it worked perfectly. Have you made any changes in default theme provided by struts as you have mention theme="simple" explicitly.

Regards
Jatan bhavsar

usha kotha
Ranch Hand

Joined: Apr 18, 2012
Posts: 33
here is my jsp


<%-- <%
response.setHeader("Pragma", "no-cache");
%>


<%
response.setHeader("Cache-Control", "no-store");
%>
<%
response.setDateHeader("Expires", -1);
%> --%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Candidate</title>
<link href="style2.css" rel="stylesheet" type="text/css" />
<sx:head parseContent="true" />
<script type="text/javascript">
function Checkfiles() {
var fup = document.getElementById('upload_filename');
var fileName = fup.value;
//alert (fileName);
var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
//alert (ext);
if (fileName == "") {
alert("Please select a file to Upload");
return false;
} else if (ext == "doc" || ext == "DOC") {
return true;
} else {
alert("Make sure to upload only .doc files");
fup.focus();
return false;
}
}
</script>
</head>

<body>
<%@ page errorPage="errorpage.jsp" %>
<%@ include file="QuickSearch.jsp"%>

<form name="frm" action="AddCandidate" method="post"
enctype="multipart/form-data">
<%@ include file="MainPage.jsp"%>


<!--Menu ends here-->

<!--Content Starts here-->


<div class="wrapper">

<div class="cont1"></div>

<div class="cont2">
<div class="title">Add Candidate</div>
<div class="centent">
<div class="conbox1">

<div class="fields">
<h1>Identification</h1>

<div class="formbox_in">
<s:textfield label="First Name" name="firstName"
value="%{firstName}" maxlength="25" required="true"
style="border:1px solid #ccc; background:#fff; width:165px;" />

<s:hidden name="userName" value="%{userName}" maxlength="15"
style="border:1px solid #ccc; background:#fff; width:165px;" />
<s:hidden name="roleInfo" value="%{roleInfo}" maxlength="15"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>

<div class="formbox_in">
<s:textfield label="Middle Name" name="middleInitial"
maxlength="25"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>

<div class="formbox_in">
<s:textfield label="Last Name" name="lastName"
value="%{lastName}" maxlength="25" required="true"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>

<div class="formbox_in">

<!-- <label class="label" for="gender">Gender:</label>
<input type="radio" value="1" id="gender1" name="gender" style="float: left; margin-left: 10px; margin-top: 4px;">
<label for="gender1" style="width: 45px; text-align: left; margin-left: 5px;">Male</label>
<input type="radio" value="2" id="gender2" name="gender" style="float: left; margin-top: 4px;">
<label for="gender2" style="text-align: left; width: 50px; margin-left: 5px;">Female</label> -->



<s:radio label="Gender" name="gender" required="true"
list="#{'1':'Male','2':'Female'}" />

</div>

<div class="clear"></div>

</div>

<div class="fields">
<h1>Contact Details</h1>

<div class="formbox_in">
<s:textfield label="Address" name="address" maxlength="30" required="true"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>

<div class="formbox_in">
<s:textfield label="City" name="city" maxlength="30" required="true"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>

<div class="formbox_in">
<s:select label="State" name="state" headerKey="Select" required="true"
headerValue="Select" list="states" listKey="value"
listValue="value"
style="border:1px solid #ccc; background:#fff; width:165px; margin-left:10px;" />

</div>

<div class="clear"></div>

<div class="formbox_in">
<s:textfield label="Zip" name="zip" required="true"
maxlength="6"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>


<div class="formbox_in">
<s:select label="Country" name="country" headerKey="United States" required="true"
headerValue="United States" list="countries" listKey="value"
listValue="value"
style="border:1px solid #ccc; background:#fff; width:165px; margin-left:10px;" />

</div>

<div class="clear"></div>


<div class="formbox_in">
<s:textfield label="Home Phone" name="homePhone"
value="%{homePhone}" maxlength="15"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>


<div class="formbox_in">
<s:textfield label="Cell Phone" name="cellPhone"
value="%{cellPhone}" maxlength="15"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>


<div class="formbox_in">
<s:textfield label="Email" name="emailId" value="%{emailId}"
maxlength="50" required="true"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>


<div class="formbox_in">
<s:textfield label="Alternate Email" name="altEmail"
maxlength="50"
style="border:1px solid #ccc; background:#fff; width:165px;" />

</div>

<div class="clear"></div>


</div>
</div>

<div class="conbox2">

<div class="fields">
<h1>Highest Education</h1>

<div class="formbox_in">
<s:select label="Education Level" name="educationLevel"
headerKey="Select" headerValue="Select"
list="{'Doctorate','Masters','Associate','Bachelors','High School'}"
style="border:1px solid #ccc; background:#fff; width:165px; margin-left:10px;" />

</div>

<div class="clear"></div>


</div>


<div class="fields">
<h1>Status</h1>

<div class="formbox_in">
<sx:datetimepicker name="dateAvailable" formatLength="medium"
label="Date" displayFormat="MM/dd/yyyy"
value="%{dateAvailable}" type="date"
cssStyle="border:1px solid #ccc; width:165px;" />

</div>
<div class="clear"></div>

<div class="formbox_in">
<s:select label="Work Permit Type" headerKey="Select" required="true"
headerValue="Select" name="workPermit"
list="{'Citizen','H1','F1-OPT','Other'}"
style="border:1px solid #ccc; background:#fff; width:165px; margin-left:10px;" />

</div>
<div class="clear"></div>

<div class="formbox_in" style="margin-top: 20px;">
<%-- <s:select label="Status" headerKey="-1" headerValue="Any" value="-1"
name="status" multiple="true"
list="listOfStatus" listKey="statusName" listValue="statusName"
style="border:1px solid #ccc; background:#fff; width:165px; margin-left:10px;" /> --%>
<s:select label="Status" headerKey="-1"
name="status" multiple="true" value="%{statusMultiList}" required="true"
list="listOfStatus" listKey="statusName" listValue="statusName"
style="border:1px solid #ccc; background:#fff; width:165px; margin-left:10px;" />
<%-- <s:select label="Status" headerKey="-1"
name="status" multiple="true" required="true"
list="listOfStatus" listKey="statusName" listValue="statusName"
style="border:1px solid #ccc; background:#fff; width:165px; margin-left:10px;" /> --%>

</div>
<div class="clear"></div>

<div class="formbox_in" style="margin-top:60px;">
<s:select label="Sourcer" name="sourcer" required="true"
headerKey="Select" headerValue="Select" list="listOfSourcers"
listKey="%{firstName+' '+lastName}"
listValue="%{firstName+' '+lastName}"
style="border:1px solid #ccc; background:#fff; width:165px; margin-left:10px;" />

</div>

<div class="clear"></div>


</div>

<div class="fields">
<h1>Resume</h1>

<div class="formbox_in">
<s:file id="upload_filename" name="upload_filename"
label="Resume " style="border:1px solid #ccc; margin-left:10px;" />

</div>
<div class="clear"></div>



</div>

</div>
<div class="clear"></div>
<div class="conbox">
<div class="formbox" style="width:54px; margin-top:15px;">
<input type="submit" name="submit" align="right" value="Save"
class="title_bg" style="width: 54px;" />
</div>
</div>
</div>

</div>

<div class="cont3"></div>
</div>
</form>
</body>
</html>






jatan bhavsar wrote:Hi Usha,

Can you post your whole jsp as i put the line you mention and it worked perfectly. Have you made any changes in default theme provided by struts as you have mention theme="simple" explicitly.

Regards
Jatan bhavsar

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts radio button alignment