How to add multiple column in a table on a button action - html

I have a table were I want to add multiple columns with values when I click an add button. I have a drop down of Rulelist after selecting rule I have a button that rule pass to the controller search the object of that particular rule and display in a table. Now I am facing a problem after adding one column when I want to add another the first column gets removed.
Html
<form:form action="/update" method="post" id="ruleListForm" modelAttribute="ruleListContainer">
<table border="1">
<thead>
<h3 align="center">Selected Rule</h3>
<tr>
<th data-field="id" width="25"> ID </th>
<th data-field="details" width="20">RuleName</th>
<th data-field="details" width="10">StartDate</th>
<th data-field="details" width="10">EndDate</th>
<th data-field="parameter" width="240">Parameter </th>
</tr>
</thead>
<tbody id="ruleListContainer">
<c:forEach items="${ruleList}" var="as" varStatus="vs">
<tr class="rule">
<td><input type="hidden" name="ruleList[${vs.index}].id" value="${as.rule.id}" /> ${as.rule.id}</td>
<td><input type="hidden" name="ruleList[${vs.index}].ruleName" value="${as.rule.ruleName}" /> ${as.rule.ruleName}</td>
<td> <input id="one" class="datepicker" type="text" name="ruleList[${vs.index}].startDate" size="11" height="0.10"></td>
<td> <input id="two" class="datepicker" type="text" name="ruleList[${vs.index}].endDate" size="11" height="0.10"></td>
<td>
<table border="1">
<c:forEach items="${as.ruleParameter}" var="asss">
<tr>
<td><input type="hidden" name="ruleList[${vs.index}].ruleParameter[${assignments.index}].parameterName"value="${asss.parameterName}"> ${asss.parameterName}</td>
<td><input type="hidden" name="ruleList[${vs.index}].ruleParameter[${assignments.index}].parameterValue" value="${asss.parameterValue}" /> ${asss.parameterValue}</td>
<td><input type="text" name="Name" value=""size="2"height="0.01">
<select style="width: 80px;">
<option value="">--Select--</option>
<c:forEach items="${targetlist}" var="target">
<option value="${target.displayName}"/>
<c:out value="${target.displayName}" />
</c:forEach>
</select>
</td>
</tr>
</c:forEach>
</table>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<br>
<input type="submit" value="create">
</form:form>
<div>
<form action="/submitrule" method="post" model="command">
<table>
<tr>
<td colspan="6" align="right">
<select name="Id">
<option value="">--Select--</option>
<c:forEach items="${listRules}" var="rule">
<option>
<c:out value="${rule.id}" />
</option>
</c:forEach>
</select>
<input type="submit" value ="add"></td>
</tr></table></form>
</div>
Controller
#RequestMapping(value = "/submitrule", method = RequestMethod.POST)
public String addruleSerch(#ModelAttribute ("SpringWeb") Rule obj2, ModelMap model) {
model.addAttribute("Id", obj2.getId());
Rule rul = ruleApi.getRule(obj2.getId());
ArrayList<Rule> rl1 = new ArrayList<Rule>();
List<RuleParameter> ptr2 = rul.getRuleParameter();
Iterator it = ptr2.iterator();
while(it.hasNext()) {
RuleParameter r = (RuleParameter) it.next();
System.out.println(r.getParameterName());
System.out.println(r.getParameterValue());
}
rl1.add(rul);
model.addAttribute("ruleList", rl1);
return "hello";
}
How to add multiple column?
Thank you in advance for help/suggestions.

Related

send automatic mail to respective user when user uploads file to database

