Starting tag <td> not closed? - java

Please have a look at the below code:
<table border="0" width="100%" id="id1">
<tr>
<td width="15%" nowrap>
<Label class="someClass"> Testing </Label>
</td>
//Error complaining at below line
<td width="30%" class="someClass" nowrap>
<html-el:text styleClass="Test" property="someProperty" size="30" maxlength="10"/>
</td>
</tr>
</table>
For the first td I've closed it but at the second td it's complaining IWAK0061E Start tag() not closed.
May I know what's wrong?

I don't know why you use such weird html syntax ,however I would use:
<table border="0" width="100%" id="id1">
<tr>
<td width="15%">
<Label class="some class"> Testing </Label>
</td>
<td width="30%" class="some class">
<textarea property="some property" maxlength="10" class="some class"></textarea> // all visual stuff is used with class tag
<input property="some property" maxlength="10" class="some class"> // or input with one line field
</td>
</tr>
</table>
Also, nowrap attribute is not supported in HTML5. Use CSS instead.

Related

Spring Boot, Thymeleaf Form Error => i want edit line selected from table

I want to edit a row of a table in another html page.
I have a beginner with thymeleaf and Spring MVC...
profilesAll.html
but, i have this error :
org.thymeleaf.exceptions.TemplateProcessingException: Error during execution of processor 'org.thymeleaf.spring5.processor.SpringInputRadioFieldTagProcessor' (template: "profilsAll" - line 39, col 26)
....
Caused by: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'profil' available as request attribute
ProfilsAll.html :
<form th:action="#{/profiles/update}" th:object="${profil}" method="POST">
<table border="1">
<thead>
<tr>
<th>Select</th>
<th>UID</th>
<th>SIP</th>
<th>enterpriseVoiceEnabled</th>
<th>voicePolicy</th>
<th>dialPlan</th>
<th>samAccountName</th>
<th>exUmEnabled</th>
<th>exchUser</th>
<th>objectClass</th>
<th>statusProfile</th>
</tr>
</thead>
<tbody>
<tr th:if="${skypeProfiles.empty}">
<td colspan="2"> No skype profile available </td>
<tr th:each="skypeProfile, profile:${skypeProfiles}">
<td>
<input type="radio" th:field="*{profile}" th:value="${profile}" />
</td>
<td th:text=${skypeProfile.collaboraterId}>UID</td>
<td th:text=${skypeProfile.SIP}>SIP</td>
<td th:text=${skypeProfile.enterpriseVoiceEnabled}>enterpriseVoiceEnabled</td>
<td th:text=${skypeProfile.voicePolicy}>voicePolicy</td>
<td th:text=${skypeProfile.dialPlan}>dialPlan</td>
<td th:text=${skypeProfile.samAccountName}>samAccountName</td>
<td th:text=${skypeProfile.exUmEnabled}>exUmEnabled</td>
<td th:text=${skypeProfile.exchUser}>exchUser</td>
<td th:text=${skypeProfile.objectClass}>objectClass</td>
<td th:text=${skypeProfile.statusProfile}>statusProfile</td>
</tr>
</tbody>
</table>
<button type="submit" value ="Edit">Edit</button>
</form>
Controller :
#PostMapping("profiles/update")
public String profilesUpdate(#ModelAttribute("profil") SkypeProfileSearchBean skypeProfile) {
System.out.print("skypeProfile id "+skypeProfile.getCollaboraterId());
return "profilsUpdate";
}
This code is problematic but I did not find the solution :
<input type="radio" th:field="*{profile}" th:value="${profile}" />
Thank you very much for your help
You don't need to have two instances of skypeProfiles to use one in object and display one. Just having one instance would be enough.
Ref - https://www.baeldung.com/spring-boot-crud-thymeleaf
replace <tr th:each="skypeProfile, profile:${skypeProfiles}">
with <tr th:each="skypeProfile : ${skypeProfiles}">
and <input type="radio" th:field="*{profile}" th:value="${profile}" />
with <input type="radio" th:field="*{skypeProfile}" th:value="${skypeProfile}" />

Finding the idNumber element from this below HTML code

