How to have a struts2 form in a table? - css

I am trying to have my form in a table but it generates a table and makes it a mess.
the generated table is as following:
<div>
<s:form action="myaction" >
<table border="1">
<tr>
<td><s:textfield name="name" label="Name" /></td>
<td><s:textfield name="family" label="Family" /></td>
<td><s:submit/></td>
</tr>
</table>
</s:form>
</div>
Source code :
<div>
<form id="myaction" name="myaction" action="/application/myaction.action" method="post">
<table class="wwFormTable"> <<<generated table
<table border="1">
<tr>
<td><tr>
<td class="tdLabel"><label for="Search_Name" class="label">Name:</label></td>
<td
><input type="text" name="Name" value="" id="Search_Name"/></td>
</tr>
</td>
<td><tr>
<td class="tdLabel"><label for="Search_Family" class="label">Family:</label></td>
<td
><input type="text" name="Family" value="" id="Search_Family"/></td>
</tr>
</td>
<td><tr>
<td colspan="2"><div align="right"><input type="submit" id="Search_0" value="Submit"/>
</div></td>
</tr>
</td>
</tr>
</table>
</table></form>

Use the "simple" theme if you do not want to use S2's default "xhtml" theme.
You'll lose S2's automatic error reporting. You may wish to consider creating your own theme.
Alternatively, you can use the "simple" theme on individual controls.
See the "Themes and templates" docs to get started.

Try to use any theme in struts form tag
eg:
<s:form action="Courses" theme="css_xhtml">
<table border="0">
<tr>
<td><s:textfield name="courseAbbr" /></td>
</tr>
</table>
</s:form>

May Be you should use this code instead...
<sp:form >
<tr>
<td>
<table>
<sp:textfield name="name"></sp:textfield>
</table>
</td>
<td>
<table>
<sp:textfield name="family"></sp:textfield>
</table>
</td>
<td>
<table>
<sp:submit/>
</table>
</td>
</tr>
</sp:form>

Related

How to send multiple objects from jsp files

I want to send multiple objects from jsp file using commandname in spring form
I have searched on google and explored various sites but found no solutions of this problem
<form:form action="addproductLED"method="post"commandname="addProductLed">
<div align="center">
<h2 class="ledtechdetails">Add Led</h2>
</div>
<div style="margin-top:25px;margin-bottom:25px;">
<table border="0" cellpadding="10" cellspacing="10" class="addledtable">
<tr class="add-led">
<td class="add-led">Product Category :</td>
<td class="add-led">
<select id="productCatId"name="productCatId"class="protechname"onchange="showled('led')" required>
</tr>
<tr class="add-led">
<td class="add-led">Product Name :</td>
<td class="add-led">
<input type="text" name="productName" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product Stock :</td>
<td class="add-led"><input type="number" name="productStock" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product SKU :</td>
<td class="add-led"><input type="text" name="productsku" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product MRP :</td>
<td class="add-led"><input type="number" name="productMrp" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product Price :</td>
<td class="add-led"><input type="number" name="productprize" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product Size :</td>
<td class="add-led"><input type="text" name="productsize" class="protechname"/></td>
</tr>
<!-- another model class configuration -->
<tr class="add-led">
<td class="add-led">Resolution :</td>
<td class="add-led"><input type="text" name="resolution" class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Port :</td>
<td class="add-led">
<input type="text" name="port" class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Wifi Type :</td>
<td class="add-led"><input type="text" name="type" class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Operating System :</td>
<td class="add-led"><input type="text" name="operatingSystem" class="protechname"/></td>
</tr>
I want to get model class object in Spring Controller but I dont know how to send two model class object from one single jsp page
You can transfer multiple objects using commandname separated by semi-colon,
You have to change
<form:form action="addproductLED"method="post"commandname="addProductLed">
to
<form:form action="addproductLED" method="post" commandname="addProductLed,anotherObject" enctype="multipart/form-data">
It will send multiple object.

How to populate values in a Pure CSS Table using JSTL?