I am new with servlets. I have created MySQL database. User will upload file(or more than one files). Then automatically mail should be send to respective user who will upload file. please suggest me how to do this?. I have read about JAVA Mail API but I don't know how to use it. Is there any other way to do it? please suggest.
Note:- I don't want to send an email to one user. I want to send mail to that user who will upload file.
This is index.jsp page that I have created.
<form action="UploadServletClass" method="post" enctype="multipart/form-data">
<center>
<h1>Welcome to Document Management System...</h1>
</center>
<table width="400px" align="center" border="2">
<tr>
<td align="center" colspan="2">Form Details</td>
</tr>
<tr>
<td>First Name</td>
<td>
<input list="firstnamelist" required="" name="firstname" />
</td>
</tr>
<tr>
<td>Last Name</td>
<td>
<input list="lastnamelist" required="" name="lastname" />
</td>
</tr>
<tr>
<td>Division</td>
<td>
<input type="text" required="" name="division" />
</td>
</tr>
<tr>
<td>Reporting Unit</td>
<td>
<input type="text" required="" name="reportingunit" />
</td>
</tr>
<tr>
<td>Document Number</td>
<td>
<input type="text" required="" name="documentnumber" />
</td>
</tr>
<tr>
<td>Document Name</td>
<td>
<input type="text" required="" name="documentname" />
</td>
</tr>
<tr>
<td>Document Uploader</td>
<td>
<input type="text" required="" name="documentuploader" />
</td>
</tr>
<tr>
<td>Document Owner</td>
<td>
<input type="text" required="" name="documentowner" />
</td>
</tr>
<tr>
<td>Document Type</td>
<td>
<select name="Document_Type">
<option value="Agreement">Agreement</option>
<option value="Contract">Contract</option>
<option value="PO">PO</option>
<option value="Invoice">Invoice</option>
<option value="COA">COA</option>
<option value="Lease Deed">Lease Deed</option>
<option value="AMC">AMC</option>
<option value="Direct Material">Direct Material</option>
<option value="Indirect Material/Services">Indirect Material/Services</option>
</select>
</td>
</tr>
<br><br>
<tr>
<td>Document Category</td>
<td>
<select name="Document_Category">
<option value="Customer">Customer</option>
<option value="Vendor">Vendor</option>
<option value="Internal">Internal</option>
</select>
</td>
</tr>
<br><br>
<tr>
<td>Mail id</td>
<td>
<input type="email" required="" name="mailid" />
</td>
</tr>
<tr>
<td>Select File</td>
<td>
<input type="file" name="fileName" multiple="multiple" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Submit" name="Submit" />
</td>
</tr>
</table>
</form>

table tag is adding extra td in tr tag automatically