<div id="rightContent" style="display: inline-block; width: 700px; vertical-align: top;">
<div>
<h1><em class="SomethingHeading">Something</em></h1>
</div>
<div class="content scaffold-list" role="main">
<h1>Search</h1>
<form action="/SomethingArchiveUI/search/search" method="post">
<table>
<tbody>
<tr>
<td>ID/Registration Number:</td>
<td>
<**input type="text" name="idNumber" maxlength="20" value="" id="idNumber"**>
</td>
</tr>
<tr>
<td>Client Name:</td>
<td>
<input type="text" name="clientName" maxlength="50" value="" id="clientName">
</td>
</tr>
<tr>
<td>Client Surname:</td>
<td>
<input type="text" name="clientSurname" maxlength="50" value="" id="clientSurname">
</td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" name="_dateRange"><input type="checkbox" name="dateRange" value="true" id="dateRange"><label for="dateRange"> Use date range?</label>
</td>
</tr>
<tr>
<td colspan="2"><p>From: <input type="text" name="fromDate" value="" maxlength="10" id="fromDate" class="hasDatepicker"> To: <input type="text" name="toDate" value="" maxlength="10" id="toDate" class="hasDatepicker"></p></td>
</tr>
</tbody>
</table>
<div style="display: inline;">
<div id="divSubmit">
<input type="submit" name="cmdSearch" class="buttons" value="Search" id="cmdSearch">
</div>
<div id="divBusy" style="display: none;">
Busy Searching...
</div>
</div>
</form>
<table id="customerIdentificationList" style="display: block;">
</table>
<div id="loadingMessage" style="display: none;">
Loading. Please wait.
</div>
</div>
</div>
I used this code below for logging into the Application, but similar code doesn't seem to work on this form above. I'm trying to find the 'idNumber' element:
driver.findElement(By.xpath("//*[#id='idnumber']")).sendKeys("Username");
driver.findElement(By.xpath("//*[#id=\'password\']")).sendKeys("Password");
driver.findElement(By.xpath("//*[#id=\'submit\']")).click();
The error i get is: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":
Looking forward to your responses.
Use : .//input[#id='idnumber']
Why not just use By.id()?
driver.findElement(By.id("idNumber"));
I don't know the reason why you can't use By.id() or By.xpath in this case. But you can try to find the input using text in previous td. I hope next code will help:
driver.findElement(By.xpath("//td[text()='ID/Registration Number:']/following-sibling::td/input")).sendKeys("Username");
Try using the below way -
First get the root element and keep it to a WebElement object. Then find for input element idNumber
WebElement elem = driver.findElement(By.cssSelector("#rightContent > div.content.scaffold-list > form"));
elem.findElement(By.id("idNumber")).sendKeys("Username");

getting null values for textbox for selected checkbox in a row while sending from jsp to servlet

<c:forEach var="product" items="${list}">
<tr>
<td align="center"><%-- <input type="hidden"
value="${product.productId}" name="id"> --%> <c:out
value="${product.productName}" /></td>
<td align="center"><c:out value="${product.productPrice}" /></td>
<td align="center"><input type="text" name="quantity<c:out value="${product.productId}" />"
value="<%=1%>" /></td>
<td align="center"><input type="checkbox" name="selectedItems"
value="<c:out value=" ${product.productId}"/>"/></td>
</tr>
</c:forEach>
getting null value for quantity for particular selected row by checkbox in servlet
The problem is in line name="quantity<c:out value="${product.productId}" />". Try changing to name='quantity<c:out value="${product.productId}" />' if your intention is to have name, e.g. like name=quantity1, name=quantity2, etc.
Or alternatively set the value of the quantity as ${product.productId}, e.g.
<td align="center"><input type="text" name="quantity" value='<c:out value="${product.productId}" />' /></td>
Update:
Try to simplify your problem before jumping into the loop.
Now are you able to process this as JSP POST form and see if you are able retrieve a value out of quantity?
<tr>
<td align="center"><input type="text" name="quantity" value="some default value before user overrides this" /></td>
</tr>

values are not getting display in jsp

I started learning jsp and I have written a form.jsp which contains some fields, and I have another page called formResult.jsp.
I am trying to display the value of form.jsp to formResult.jsp using El(Expression Language).
I dont know what is wrong with my code, the value are not getting populated from form.jsp to formResult.jsp except fName(First Name).
This is very annoying and abnormal. I don't know what to do.
Please help me.
form.jsp
<form action="formResult.jsp">
<fieldset>
<legend>
<font face="Courier New" size="+1"
color="red">
Please enter your information
</font>
</legend>
</fieldset>
<table>
<tr>
<td>First Name:</td>
<td><input type="text" name="fName"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lName"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email">
</tr>
<tr>
<td>Address</td>
<td><textarea rows="3" cols="20" name="address"></textarea>
</tr>
<tr>
<td><input type="submit" value="SUBMIT"></td>
</tr>
</table>
</form>
With all the possible way I tried. the bellow three ways are not working.I am just getting the first value
formResult.jsp
<body>
First Name :${param.fName}<br>
Last Name :${param.lName}<br>
Email :${param.email}<br>
Address :${param.address}<br>
First Name :${param["fName"]}<br>
Last Name :${param["lName"]}<br>
Email :${param["email"]}<br>
Address :${param["address"]}<br>
First Name :${param[0]}<br>
Last Name :${param[1]}<br>
Email :${param[2]}<br>
Address :${param[3]}<br>
</body>
Input
Output

Jump between dynamic textfield

I want to jump between textfields, but these fields are generated dynamically through an iterator from struts-tags:
<s:iterator value="aList">
<td width="50px" align="center">
<s:textfield name="solField" size="2" maxlength="1" style="text-transform: uppercase; text-align:center"/>
</td>
</s:iterator>
I tried jumping with javascript but having the same field name is not working properly.
The code in the browser is (with three items in the list to iterate):
<td width="50px" align="center">
<input type="text" name="solField" size="2" maxlength="1" value="" id="correct_solField" style="text-transform: uppercase; text-align:center"/>
</td>
<td width="50px" align="center">
<input type="text" name="solField" size="2" maxlength="1" value="" id="correct_solField" style="text-transform: uppercase; text-align:center"/>
</td>
<td width="50px" align="center">
<input type="text" name="solField" size="2" maxlength="1" value="" id="correct_solField" style="text-transform: uppercase; text-align:center"/>
</td>
Any ideas?
Thanks in advance
How about this? (using jQuery)
$(document).on('keyup', 'input', function(){
if($(this).val().length >= $(this).attr('maxlength'))
{
$(this).nextAll('input:first').focus();
// OR even
// $(this).next('input').focus();
}
});
Is that what you're looking for? http://fiddle.jshell.net/C3jeY/

Categories