I have been trying to populate the values of arraylist to load into a table using Pure CSS.
The arraylist contains values of columns "Make", "Model" and "Year".
FYI each arraylist are column values not row values.
Thank you.
<table class="pure-table" style = "margin-left :50px">
<thead>
<tr>
<th><input id="checkItem" type="checkbox"> Select All</th>
<th>Make</th>
<th>Model</th>
<th>Year</th>
</tr>
</thead>
<tbody>
<tr class="pure-table-odd">
<td><input id="remember" type="checkbox"> </td>
<c:forEach var="make" items="${loadMake}">
<td> <c:out value="${make}"></c:out> </td>
</c:forEach>
<c:forEach var="model" items="${loadModel}">
<td> <c:out value="${model}"></c:out> </td>
</c:forEach>
<c:forEach var="year" items="${loadYear}">
<td> <c:out value="${year}"></c:out> </td>
</c:forEach>
</tr>
</tbody>
</table>

applying css to font in table

I'd like to know where i have gone wrong, i want to apply font verdana to "to change this font to verdana."
I have removed contend from other table rows to make the code appear clearer. I have set the css styling to this section but when uploading the font does not change at all.
Code is:
<style type="text/css">
#form1 tbody tr td {
font-family: Verdana, Geneva, sans-serif;
}
</style>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
<tr>
<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<tr>
<td><strong>Title 1</strong></td>
</tr>
<tr>
<td>To Change this font to verdana.<br>
<br></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align="center"> </td>
</tr>
</form>
<tr>
<td>
<!-- start here-->
<form action="http://www./cookie5payment/freecontact2formprocess.php" method="post">
<table class="freecontact2form" border="0" width="400px">
<tbody>
<tr>
<td colspan="2"><span style="font-size: x-small;"> </span> <br /> <br /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><br></td>
<td></td>
</tr>
<tr>
<br>
<td valign="top"> </td>
</tr>
<tr>
<td style="text-align:center" colspan="2"><br /><br />
<br /><br />
<br /><br /></td>
</tr>
</tbody>
</table>
</form>
<!-- end here -->
</td>
</tr>
</table>
</tr>
Your code is not working as expected because you use the identifier #form1 to target the table inside that form, but you start the table outside the form so the css selector can not find it. Change the order of your html as follows (i.e. switch the form and table tag)
<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1 id="form1">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
Here is a fiddle to illustrate this

How do I use html decode in my view page?

My engine is Aspx.
I am currently having trouble editing one of my columns(Question Answer) in my table because it has html tags in it. Is there a way I can decode only that specific row/column in the value area?
<form id="updateFreqQuestionsUser" action="<%=Url.Action("SaveFreqQuestionsUser","Prod")%>" method="post">
<table>
<tr>
<td colspan="3" class="tableHeader">Freq Questions User Details <input type ="hidden" value="<%=freqQuestionsUser.freqQuestionsUserId%>" name="freqQuestionsUserId"/> </td>
</tr>
<tr>
<td colspan="2" class="label">Question Description:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionDescription" value="<%=freqQuestionsUser.questionDescription%>" />
</td>
</tr>
<tr>
<td colspan="2" class="label">QuestionAnswer:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionAnswer" value="<%=freqQuestionsUser.questionAnswer%>" />
</td>
</tr>
<tr>
<td colspan="3" class="tableFooter">
<br />
<a id="freqQuestionsUserUpdateButton" href="#" class="regularButton">Save</a>
Cancel
</td>
</tr>
</table>
Yes, you can do this:
<input type="text" maxlength="2000" name="QuestionAnswer"
value="<%=Server.HtmlDecode(freqQuestionsUser.questionAnswer)%>" />
Reference

How to disable all td tag in jsp using css

I have a form that is in jsp at one condition the user click to view the form. When the form is render the information contain in the form should not be editable all the td should be visible but should not be editable.
for example:-
<table width="600" align="center" >
<tr>
<td class="td_left_b" width="30%">Company Name:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.companyName}" id="companyName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Hotel Name(Display Name):</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.hotelName}" id="hotelName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Country:</td>
<td width="60%" height="25"><input type="text" size="28" value="" id="country"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">City:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.cityName}" id="cityName"/></td></tr>
<tr>
<td class="td_left_b" width="30%">NeighbourhoodName:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.neighbourhoodName}" id="neighbourhoodName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Street Name:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.streetName}" id="streetName"/></td>
</tr>
</table>
The above information i am putting through spring MODEL ATTRIBUTE in respective td. i dont want to be editable the information.
Thanks.
You cannot disable Tablecolumns. You have to disable evere input in your table.

Resources