Hi I am just going through a mysterious condition in my code.
single <td> Or <th> in chrome and Mozilla Firefox don't know why.
<div class="right_content">
<table style="width: 100%; height: 200px; margin-top: 5px;" id="mainTable">
<tr>
<th colspan="1">Participant Name</th>
<td colspan="1">${fullName}<td>
<th colspan="1">Role</th>
<td colspan="1">${role}<td>
<th colspan="1">Brand/Location</th>
<td colspan="1">${location}<td>
</tr>
<tr>
<th>Goal Text</th>
<td><input name="goalText" id="goalText" name="goalText"
class="text_field" size="40" maxlength="95" tabindex="1"
title="Minimum Rating For This Competency" /></td>
<th>Assessment Center</th>
<td><select name="assessmentCenterId" id="assessmentCenterId" class="text_field"
tabindex="2" title="Select Assessment Center">
<option value="-1">--Select Assessment Center--</option>
<c:forEach items="${acList}" var="singleAC" varStatus="sts">
<c:choose>
<c:when test="${singleAC.id eq 0}">
<option value="${singleAC.id}" selected="selected">${singleAC.name} </option>
</c:when>
<c:otherwise>
<option value="${singleAC.id}">${singleAC.name}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select></td>
<th>Status</th>
<td><select name="status" id="status" class="text_field"
tabindex="3" title="Select Status Of IDP">
<option value="-1" selected="selected">--Select Status--</option>
<c:forEach items="${EnumIDPStatus}" var="singleStatus"
varStatus="sts">
<c:choose>
<c:when test="${(singleStatus.key eq 0) &&(mode eq 'Add')}">
<option value="${singleStatus.key}" selected="selected">${singleStatus.value}</option>
</c:when>
<c:otherwise>
<option value="${singleStatus.key}">${singleStatus.value}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select></td>
</tr>
<tr>
<th>Score</th>
<td><input type="text" name="score" id="score" class="text_field"
size="40" maxlength="95" tabindex="4" title="Score" /></td>
<th>Target Date</th>
<td><input type="text" name="targetDate" id="targetDate"
class="text_field" title="Minimum Rating For This Competency" /></td>
<th>Extended Date</th>
<td><input type="text" name="extendedDate" id="extendedDate"
class="text_field" /></td>
</tr>
<tr>
<th>Manger Comments</th>
<td><textarea name="managerComments" id="managerComments"
class="text_field" rows="5" cols="50" tabindex="7"
title="Minimum Rating For This Competency"></textarea></td>
<th>Assessor Comments</th>
<td><textarea name="assessorComments" id="assessorComments"
class="text_field" rows="5" cols="50" tabindex="8"
title="Minimum Rating For This Competency"></textarea></td>
<th>Participant Comments</th>
<td><textarea name="participantComments"
id="participantComments" class="text_field" rows="5" cols="50"
tabindex="9" title="Minimum Rating For This Competency"></textarea>
</td>
</tr>
<tr>
<td colspan="6" class="frm_footer_buttons"
style="text-align: center;"><input type="button"
name="btnsubmit" id="btnsubmit" class="frm_button"
value="<spring:message code='button.save' />" tabindex="10"
onclick="return errorPopup();" /> <input type="reset"
class="frm_button" value="Reset" tabindex="11" /> <input
type="button" class="frm_button"
value="<spring:message code='button.cancel'/>" tabindex="12"
onclick="submitRequest('showIDPList.html');" /></td>
</tr>
</table>
</div>
Make sure to always close your HTML tags properly.
Here's a part of your HTML:
<tr>
<th colspan="1">Participant Name</th>
<td colspan="1">${fullName}<td>
<th colspan="1">Role</th>
<td colspan="1">${role}<td>
<th colspan="1">Brand/Location</th>
<td colspan="1">${location}<td>
</tr>
Can you spot a problem?
Look carefully at your closing tags. Your <th> opening tags have proper </th> closing tags, but you <td> don't. They miss / in their closing tags which effectively means you open a new tag instead of closing the previous one.

smart-table st-sort only sorting half

I am using smart-table to display a table of employee names, extensions, etc. My data loads fine, but when I try and sort using st-sort it only sorts the top half of the rows. Always half, always the top.
Here's the html code snippet with the table:
<div class="col8" ng-controller="employeeCtrl">
<table st-table="employeesCollection" st-safe-src="employeesCollection" class="table table-striped">
<thead>
<tr>
<th st-sort="firstName" st-skip-natural="true">First Name</th>
<th st-sort="lastName" st-skip-natural="true">Last Name</th>
<th st-sort="extension" st-skip-natural="true">Extension</th>
<th st-sort="city" st-skip-natural="true">Store City</th>
<th st-sort="number" st-skip-natural="true">Store Number</th>
</tr>
<tr>
<td>
<input type="text" id="FirstName" size="10" ng-keyup="searchEmp()" /></td>
<td>
<input type="text" id="LastName" size="10" ng-keyup="searchEmp()" /></td>
<td>
<input type="text" id="Extension" size="10" ng-keyup="searchEmp()" /></td>
<td>
<select id="store" onchange="searchEmp()">
<option value=''>Select City</option>
<% For Each city In cityList%>
<option value="<%=city%>"><%=city%></option>
<% Next%>
</select></td>
<td>
<select id="storeNo" onchange="searchEmp()">
<option value=''>Select Store</option>
<% For Each store In storeList%>
<option value="<%=store%>"><%=store%></option>
<% Next%>
</select>
</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="employee in employeesCollection">
<td ng-repeat="col in employee track by $index">{{col}}</td>
</tr>
</tbody>
</table>
</div>
Anybody got any ideas?
One thing I am noticing, and it may be the issue, is that you are using the same collection in the st-table directive and st-safe-src directive. If you are working with async data, you need to set as in documentation:
st-table="displayedCollection" st-safe-src="rowCollection"
And in your controller:
$scope.displayedCollection = [].concat($scope.rowCollection);

Making input form boxes horizontal in HTML

