Spring -- DataTables Checkbox selection cannot be deleted - java

I'm posting my first question on Stack Overflow.
When I try to remove the checked data from the data table, it doesn't work.
Is there a problem with my code?
Is it right to receive data from DAO, Service, and Service Impl using Map<String,Object>commandMap?
JSP
<table id="tableDemo" class="display">
<thead>
<tr>
<th></th>
<th data-orderable="false">No.</th>
<th>그룹코드</th>
<th>그룹명</th>
<th>코드</th>
<th>코드명</th>
<th>사용여부</th>
</tr>
</thead>
<tbody>
<c:set var="count" value="1"/>
<c:forEach var="list" items="${resultlist }" varStatus="status">
<tr>
<td><input style="zoom:1.3;" type="checkbox" name="test" value=${list.codegid }></td>
<td>${count }</td>
<td>${list.codegid }</td>
<td>${list.codegnm }</td>
<td>${list.code }</td>
<td>${list.codenm }</td>
<td>${list.useat }</td>
<c:set var="count" value="${count+1}"/>
</tr>
</c:forEach>
</tbody>
</table>
<a id="delete" class="btn blue" >삭제</a>
</div>
script
$("#delete").on("click", function() {
if (confirm(" 삭제하시겠습니까?")==true) {
var cnt = $("input[name='test']:checked").length;
var ids = new Array;
$("input[name='test']:checked").each(function() {
ids.push($(this).val('id'));
});
if(cnt == 0){
alert("선택된 글이없습니다.");
}
else{
$.ajax = {
type: "POST",
url: "<c:url value='/codeDelete.do'",
data: "codegid="+ ids + "&CNT=" + cnt,
dataType: "json"
}
}
}
});
Controller
#RequestMapping(value="/codeDelete.do")
#ResponseBody
public int deleteCodes(Map<String,Object> commandMap) throws Exception{
int result=1;
try {
int cnt = Integer.parseInt((String) commandMap.get("CNT"));
String rprtOdr = (String)commandMap.get("codegid");
String [] strArray = rprtOdr.split(",");
System.out.println("list ===>>" + strArray);
for(int i=0; i<cnt; i++) {
String temp = ((String)strArray[i]);
commandMap.put("codegid", temp);
codeService.deleteCodes("codetDAO.deleteCodes", commandMap);
}
} catch (Exception e) {
log.debug(e.getMessage());
result=0;
}
return result;
}
}
serviceImpl
#Service("codeService")
public class CodeServiceImpl implements CodeService {
#Resource(name="codeDAO")
private CodeDAO codeDAO;
#Override
public void deleteCodes(String string, Map<String, Object> commandMap){
codeDAO.deleteCodes(commandMap)
}
DAO
#Repository("codeDAO")
public class CodeDAO extends EgovAbstractDAO{
public void deleteCodes(Map<String, Object> commandMap) {
delete("codeDAO.deleteCodes",commandMap);
}
SQL
<delete id="codeDAO.deleteCodes">
<![CDATA[
UPDATE codes
SET USE_AT = 'N'
WHERE codegid = #codegid#
]]>
</delete>

Related

getting Ids from selected checkboxes in a table using Spring + Thymeleaf

I'm getting an error NotReadablePropertyException: Invalid property 'userIds' of bean class [...ListOfIds]... And I'm not sure why. If I remove the th:field attribute on the checkbox, the table fills in properly. I've tried with th:field="*{requestIds}" and th:field="*{requestIds.ids}"
What I'm trying to do is collect the list of ids from the selected checkboxes and pass them back to the controller for the post.
Form
public class ListOfIds {
List<Long> ids = new ArrayList<>();
public List<Long> getIds() { return ids; }
// I've tried both set methods by themselves and together.
public void setIds(List<Long> ids) { this.ids = ids; }
public void setIds(Long[] ids) { this.ids = Arrays.asList(ids); }
}
Request bean
public class Request {
long id;
String name;
String phone;
String email;
// Getters/Setters
}
Controller
#GetMapping("/myTable")
public ModelAndView getMyTable(ModelAndView mav) {
mav.setViewName("myTable");
List<Request> requests = service.getRequests();
mav.addObject("requests", requests);
mav.addObject("requestIds", new ListOfIds());
return mav;
}
#PostMapping("/myTable")
public ModelAndView postRequests(ModelAndView mav, #ModelAttribute("requestIds") ListOfIds ids) {
...
}
html page
...
<form method="post" th:action="#{/myTable}" th:object="${requestIds}">
<table class="table ...">
<thead>
<tr>
<th><input type="checkbox" class="selectall" data-target="requests-all"/></th>
<th>Name</th>
<th>Phone</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr role="row" th:each="request : ${requests}">
<td>
<input type="checkbox" name="requestId" data-target="requests-all"
th:value="${request.id}" th:field="*{requestIds}"/>
</td>
<td th:text="${request.name}"></td>
<td th:text="${request.phone}"></td>
<td th:text="${request.email}"></td>
</tr>
</tbody>
</table>
<button class="btn btn-primary show-selected">Process</button>
</form>
...
<script>
$(document).ready(function() {
$('button').click(function(e) {
if !(confirm("Are you sure you wish to process these requests")) {
e.preventDefault();
}
});
});
</script>
...
So the answer is that name and th:field don't play nice together.
I made the following changes and it worked:
Controller
#PostMapping("/myTable")
public ModelAndView postRequests(ModelAndView mav,
#ModelAttribute("requestIds") Long[] ids) {
...
}
html
<form id="postMyTable" method="post" th:action="#{/myTable}">
<table ...
<input type="checkbox" name="requestId" data-target="requests-all"
th:value="${request.id}"/>
...
<script>
$(document).ready(function() {
$('button').click(function(e) {
if !(confirm("Are you sure you wish to process these requests")) {
e.preventDefault();
} else {
$("#postMyTable").submit();
}
});
});
</script>

How to get a list of objects from a JSP in a Controller

I have some issues with my code. I try to get a list of object from a jsp in my controller to send it to my service with a POST
When I try to get the list in my controller with the annotation #ModelAttribute it return me an empty list. Here my controller class and my jsp
Controller
#GetMapping("/OvedraftsCustomer")
public String getOverdraftsCustomers(ModelMap model){
List<AccountDTO> overdraftAccounts = overdraftService.getOverdraftAccounts();
model.addAttribute("overdraftAccounts",overdraftAccounts);
return "agios/displayOverdraftCustomers";
}
#PostMapping("/agioDetails")
public String getOverDraftDetails(#ModelAttribute("account") ArrayList<AccountDTO> account, BindingResult binding, ModelMap model) throws ParseException {
model.addAttribute("accounts",account);
logger.info("taille : " + account.size());
return "redirect:agiosInfo";
}
JSP
<table class="w3-table-all w3-hoverable">
<tr class="w3-hover-blue w3-blue">
<th>Nom</th>
<th>Prénom </th>
<th>iban</th>
<th>email</th>
<th>Découvert Autorisé</th>
<th>Découvert actuel</th>
<th>Taux débiteurs</th>
</tr>
<c:forEach items="${overdraftAccounts}" var="overdraftAccounts">
<tr class="w3-hover-blue">
<td><c:out value="${overdraftAccounts.getCustomer().getName()}" /></td>
<td><c:out value="${overdraftAccounts.getCustomer().getSurname()}" /></td>
<td><c:out value="${overdraftAccounts.getIban()}" /></td>
<td><c:out value="${overdraftAccounts.getCustomer().getEmail()}" /></td>
<td><c:out value="${overdraftAccounts.getCustomer().getAgioParameters().getAuthorizedOverdraft()}" /></td>
<td><c:out value="${overdraftAccounts.getOldBalances().get(overdraftAccounts.getOldBalances().size()-1).getBalance()}" /></td>
<td><c:out value="${overdraftAccounts.getCustomer().getAgioParameters().getBorrowingRate()}" /></td>
</tr>
</c:forEach>
</table>
</br>
</br>
<form method="POST" action="/agioDetails" modelAttribute="account">
<c:forEach var="test" items="${accounts}" varStatus="status">
<form:input path="accounts[${status.index}].getIban()" name="iban" id="iban" value="test.getIban()" />
<form:input path="accounts[${status.index}].getBalance()" name="balance" id="balance" value="test.getBalance()" />
<form:input path="accounts[${status.index}].oldBalances()" name="oldBalances" id="oldBalances" value="test.getOldBalances()" />
<form:input path="accounts[${status.index}].getCustomer()" name="customer" id="customer" value="test.getCustomer()" />
<form:input path="accounts[${status.index}].getAgios()" name="agios" id="agios" value="test.getAgios()" />
</c:forEach>
</br>
<table align="center">
<tr>
<td colspan="2"><input class="w3-button w3-padding-large w3-blue" type="submit" value="Consulter le détail"/></td>
</tr>
</table>
</form>
Currently, I am just trying to get the list in my controller from my jsp therefore I just try to see if my list is not empty in my controller. If anyone can help me with this issue and explain what i have done wrongly please..
Hi I think your way of making a post request to your controller is little bit messy, so I'll recommend that you try to do this:
First in your java Create a Entity class for your Details,
e.g.
Details.java
public class Details {
private String iban;
private Integer balance;
private Integer oldBalances;
private String customer;
private String agios;
public String getIban() {
return iban;
}
public void setIban(String iban) {
this.iban = iban;
}
public Integer getBalance() {
return balance;
}
public void setBalance(Integer balance) {
this.balance = balance;
}
public Integer getOldBalances() {
return oldBalances;
}
public void setOldBalances(Integer oldBalances) {
this.oldBalances = oldBalances;
}
public String getCustomer() {
return customer;
}
public void setCustomer(String customer) {
this.customer = customer;
}
public String getAgios() {
return agios;
}
public void setAgios(String agios) {
this.agios = agios;
}
#Override
public String toString() {
return "Details [iban=" + iban + ", balance=" + balance + ", oldBalances=" + oldBalances + ", customer="
+ customer + ", agios=" + agios + "]";
}
}
and add this id to your button"btnSubmit" and put this to your javascipt(I'm using jquery)
var details = {};
$("#btnSubmit").click(function(){
details.iban = $("#iban").val();
details.balance = $("#balance ").val();
details.oldBalances = $("#oldBalances").val();
details.customer = $("#customer ").val();
details.agios = $("#agios ").val();
$.ajax({
method: "POST",
headers: {
"Content-Type":"application/json"
},
url: "/agioDetails",
data: JSON.stringify(details ),
success: function( result ) {
alert("okay");
}
});
})
and do this to your controller
#PostMapping(value = "/agioDetails", consumes = "application/json")
ModelAndView getRecord(#RequestBody Details details) throws SQLException, Exception {
System.out.println(details);
ModelAndView mv = new ModelAndView("index");
return mv;
}
the datas should have been passed to your java cotroller without errors.

How to pass nested list element to the controller in spring mvc

In my jsp page there have a table with nested list value, i want to send that table value to the container, The outer table value were sent but the inner table value not sent to the container, I am new here please let me know how to over come this situation,
My jsp
<script>
function rowAdded(rowElement) {
//clear the imput fields for the row
$(rowElement).find("input").val('');
//may want to reset <select> options etc
//in fact you may want to submit the form
saveNeeded();
}
function rowRemoved(rowElement) {
saveNeeded();
}
function saveNeeded() {
$('#submit').css('color','red');
$('#submit').css('font-weight','bold');
if( $('#submit').val().indexOf('!') != 0 ) {
$('#submit').val( '!' + $('#submit').val() );
}
}
function beforeSubmit() {
alert('script Working');
return true;
}
$(document).ready( function() {
var config = {
rowClass : 'rule',
addRowId : 'addRule',
removeRowClass : 'removeRule',
formId : 'ruleListForm',
rowContainerId : 'ruleListContainer',
indexedPropertyName : 'ruleList',
indexedPropertyMemberNames : 'id,ruleName,parameterName,overwriteValue',
rowAddedListener : rowAdded,
rowRemovedListener : rowRemoved,
beforeSubmit : beforeSubmit
};
new DynamicListHelper(config);
});
</script>
<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="parameter" width="240">Parameter </th>
</tr>
</thead>
<tbody id="ruleListContainer">
<c:forEach items="${List2}" var="as">
<tr class="rule">
<td><input type="hidden" name="ruleList[].id" value="${as.rule.id}" /> ${as.rule.id}</td>
<td><input type="hidden" name="ruleList[].ruleName" value="${as.rule.ruleName}" /> ${as.rule.ruleName}</td>
<td> <input id="one" class="datepicker" type="text" name="ruleList[].startDate" size="11" height="0.10"></td>
<td> <input id="two" class="datepicker" type="text" name="ruleList[].endDate" size="11" height="0.10"></td>
<td>
<table border="1">
<c:forEach items="${as.ruleAssignmentParameter}" var="asss">
<tr>
<td><input type="hidden" name="ruleList[].parameterName"value="${asss.parameterName}" > ${asss.parameterName}</td>
<td><input type="hidden" name="ruleList[].overwriteValue" value="${asss.overwriteValue}" /> ${asss.overwriteValue}</td>
</tr>
</c:forEach>
</table>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<br>
<input type="submit" value="Update">
</form:form>
</html>
Here is my model class
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import com.demo.app.model.RuleAssignmentParameter;
public class RuleAssUI {
private int id;
private String ruleName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
private List<RuleAssignmentParameter> ruleAssignmentParameter = new LinkedList<RuleAssignmentParameter>();
public List<RuleAssignmentParameter> getRuleAssignmentParameter() {
return ruleAssignmentParameter;
}
public void setRuleAssignmentParameter(List<RuleAssignmentParameter> ruleAssignmentParameter) {
this.ruleAssignmentParameter = ruleAssignmentParameter;
}
public RuleAssUI(){
}
public RuleAssUI(int id,String ruleName){
this.id=id;
this.ruleName=ruleName;
}
}
My container where i store the list value
import java.util.LinkedList;
import java.util.List;
public class RuleListContainer {
private List<RuleAssUI> ruleList = new LinkedList<RuleAssUI>();
public RuleListContainer() {
}
public RuleListContainer(List<RuleAssUI> ruleList) {
this.ruleList = ruleList;
}
public List<RuleAssUI> getRuleList() {
return ruleList;
}
public void setRuleList(List<RuleAssUI> ruleList) {
this.ruleList = ruleList;
}
Controller
#RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(#ModelAttribute("SpringWeb") RuleListContainer ruleListContainer, HttpSession session, ModelMap model) {
ruleListContainer.getRuleList().size();
for (RuleAssUI rul1 : ruleListContainer.getRuleList()) {
System.out.println("Id: " + rul1.getId());
System.out.println("RuleName: " + rul1.getRuleName());
for (RuleAssignmentParameter rul2 : rul1.getRuleAssignmentParameter()) {
System.out.println("ParameterName: " + rul2.getParameterName());
System.out.println("ParameterValue: " + rul2.getOverwriteValue());
}
}
session.setAttribute("ruleListContainer", ruleListContainer);
return "hello";
}
I am trying so many time but unable to fixed the issue, And browse also but did't get any proper help, so please help to do items
I NEED HELP PLEASE SOME BODY HELP ME...!
Thank you in advance
I think the problem is in your jsp file.
You need to set the index of each list element.
<c:forEach items="${List2}" 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.ruleAssignmentParameter}" var="asss" varStatus="assignments">
<tr>
<td><input type="hidden" name="ruleList[${vs.index}].ruleAssignmentParameter[${assignments.index}].parameterName" value="${asss.parameterName}" > ${asss.parameterName}</td>
<td><input type="hidden" name="ruleList[${vs.index}].ruleAssignmentParameter[${assignments.index}].overwriteValue" value="${asss.overwriteValue}" /> ${asss.overwriteValue}</td>
</tr>
</c:forEach>
</table>
</td>
</tr>
</c:forEach>
Also in your controller (POST method) you are trying to get the object identified by "SpringWeb" but should be "ruleListContainer", same name you have in your form tag
The problem was you had a list into RuleAssUI and you was not accesing correctly, you need 2 loops and indexes, one for each list.
Here is the key:
ruleList[${vs.index}].ruleAssignmentParameter[${assignments.index}].parameterName

Getting IllegalStateException when creating dynamic Fields using Thymeleaf

In my program, I am generating dynamic form names based on the number of feedbacks I get. I am then taking the satisfaction, comment and feedbackId inputs. They are different for each iteration. This is giving me an IllegalStateException error.
My HTML form is:
<form action="#" th:action="#{/heart2heart/token/__${tokenId}__/}" method="post">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover table-condensed">
<tr>
<th style="display:none;"></th>
<th th:text="#{service.desc}">Service</th>
<th th:text="#{feedback.description}">Feedback</th>
<th th:text="#{visit.date}">Date of Visit</th>
<th th:text="#{repr.name}">FU Repr</th>
<th th:text="#{resolution.response}">Response</th>
<th th:text="#{resolution.satisfactionLevel}">Satisfaction</th>
<th th:text="#{resolution.comment}">Comment</th>
</tr>
<tr th:each="feedback, feedbackStat : *{feedbacks}">
<td style="display:none;"><input type="hidden" th:field="*{feedbacks[__${feedbackStat.index}__].feedbackId}" th:value="${feedback.id}" /></td>
<td th:text="${feedback.service.description}">Steel</td>
<td th:text="${feedback.description}">Problem</td>
<td th:text="${feedback.visits[0].date}">12/08/2015</td>
<td th:text="${feedback.visits[0].repr.fullName}">XYZ</td>
<td th:text="${feedback.receipt.resolutions[0].response}">response</td>
<td>
<div class="radio">
<label><input type="radio" th:field="*{feedbacks[__${feedbackStat.index}__].satisfaction}" th:text="#{global.yes}" value="SATISFIED">Yes</input></label>
</div>
<div class="radio">
<label><input type="radio" th:field="*{feedbacks[__${feedbackStat.index}__].satisfaction}" th:text="#{global.no}" value="NOT SATISFIED">No</input></label>
</div>
</td>
<td><textarea th:field="*{feedbacks[__${feedbackStat.index}__].comment}" class="form-control" rows="2"></textarea></td>
</tr>
</table>
<div class="form-group">
<button type="submit" name="addRow" th:text="#{button.submit}"
class="btn btn-primary btn-md">Submit</button>
</div>
</div>
</form>
My controller is:
#RequestMapping(value = "/{tokenId}/", method = RequestMethod.POST)
public String addSatisfaction(#PathVariable int tokenId, #Valid ReceiptForm receiptForm, BindingResult result, Model model) {
try {
for (SatisfactionForm satisfactionForm : receiptForm.getFeedbacks()) {
Feedback feedback = new Feedback();
feedback.setId(satisfactionForm.getFeedbackId());
Feedback feedback1 = heart2heartService.getFeedbackById(feedback);
Resolution resolution = new Resolution();
resolution.setId(feedback1.getReceipt().getResolutions().get(0).getId());
resolution.setSatisfactionLevel(satisfactionForm.getSatisfaction().name());
resolution.setComment(satisfactionForm.getComment());
heart2heartService.addSatisfaction(resolution);
model.addAttribute("success", "Satisfaction added for tokenId " + tokenId);
}
} catch (Exception e) {
logger.error("Exception :: ", e);
}
return "success2";
}
#RequestMapping(value = "/{tokenId}/", method = RequestMethod.GET)
public String getSatisfaction(#PathVariable int tokenId, Model model) {
Token token = new Token();
token.setId(tokenId);
try {
model.addAttribute("feedbacks", heart2heartService.getFeedbacksByToken(token));
} catch (Exception e) {
logger.error("Exception :: ", e);
}
return "heart2heart/closeFeedback";
}
My forms are:
public class ReceiptForm {
private List<SatisfactionForm> feedbacks = new ArrayList<SatisfactionForm>();
public List<SatisfactionForm> getFeedbacks() {
return feedbacks;
}
public void setFeedbacks(List<SatisfactionForm> feedbacks) {
this.feedbacks = feedbacks;
}
}
and
public class SatisfactionForm {
public static enum Satisfaction {
NOT_SATISFIED, SATISFIED
}
private String comment;
private int feedbackId;
private Satisfaction satisfaction;
public String getComment() {
return comment;
}
public int getFeedbackId() {
return feedbackId;
}
public Satisfaction getSatisfaction() {
return satisfaction;
}
public void setComment(String comment) {
this.comment = comment;
}
public void setFeedbackId(int feedbackId) {
this.feedbackId = feedbackId;
}
public void setSatisfaction(Satisfaction satisfaction) {
this.satisfaction = satisfaction;
}
}
I am getting the following error:
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'feedbacks[0]' available as request attribute
How do I fix this?
You did not specify the form-backing bean in your Thymeleaf template.
You are using the *{} operator to access fields of the bean, but Thymeleaf does not know
which bean you want to use. To resolve the error, add a th:object to your form.
Assuming that heart2heartService.getFeedbacksByToken(token) returns a ReceiptForm your form would look like this:
<form action="#" th:action="#{/heart2heart/token/__${tokenId}__/}" method="post" th:object="${feedbacks}">

JSP or Spring MVC controller display same info several times

I have controller which adds Computer assigned to User by admin. User can have several assigned Computers and it is implemented through Spring MVC Multiple Selection. But I’ve little issue with displaying of info after updating. It shows as many users in List of users as many computers were assigned. I think problem not in JSP and debuggers shows nothing so I’ll very appreciate your help.
Here is my AdminUserUpdateController.java
#Controller
public class AdminUserUpdateController {
#InitBinder("userForm")
private void initBinder(WebDataBinder binder) {
binder.setValidator(updateValidator);
binder.registerCustomEditor(Set.class, "computers", new CustomCollectionEditor(Set.class) {
#Override
protected Object convertElement(Object element) {
String pcName = null;
if (element instanceof String && !((String) element).equals("")) {
try {
pcName = (String) element;
Set<Computer> computerSet = new LinkedHashSet<>();
computerSet.add(computerService.getComputerByName(pcName));
new UserForm().setComputers(computerSet);
} catch (NumberFormatException e) {
logger.info("Error in element");
logger.info("Element was " + ((String) element));
}
}
return pcName != null ? computerService.getComputerByName(pcName) : null;
}
});
}
...............
#RequestMapping(value = "/adminEdit/{userId}", method = RequestMethod.GET)
public String updateView(#PathVariable("userId") Integer userId,
UserForm userForm,
ModelMap model) {
userForm.setUser(userService.getUserById(userId));
model.addAttribute("userForm", userForm);
model.addAttribute("computers", computerService.getAllComputers());
return "adminUserUpdate";
}
#RequestMapping(value = "adminEdit.do/{userId}", method = RequestMethod.POST)
public ModelAndView updateUserProcess(#ModelAttribute(value = "userForm")
UserForm userForm,
#PathVariable("userId") Integer userId,
BindingResult result, Model model) {
User user = userService.getUserById(userId);
model.addAttribute("computers", computerService.getAllComputers());
model.addAttribute("userForm", userForm);
updateValidator.validate(userForm, result);
return updatingUser(user, model, userForm);
}
private ModelAndView updatingUser(User user, Model model,
UserForm userForm) {
if (isEmailExists(userForm, user)) {
model.addAttribute("errorMsg", "Email is already in use!");
return new ModelAndView("adminUserUpdate");
}
fillForm(userForm, user);
user = userForm.getUser();
userService.updateUser(user);
return new ModelAndView("redirect:/adminPage", "user", user);
}
private void fillForm(UserForm userForm, User user) {
userForm.setUserId(user.getUserId());
userForm.setLogin(user.getLogin());
userForm.setRegDate(user.getRegDate());
// userForm.setComputers(computer);
userForm.setRole(roleService.findByName(user.getRole().getRoleName()));
}
}
And here it is my JSP
<!--BEGIN OF USERS TABLE-->
<div align="center">
<table border=1>
<thead align="center">
<tr>
<th>User Id</th>
<th>Login</th>
<th>Name</th>
<th>Password</th>
<th>Email</th>
<th>Regsiter Date</th>
<th>PC Assigned</th>
<th colspan=2>Action</th>
</tr>
</thead>
<tbody align="center">
<tr>
<c:forEach items="${members}" var="user">
<td><c:out value="${user.userId}"/></td>
<td><c:out value="${user.login}"/></td>
<td><c:out value="${user.name}"/></td>
<td><c:out value="${user.password}"/></td>
<td><c:out value="${user.email}"/></td>
<td><fmt:formatDate pattern="yyyy-MM-dd" value="${user.regDate}"/></td>
<td>
<c:choose>
<c:when test="${user.computers!= null && !user.computers['empty']}">
<c:forEach items="${user.computers}" var="comp">
<c:out value="${comp.pcName}"/>
</c:forEach>
</c:when>
<c:otherwise>
<p class="h3_error">No PC Assigned</p>
</c:otherwise>
</c:choose>
</td>
<td>Update</td>
<td>Delete</td>
</tr>
</c:forEach>
</tbody>
</table>
<br>
</div>
<!--END OF USERS TABLE-->

Categories