I been doing some html code in a few days now, but i can't figure out how to make the it all in a horizontal look, just like this exsampel:
ID Name Commodity Weight Tolerance
Box Box drop down box box
So box stands for "input form" ofc, and a drop down should be full of names of commodities from my database.
Right now, i have this code so far:
<body>
<div id="header">
<h2 align="center" style="color: #FFFFFF">Edit Recept</h2>
</div>
<div id="content">
<div id="form-wrapper">
<form method="post" action="Front">
<table>
<tr>
<td>ID: <td>
<td><input type="text" name="Id" />
</tr>
<tr>
<td>Name:<td>
<td><input type="text" name="name" />
</tr>
</table>
<table>
<tr>
<p> </p>
<p>Add commodities to your recept: <p>
</tr>
<tr>
<td>Select commodity:<td>
<td><select>
<option value="" disabled="disabled" selected="selected">Please select Commodity</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>
</tr>
<tr>
<td>Weight:<td>
<td><input type="text" name="tolerance" />
</tr>
<tr>
<td>Tolerance:<td>
<td><input type="text" name="name" />
</tr>
<tr>
<td><input type="submit" value="Add" /><td>
<tr>
</table>
<br>
<input type="submit" value="Save" />
<input type="reset" value="Cancel" />
<input type="hidden" name="whichPage" value="prescription"/>
</form>
</div>
<p align="center">
Enter the new values and press save to make the change
</p>
</div>
Is there a trick how to do it easy?? My goal is to make it like i described on the top, and then add a button which will add a new line of input boxes under the other if you want to store more commodities in the same prescription.
Just make your labels all in one single row of the table, then the input fields for those labels should be jsut under in a second row. So you will have a colomn based input just as you wish, here is a fiddle as a sample.
<div id="header">
<h2 align="center" style="color: #FFFFFF">Edit Recept</h2>
</div>
<div id="content">
<div id="form-wrapper">
<form method="post" action="Front">
<table>
<tr>
<td>ID </td>
<td>Name</td>
<td>Select commodity</td>
<td>Weight</td>
<td>Tolerance</td>
</tr>
<tr>
<td><input type="text" name="Id" /></td>
<td><input type="text" name="name" /></td>
<td><select>
<option value="" disabled="disabled" selected="selected">Please select Commodity</option>
<option value="1">One</option>
<option value="2">Two</option>
</select></td>
<td><input type="text" name="tolerance" /></td>
<td><input type="text" name="name" /></td>
</tr>
</table>
<br />
<input type="submit" value="Save" />
<input type="reset" value="Cancel" />
<input type="hidden" name="whichPage" value="prescription"/>
</form>
</div>
<p align="center">
Enter the new values and press save to make the change
</p>
</div>
Note: You should pay attention to the closing tags for table element markups as you are missing some and introducing an open tag instead of a closing one in some rows.
Just a small hint. This will show the text and input box below each other. But you need to rearrange your whole table with the proper manner. Also dont use multiple tables. Use single table with many columns.
<table>
<tr>
<td>ID: </td>
<td>Name:</td>
</tr>
<tr>
<td><input type="text" name="Id" /></td>
<td><input type="text" name="name" /></td>
</tr>
</table>

How to call jquery that is stored in external javascript file from html file

//employeeForm.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Employee Information</title>
<script src="jquery-1.4.4.js" type="text/javascript"></script>
<link href="EmployeeFormStyle.css" type="text/css" rel="stylesheet"/>
<script src="EmployeeModuleBase.js" type="text/javascript"></script>
</head>
<body class="body">
<h3 class="header">Employee Information</h3>
<form class="form" method="post" id="employeeInfoForm" name="employeeInfo" action="ProcessEmployeeInfo.php">
<table>
<tbody>
<tr>
<td><label for="fname">First Name:</label></td>
<td id="eftd_1"><input id="FirstName" name="FirstName" type="text"/></td>
<td id="validatortxt_1" class="red-text"></td>
</tr>
<tr>
<td><label for="surname">Surname:</label></td>
<td id="eftd_2"><input id="Surname" name="Surname" type="text"/></td>
<td id="validatortxt_2" class="red-text"></td>
</tr>
<tr>
<td><label for="gender">Gender:</label></td>
<td id="eftd_3">
<select name="Gender" id="Gender">
<option></option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</td>
<td id="validatortxt_3" class="red-text"></td>
</tr>
<tr>
<td><label for="Title">Title:</label></td>
<td id="eftd_4">
<select name="Title" id="Title">
<option></option>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
<option value="Prof">Prof</option>
</select>
</td>
<td id="validatortxt_4" class="red-text"></td>
</tr>
<tr>
<td><label for="ID No">ID No.:</label></td>
<td id="eftd_5"><input id="IDNo" name="IDNo" type="text" maxlength="13"/></td>
<td id="validatortxt_5" class="red-text"></td>
</tr>
<tr>
<td><label for="mobileNumber">Mobile Number:</label></td>
<td id="eftd_6"><input id="MobileNumber" name="MobileNumber" type="text" maxlength="12"/></td>
<td id="validatortxt_6" class="red-text"></td>
</tr>
<tr>
<td><label for="email">Email Address:</label></td>
<td id="eftd_7"><input id="EmailAddress" name="EmailAddress" type="text"/></td>
<td id="validatortxt_7" class="red-text"></td>
</tr>
<tr>
<td><label for= "address">Address:</label></td>
<td id="eftd_8"><input id="AddressLine1" name="AddressLine1" type="text"/></td>
<td id="validatortxt_8" class="red-text"></td>
</tr>
<tr>
<td></td>
<td id="eftd_9"><input id="AddressLine2" name="AddressLine2" type="text" size=30/></td>
<td id="validatortxt_9" class="red-text"></td>
</tr>
<tr>
<td></td>
<td id="eftd_10"><input id="AddressLine3" name="AddressLine3" type="text" size=30/></td>
<td id="validatortxt_10" class="red-text"></td>
</tr>
<tr>
<td><label for="location">Location:</label></td>
<td id="eftd_11">
<select name="Location" id="Location">
<option></option>
<option value="Sebokeng">Sebokeng</option>
<option value="Sharpville">Sharpville</option>
<option value="Evaton">Evaton</option>
<option value="Boipatong">Boipatong</option>
<option value="Bophelong">Bophelong</option>
<option value="Vanderbijlpark">Vanderbijlpark</option>
<option value="Vereeneging">Vereeneging</option>
</select>
</td>
<td id="validatortxt_11" class="red-text"></td>
</tr>
<tr>
<td><label for= "postalcode">Postal Code:</label></td>
<td id="eftd_12"><input id="PostalCode" name="PostalCode" type="text" maxlength="5"/></td>
<td id="validatortxt_12" class="red-text"></td>
</tr>
<tr>
<td> </td>
<td>
<input id="btnSubmit" class="butt" name="btnSubmit" value="Save" type="submit"/>
<input id="btnClear" class="butt" name="btnClear" value="Clear" type="submit"/>
</td>
<td> </td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
EmployeeModuleBase.js
jQuery().ready(function ()
{
$('#employeeInfoForm').submit(function()
{
var postForm = true;
$(':input').each(function(index)
{
if ( $(this).val() == "" )
{
if ($(this).attr("id")!="EmailAddress")
{
$('#validatortxt_' + (index + 1).toString()).text(" *");
}
postForm = false;
}
else
{
$('#validatortxt_' + (index + 1).toString()).text("");
postForm = true;
}
});
return postForm;
});
};
basically what m trying to achieve is to validate the form using jquery code in external js file.but how does the form calls the jquery code in js external file...?
you append the ready method to the loading of jQuery
jQuery().ready(function ()
you should append the event to the document and not just to the jQuery itself. then it should load up when the document is ready to go and the DOM is there for the handler to append to.
jQuery(document).ready(function ()
In your external file, just have a plain 'old fashion' function. Then you can call it as needed (the function can use jQuery):
$(document).ready(DocReady);
function DocReady()
{
AssignClickToToggleButtons();
ColorCodeTextBoxes();
DoValidation();
}