diacritic in jsp form - forms

we have problem with diacritic in jsp form in school project. We use Spring 3.0. In JSP form we have inputs which can contains words with diacritic (czech language,f.e "šáříěá"). When I start project and write diacritic words into these inputs and send form, immediately in controller are wrong values. Diacritic letters has strange form, for example "Ä???Ä".
Following code is our form.
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Nový prostor</title>
</head>
<body>
<h1>Nový prostor</h1>
<form:form method="POST" commandName="PLACE" >
<fieldset>
<legend>Adresa prostoru</legend>
<table>
<tr>
<td><form:label path="name">Název prostoru</form:label></td>
<td><form:input path="name" /></td>
</tr>
<tr>
<td><form:label path="street">Ulice a č.p.</form:label></td>
<td><form:input path="street" /></td>
</tr>
<tr>
<td><form:label path="zip_code">PSČ</form:label></td>
<td><form:input path="zip_code" /></td>
</tr>
<tr>
<td><form:label path="city">Město</form:label></td>
<td><form:input path="city" /></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Parametry prostoru</legend>
<table>
<tr>
<td><form:label path="rows">Počet řad</form:label></td>
<td><form:input path="rows" /></td>
</tr>
<tr>
<td><form:label path="columns">Počet sedaček v řadě</form:label></td>
<td><form:input path="columns" /></td>
</tr>
<tr>
<td><form:label path="note">Poznámky</form:label></td>
<td><form:textarea path="note" /></td>
</tr>
</table>
</fieldset>
<input type="submit" value="Vytvořit">
</form:form>
</body>
And this is conroller:
#Controller
#RequestMapping("/newPlace")
public class NewPlaceController {
#Autowired
private PlaceService placeService;
/**
* Pri pozadavku typu get vrati nazev jsp ktere se ma renderovat, nabinduje Complex place do formualre
* #param model
* #return
*/
#RequestMapping(method=RequestMethod.GET)
public String showNewPlaceForm(Model model){
model.addAttribute("PLACE", new ComplexPlace());
return "newPlaceForm";
}
/**
*Pri pozadavku POST ulozi data z formulare do DB
*
* #param place
* #param result
* #return
*/
#RequestMapping(method=RequestMethod.POST)
public String createNewPlace(#ModelAttribute(value="PLACE") ComplexPlace place, BindingResult result){
System.out.println(place.getName());
placeService.buildPlaceService(place);
placeService.PersistNewPlace();
return "/index";
}
}
System.out.println write strange value on console. Know somebody where is problem? I want remark, that we have small expirience with Java web programming.
Thanks

you can't use any other language other then standard english.if you want to do this then u have to use any standard free unicode converter.convert your character and put their unicode character at run time it is converted in your original language...i hope it works for you.

Related

Why Does My FAMILY Query Fail?

Please have a look at the following code wherein I have a method that searches by family name and another that searches by system. Following the code I have provided the results that were produced by invoking each of these two methods. You can see that the system search returned three patients, the third one having the family name Vaessen. But, when I search for the family name Vaessen a timeout results. Would someone please help me to understand why this is happening?
Note: As you can see from the timeout exception, I am querying the public fhir server http://fhirtest.uhn.ca/baseDstu3
public void findPatientsInFamily(String family) {
System.out.printf("\n\nFinding patients in family %s\n", family);
findPatients(Patient.FAMILY.matches().value(family));
}
public void findPatientsInSystem(String system) {
System.out.printf("\n\nFinding patients in system %s\n", system);
findPatients(Patient.IDENTIFIER.hasSystemWithAnyCode(system));
}
#SuppressWarnings("rawtypes")
public void findPatients(ICriterion criterion) {
try {
Bundle bundle = client.search().forResource(Patient.class).where(criterion).returnBundle(Bundle.class).execute();
for (BundleEntryComponent entry : bundle.getEntry()) {
if (entry.getResource().getResourceType() == ResourceType.Patient) {
Patient patient = (Patient) entry.getResource();
System.out.printf("%s\n", parser.encodeResourceToString(patient));
}
}
}
catch(Exception e) {
System.out.printf("Cannot find patients\n%s\n", e.getMessage());
}
}
Results for the findPatientsInSystem(String system) method:
Finding patients in system http://dmw.levy.com/mrn
<Patient xmlns="http://hl7.org/fhir">
<id value="4172808"></id>
<meta>
<versionId value="1"></versionId>
<lastUpdated value="2018-06-07T14:10:52.336+00:00"></lastUpdated>
</meta>
<text>
<status value="generated"></status>
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="hapiHeaderText">Rachael
<b>LANEHART </b>
</div>
<table class="hapiPropertyTable">
<tbody>
<tr>
<td>Identifier</td>
<td>12345</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<span>30 December 1985</span>
</td>
</tr>
</tbody>
</table>
</div>
</text>
<identifier>
<system value="http://dmw.levy.com/mrn"></system>
<value value="12345"></value>
</identifier>
<name>
<family value="Lanehart"></family>
<given value="Rachael"></given>
</name>
<gender value="female"></gender>
<birthDate value="1985-12-30"></birthDate>
</Patient>
<Patient xmlns="http://hl7.org/fhir">
<id value="4149602"></id>
<meta>
<versionId value="1"></versionId>
<lastUpdated value="2018-06-06T20:52:11.831+00:00"></lastUpdated>
</meta>
<text>
<status value="generated"></status>
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="hapiHeaderText">Ravi
<b>THAKKAR </b>
</div>
<table class="hapiPropertyTable">
<tbody>
<tr>
<td>Identifier</td>
<td>12345</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<span>14 April 1962</span>
</td>
</tr>
</tbody>
</table>
</div>
</text>
<identifier>
<system value="http://dmw.levy.com/mrn"></system>
<value value="12345"></value>
</identifier>
<name>
<family value="Thakkar"></family>
<given value="Ravi"></given>
</name>
<gender value="male"></gender>
<birthDate value="1962-04-14"></birthDate>
</Patient>
<Patient xmlns="http://hl7.org/fhir">
<id value="4013201"></id>
<meta>
<versionId value="1"></versionId>
<lastUpdated value="2018-06-01T18:30:23.902+00:00"></lastUpdated>
</meta>
<text>
<status value="generated"></status>
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="hapiHeaderText">Robert Jozef
<b>VAESSEN </b>
</div>
<table class="hapiPropertyTable">
<tbody>
<tr>
<td>Identifier</td>
<td>12345</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<span>30 January 1954</span>
</td>
</tr>
</tbody>
</table>
</div>
</text>
<identifier>
<system value="http://dmw.levy.com/mrn"></system>
<value value="12345"></value>
</identifier>
<name>
<family value="Vaessen"></family>
<given value="Robert"></given>
<given value="Jozef"></given>
</name>
<gender value="male"></gender>
<birthDate value="1954-01-30"></birthDate>
</Patient>
Results for the findPatientsInFamily(String family) method:
Finding patients in family Vaessen
Cannot find patients
Failed to parse response from server when performing GET to URL http://fhirtest.uhn.ca/baseDstu3/Patient?family=Vaessen - java.net.SocketTimeoutException: Read timed out
The way in which your code queries the FHIR Server should be fine for a Patient search by system or family name.
I tried the public test server through the UI at http://fhirtest.uhn.ca/ and everything appears to be down currently. Every request returns an error. There is already an issue posted here on GIT https://github.com/jamesagnew/hapi-fhir/issues/998.
It is also possible that when the server is back up, there may be so much patient data that your request will still error unless a large connection timeout is set, or more filter criteria is provided.

Using Indy TIdHTTP Post Method on Secure Site with Cookies

I am trying to use the TIdHTTP.Post() method to submit a form on a website that I just can't figure out. I have tried several iterations and changes to my code, and have hit a road block that I need to get help with. I am relatively new to TIdHTTP and its usage, so I beg forgiveness for anything that is just plain stupid about my code.
So far, I have been able to use the TIdHTTP.Get() method to obtain the HTML code from the site. Then I examine the <form> code within the HTML, and designed the below code to submit that form to the website.
I can't tell if my code isn't working because I am not using the Post() method correctly, or because I am not using the CookieManager correctly. All I receive is an "Internal Server Error" on execution.
Interestingly, the website to manually login requires you to enter your Account Number, Date Of Birth, and Password, but the form I see in the HTML only contains two variables for submission... Username (which is a combination of Acct and DOB, it seems) and submit. So I don't understand how/where it handles or posts the password variable?
Here is my current code in Delphi:
procedure TMSBS_App_GUI.SubmitClick(Sender: TObject);
Var
Response : String;
ResponseSet : TStringStream;
Params : TStringList;
IdHttp : TIDHttp;
IdSSL : TIdSSLIOHandlerSocketOpenSSL;
CookieMonster : TidCookieManager;
begin
Params := TStringList.Create;
Params.Add('username=' + 'username');
Params.Add('submit.value=' + 'submit');
idhttp := TIdhttp.Create;
idhttp.AllowCookies := True;
CookieMonster := TiDCookieManager.Create;
idHttp.CookieManager := CookieMonster;
idSSLOpenSSLHeaders.Load;
IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
idHttp.ReadTimeout := 30000;
idHttp.IOHandler := idSSL;
idHttp.Get('https://' + website);
idhttp.Request.ContentType := 'application/x-www-form-urlencoded';
idhttp.Request.Referer := 'http://' + website;
idSSL.SSLOptions.Method := sslvTLSv1;
idSSL.SSLOptions.Mode := sslmUnassigned;
ResponseSet := TStringStream.Create(nil);
Try
Memo1.Text := idHttp.Post('https://' + website,Params);
Finally
Params.Free;
ResponseSet.Free;
End;
end;
This is the webpage:
<!-- SiteMinder Encoding=ISO-8859-1; -->
<!-- FCC File : (generic) caloglfn.fcc version 1.4-->
<!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" />
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<link rel="stylesheet" type="text/css" href="styles.css" />
<!-- Cross-frame scripting prevention: This code will prevent this page from being encapsulated within HTML frames. Remove, or comment out, this code if the functionality that is contained in this SiteMinder page is to be included within HTML frames. -->
<SCRIPT type="text/javascript" src="https://ff.kis.v2.scr.kaspersky-labs.com/D0501246-9A02-314D-B50C-0C6D353C6332/main.js" charset="UTF-8"></script><link rel="stylesheet" crossorigin="anonymous" href="https://ff.kis.v2.scr.kaspersky-labs.com/2336C353D6C0-C05B-D413-20A9-6421050D/abn/main.css"/><script>
if (top !=self)
top.location=self.location;
</SCRIPT>
<title>Member/Pensioner Services Online Login</title>
<script>
function submit_form()
{
document.mos_form.username.value = document.mos_form.pUserID.value + document.mos_form.pDOB.value
document.mos_form.submit()
}
</script>
</head>
<body>
<div id="wrapper">
<div id="help">
<a style="border-bottom:none;" href="mso_pso_access_help.html" target="_blank"><img STYLE="border:none;" src="Help_button.png" alt="Help" align="right"> </a>
</div>
<div id="header">
<img class="crest" src="crest.png" alt="Crest - Superannuation Corporation" align="left">
<img class="logo" src="mso_pso.png" alt="Pensioner Services Online (PSO) and Member Services Online (MSO)" align="right">
</div>
<div id="toplinks">
</div>
<div id="form">
<form name="mos_form" method="POST" enctype="application/x-www-form-urlencoded" autocomplete="off">
<input type="hidden" name="autherrmsg" value="Login failed. Please try again."/>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="left">
<H1>
<span style="color: #3E842E;">Member Access</span>
</H1>
</td>
</tr>
<tr>
<td>
<p><font color="red"> </font></p>
<p>
To gain access to the complete range of online services, please enter your Membership Number, Date of Birth and Password below.
</p>
<p> If you need any help, click on Help in the top right-hand corner of this screen.</p>
<p> </p>
</td>
</tr>
</table>
<label for="hidden_username"></label>
<input type="hidden" name="username">
<label for="hidden_url"></label>
<input type="hidden" name="url" value="<ERROR_INFORMATION>" READONLY>
<label for="hidden_proxy"></label>
<input type="hidden" name="proxypath" value="<PROXY_PATH>">
<table width="900" border="0">
<tr height="38" valign="top">
<td width="200px" align="right" > <label for="mem_num" id="mem_num_label">Membership Number </label> </td>
<td width="200px" > <input id="pUserID" type="text" name="pUserID" value="" size="27" maxlength="13" id="mem_num"> </td>
<td width="500px">
<img STYLE="border:none;" src="mso_pso_question.png" onmouseover="this.style.cursor = 'help';"
title="Please enter your Membership Number.
This is either your Employment Number or Pension Reference Number as found on our correspondence to you.
If this is not available please Contact us.">
</td>
</tr>
<tr height="38" valign="top">
<td width="200px" align="right" > <label for="dob" id="dob_label">Date of Birth </label> </td>
<td width="200px" > <input type="text" name="pDOB" value="" size="27" maxlength="8" id="dob" placeholder="DDMMYYYY"> </td>
<td width="500px">
<img STYLE="border:none;" src="mso_pso_question.png" onmouseover="this.style.cursor = 'help';"
title="Please enter your date of birth in this format: DDMMYYYY (e.g. 01021955).">
</td>
</tr>
<tr height="38" valign="top">
<td width="200px" align="right" > <label for="acc_num" id="acc_num_label">Password</label> </td>
<td width="200px"> <input type="PASSWORD" name="password" value="" size="27" maxlength="30" id="acc_num"> </td>
<td width="500px">
<img STYLE="border:none;" src="mso_pso_question.png" onmouseover="this.style.cursor = 'help';"
title='Please enter your Password.
If you have forgotten your Password, use the &#34I&#39ve forgotten my password&#34 link to reset your access credentials.
If you need to contact us, our details are available via the contact us button at the top right-hand corner of this screen.'>
</td>
</tr>
</tr>
<tr height="38" valign="top">
<td width="200px" width=200></td>
<td width="200px" align="right"> I've forgotten my password </td>
<td width="500px">
</tr>
<tr height="38" valign="top">
<td colspan=2 align="right"> Register&nbsp&nbsp <input type=button onclick=javascript:submit_form() value=Login> </td>
</tr>
<tr>
</table>
<script language="JavaScript">
<!-- the script here sets the focus on UserID field
document.mos_form.pUserID.focus();
document.mos_form.pUserID.select();
function enter(e)
{
if (navigator.appName == "Netscape")
whichASCII = e.which;
else
whichASCII = event.keyCode
if (whichASCII == 13 )
{
submit_form();
}
}
document.onkeypress = enter;
if (navigator.appName == "Netscape")
document.mos_form.pAccessCode.onkeypress = enter;
// End of script -->
</script>
<!-- SiteMinder Variables START -->
<input type=hidden name=target value="http://website">
<input type=hidden name=smauthreason value="0">
<input type=hidden name=smagentname value="boFynyFE9jczy7ra1lzqLmXPeVc9xLptAWQSI9ksks1Hx/oGQmJxQA7Fy25/Xt9X">
<!-- SiteMinder Variables END -->
</FORM>
</div>
<div id="footer">
<table width=100% border=0 cellspacing="0" cellpadding="0">
<tr>
<td height="30px" align="left" valign="middle" bgcolor="#3E842E">
Privacy |
Disclaimer
</td>
</tr>
<tr>
<td height="30px" colspan="2" valign="top" bgcolor="#949599" class="footer"><p class="footer"><span class="bold">Superannuation Company</span> ABN: ## ### ### ### AFSL: ###### RSEL: L#######<br /></td>
</tr>
</table>
</div>
</div>
<!--<script>
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[[]]/g, "\$&");
var regex = new RegExp("[#&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/+/g, " "));
}
document.getElementById('pUserID').value = getParameterByName('id');
</script> -->
</body>
</html>
And here is the Wireshark packet for the POST request:
Hypertext Transfer Protocol
POST /live/red_lojson/100eng.json?sh=0&ph=1383&ivh=928&dt=2720&pdt=214&ict=&pct=1&perf=widget%7C214%7C16%2Clojson%7C1027%7C656%2Csh%7C1031%7C0%2Csh%7C1035%7C16&rndr=render_toolbox%7C1375&cmenu=null&ppd=4&ppl=4&fbe=&xmv=0&xms=0&xmlc=0&jsfw=
Request Method: POST
Request URI [truncated]: /live/red_lojson/100eng.json?sh=0&ph=1383&ivh=928&dt=2720&pdt=214&ict=&pct=1&perf=widget%7C214%7C16%2Clojson%7C1027%7C656%2Csh%7C1031%7C0%2Csh%7C1035%7C16&rndr=render_toolbox%7C1375&cmenu=null&ppd=4&ppl=4&fbe=&xmv=
Request Version: HTTP/1.1
Host: m.addthis.com\r\n
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0\r\n
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n
Accept-Language: en-US,en;q=0.5\r\n
Accept-Encoding: gzip, deflate\r\n
Referer: http://website/\r\n
Content-Length: 0\r\n
Content-Type: text/plain;charset=UTF-8\r\n
Cookie: na_tc=Y; uid=597293e6c72cb3be; na_id=2017072123300513069970337317; uvc=27%7C47%2C4%7C48%2C0%7C49%2C10%7C50%2C3%7C51; loc=MDAwMDBPQ0FVTlMxNDYxMzMxMjAwMDAwMDAwVg==; mus=0; ssc=pinterest%3B1%2Cgoogle%3B1\r\n
Connection: keep-alive\r\n
\r\n
The POST request you showed from Wireshark does not match the HTML you showed. In fact, that POST request is not even an HTML webform submission at all.
You don't need to create your own TIdCookieManager object, TIdHTTP can create one internally for you. And, for that matter, TIdHTTP can create the TIdSSLIOHandlerSocketOpenSSL object for you, too.
Also, you are leaking the CookieMonster and IdSSL objects (unless you are running this code on an ARC platform).
In any case, you are not filling in the TStringList correctly, not even close. You have to add an entry for every <input> field in the <form> that has a name and non-blank value. That includes all of the hidden fields, fields assigned by scripts, etc. Failing to do this can easily cause an "Internal Server Error" failure. You are providing a value for only 1 of the 10 input fields that the HTML form defines.
Based on the HTML you showed, try this instead:
procedure TMSBS_App_GUI.SubmitClick(Sender: TObject);
var
Params : TStringList;
IdHttp : TIdHTTP;
UserID, DOB, Password, AgentName, Response: String;
begin
IdSSLOpenSSL.LoadOpenSSLLibrary;
UserID := ...;
DOB := ...;
Password := ...;
IdHttp := TIdHTTP.Create;
try
IdHttp.AllowCookies := True;
IdHttp.ReadTimeout := 30000;
IdHttp.HandleRedirects := True;
//IdHttp.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(IdHttp);
Response := IdHttp.Get('https://' + website);
// I *suspect* the following value is randomly
// generated when the HTML is requested. If
// so, you will have to parse it out each time...
AgentName := 'boFynyFE9jczy7ra1lzqLmXPeVc9xLptAWQSI9ksks1Hx/oGQmJxQA7Fy25/Xt9X';
Params := TStringList.Create;
try
Params.Add('autherrmsg=Login failed. Please try again.');
Params.Add('username=' + UserID + DOB);
Params.Add('url=<ERROR_INFORMATION>');
Params.Add('proxypath=<PROXY_PATH>');
Params.Add('pUserID=' + UserID);
Params.Add('pDOB=' + DOB);
Params.Add('password=' + Password);
Params.Add('target=http://website');
Params.Add('smauthreason=0');
Params.Add('smagentname=' + AgentName);
IdHttp.Request.Referer := 'http://' + website;
Response := IdHttp.Post('https://' + website, Params);
Memo1.Text := Response;
finally
Params.Free;
end;
finally
IdHttp.Free;
end;
end;

Selenium Webdriver_Not able to click on link given into column

I'm a beginner and I'm trying to write a Selenium web driver. I'm using eclipse and trying to locate a link available in next column. In each row I have different link. For example in my employee data table I have 2 columns and 10 rows in one page. The first column contains the name of person and second column contains its employee ID (ID is a hyperlink). I'm trying to select the hyperlink of any employee but I'm not able to do it.
I have below the HTML code and sample script.
<span id="37">
<div class="clear"></div>
<div id="FC_Schema.1021.WIP" type="DataCheckingList" name="FC_Schema.1021.WIP">
<input id="baseurl" type="hidden" value="/Web/" name="baseurl">
<input id="hdnDcCnt" type="hidden" value="13" name="hdnDcCnt">
<input id="PageNo" type="hidden" value="1" name="PageNo">
<meta content="width=device-width" name="viewport">
<style type="text/css">
<div id="DataCheckingLoad">
<div id="SupplyChainTabs">
<div id="gbo" class="InnerAlertsTabs">
<table id="one" class="draggable" width="100%">
<thead>
<tbody>
<tr>
<td valign="top" align="center">
<td valign="top">
<td valign="top">
<a onclick="return ButtonClick(this,'TxnyD.Communities.2.1','Org.2000476_Product.THQS|SMS|Questionnaire.WIP_Questionnaire_TxnyD.Communities.2.1_THQS_TxnyD.Operationaloffice.1.2');" href="#f">Axiom
Process LLC</a>
<div class="country-name">
<div class="CompanyInfoContactLinks">
</td>
<td valign="top">
THQS
<div class="clear"> </div>
<a id="Org.2000476_Product.THQS|SMS|Questionnaire.WIP_Questionnaire_TxnyD.Communities.2.1_THQS_TxnyD.Operationaloffice.1.2" onclick="RedirectToQuestionnairePage(id)" href="#">THQS</a>
<div class="clear"> </div>
</td>
In the above code first column contains company name i.e "Axiom
Process LLC" and second column contains company subcription name i.e."THQS". I have to select the THQS link of company "Axiom Process LLC"
Selenium script designed for it as below
public static void main(String[] args) throws Exception {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://XXX.XXX.XXX.XXX/Web");
Thread.sleep(1000);
driver.findElement(By.xpath("//input[#id='UserName']")).sendKeys("Gbouser.1");
driver.findElement(By.xpath("//input[#id='Password']")).sendKeys("****");
driver.findElement(By.xpath("//input[#name='Login']")).click();
driver.findElement(By.xpath("//a[contains(text(),'Task')]")).click();
driver.findElement(By.xpath("//a[contains(text(),'Data Checking')]")).click();
driver.findElement(By.partialLinkText("Axiom")).findElement(By.xpath("//a[contains(text(),'THQS')]")).click();
}
So basically these are dynamic tables and each time it will have different records. How can select the link available in column?
I also tried below script as well:
driver.findElement(By.name("*[id^='CLS'][id$='Demolition Limited']")).findElement(By.xpath("//a[contains(text(),'THQS')])[3]")).click();
welcome to Stackoverflow. Before answering your question, just a few pointers. Think that you had a downvote 'cause you didn't format your question well. Otherwise a perfectly legal question, and you would receive help much earlier.
Secondly, don't ever put the real Web site address, username and password :). I was able to login, and understand exactly what you need, but a malicious guy could do bad wonders there.
To answer your question, instead of the line that is causing you problems, try this
Thread.sleep(3000);
TablePageObject tablePageObject = PageFactory.initElements(driver, TablePageObject.class);
tablePageObject.clickLink("Axiom");
Where TablePageObject is
public class TablePageObject {
private WebDriver driver;
#FindBy(css = "table tr")
private List<WebElement> allTableRows; // find all the rows of the table
public TablePageObject(WebDriver driver) {
this.driver = driver;
}
public void clickLink(String companyName) {
for(WebElement row : allTableRows) {
List<WebElement> links = row.findElements(By.cssSelector("a"));
// the first link by row is the company name, the second is link to be clicked
if (links.get(0).getText().contains(companyName)) {
links.get(3).click();
}
}
}
}
An explanation, TablePageObject class will be your programmatic handle for the dynamic table you're trying to control. It follows a page factory pattern of selenium, which I heartly recommend, and you can learn more here https://code.google.com/p/selenium/wiki/PageFactory
It basically keeps a collection of rows of your table, which more or less looks like:
<tr>
<td valign="top" align="center">
// irelevant
</td>
<td valign="top">
// irelevant
</td>
<td valign="top">
<a>Axiom Process LLC</a>
<a>company details</a>
<a>web details</a>
</td>
<td valign="top">
<a>THQS</a>
</td>
<td valign="top" align="center" style="display: none">
// irelevant
</td>
<td valign="top">
//irelevant
</td>
<td valign="top">
// irelevant
</td>
<td valign="top">
</td>
<td>
</td>
</tr>
You collect all the links from the table, check the company name against the first link, and if matched, click the fourth link,
Hope it helps, best,
by the way, I've masked your password in the question

How can a submittable online form recognize ( \t ) & ( \n ) delimiters and skip <input>'s when using copy-paste from Excel?

[[UPDATED AGAIN]] And I am sorry if this question gets wordy.
I am a hobby coder, and I am looking for some help with syntax and functionality within javaScript which will allow copied delimiters such as "\t" and "\n" to skip appropriate <input>'s in an online form.
I think I am about 33% there right now (again: hobby coder - self taught wanna be)
<script type="text/javascript">
function splitInput()
{
var x=document.forms["simpleForm02"]["dataInput_0"].value;
var delimiterT = x.split("\t");
var delimiterN = x.split("\n");
for (var i=0;i<delimiterT.length;i++)
if (x.indexOf("\t") >-1)
{
document.getElementById("dataInput_" + i ).value = (delimiterT[i]);
}
else
for (var i=0;i<delimiterN.length;i++)
if (x.indexOf("\n") >-1)
{
document.getElementById("dataInput_" + (i * 3) ).value = (delimiterN[i]);
}
}
</script>
<form name="simpleForm02">
<table>
<tr>
<th>Color</th>
<th>Model</th>
<th>Qty</th>
</tr>
<tr>
<td><input class="colorInput" id="dataInput_0" name="colorInput_row_1" value="" onKeyUp="splitInput()"></td>
<td><input class="modelInput" id="dataInput_1" name="modelInput_row_1" value="" onKeyUp=""></td>
<td><input class="qtyInput" id="dataInput_2" name="qtyInput_row_1" value="" onKeyUp=""></td>
</tr>
<tr>
<td><input class="colorInput" id="dataInput_3" name="colorInput_row_2" value="" onKeyUp=""></td>
<td><input class="modelInput" id="dataInput_4" name="modelInput_row_2" value="" onKeyUp=""></td>
<td><input class="qtyInput" id="dataInput_5" name="qtyInput_row_2" value="" onKeyUp=""></td>
</tr>
<tr>
<td><input class="colorInput" id="dataInput_6" name="colorInput_row_3" value="" onKeyUp=""></td>
<td><input class="modelInput" id="dataInput_7" name="modelInput_row_3" value="" onKeyUp=""></td>
<td><input class="qtyInput" id="dataInput_8" name="qtyInput_row_3" value="" onKeyUp=""></td>
</tr>
</table>
</form>
This code kinda works, in a limited way. If I copy three excel cells aligned side by side, and paste it into <input class="colorInput" id="dataInput_0" name="colorInput_row_1" value="" onKeyUp="splitInput()">, then the script correctly splits and pastes the contents of the three cells across the top three inputs.
However, I obviously have flaws in the script because it doesn't recognize the '\n' delimiter at all. And I also know that I have coding issues with the circumstance: applying the code to all cells relatively, and not just ["dataInput_0"].
And lets presume I had the following data in an Excel sheet:
I am trying to find functionality that if I copied the Excel sample data above, it would overwrite/write the top 6 of the inputs in the sample <form name="simpleForm">.
Sorry to be long winded.
So, this question has been up for about a week, and during that time I have continued to look for ideas and help.
The solution which has presented to finest potential, but not a complete solution is via the code below:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<script>
function splitInput() {
var x = document.forms["simpleForm02"]["dataInput_0"].value;
if (x.indexOf('\t') > 0) {
var delimiterT = x.split('\t');
for (var i = 0; i < delimiterT.length ; i++)
document.getElementById("dataInput_" + i).value = (delimiterT[i]);
}
else
if (x.indexOf('\n') > 0) {
var delimiterN = x.split('\n');
var j = 0;
for (var i = 0; i < delimiterN.length ; i++) {document.getElementById("dataInput_" + j).value = (delimiterN[i]);
j += 4;
}
}
else
return false;
}
function classFocused() {
var d = document.getElementById("dataInput_0");
d.className = d.className + " InFocus";
}
function classBlured() {
var d = document.getElementById("dataInput_0");
d.className = "inputArea";
}
</script>
<form name="simpleForm02">
<table>
<tr>
<th>Color</th>
<th>Model</th>
<th>Qty</th>
<th>Cost</th>
</tr>
<tr>
<td>
<textarea data-id="0" class="inputArea colorInput" id="dataInput_0" name="colorInput_row_1" onFocus="classFocused();" onBlur="classBlured();" onKeyUp="splitInput();"></textarea>
</td>
<td>
<textarea data-id="1" class="inputArea modelInput" id="dataInput_1" name="modelInput_row_1" onkeyup="" ></textarea></td>
<td>
<textarea data-id="2" class="inputArea qtyInput" id="dataInput_2" name="qtyInput_row_1" onkeyup="" ></textarea></textarea></td>
<td>
<textarea data-id="3" class="inputArea costInput" id="dataInput_3" name="costInput_row_1" onkeyup="" ></textarea></td>
</tr>
<tr>
<td>
<textarea data-id="4" class="inputArea colorInput" id="dataInput_4" name="colorInput_row_2" onkeyup="splitInput()" ></textarea></td>
<td>
<textarea data-id="5" class="inputArea modelInput" id="dataInput_5" name="modelInput_row_2" onkeyup="" ></textarea></td>
<td>
<textarea data-id="6" class="inputArea qtyInput" id="dataInput_6" name="qtyInput_row_2" onkeyup="" ></textarea></td>
<td>
<textarea data-id="7" class="inputArea costInput" id="dataInput_7" name="costInput_row_2" onkeyup="" ></textarea></td>
</tr>
<tr>
<td>
<textarea data-id="8" class="inputArea colorInput" id="dataInput_8" name="colorInput_row_3" onkeyup="splitInput()" ></textarea></td>
<td>
<textarea data-id="9" class="inputArea modelInput" id="dataInput_9" name="modelInput_row_3" onkeyup="" ></textarea></td>
<td>
<textarea data-id="10" class="inputArea qtyInput" id="dataInput_10" name="qtyInput_row_3" onkeyup="" ></textarea></td>
<td>
<textarea data-id="11" class="inputArea costInput" id="dataInput_11" name="costInput_row_3" onkeyup="" ></textarea>
</td>
</tr>
</table>
</form>
</body>
</html>
In the above example of the textarea's, if a '\t' delimiter exists then the split is made and the data is spread over the course of the data's inherit length.
Also, in the above example of the text areas, if a '\n' delimiter exists then the split is made and the data is spread over the course of the data's inherit length vertically instead. The statement: "j += 4" is in essence the number of columns you have in the form.
Though I still need for it to work across all text area inputs, not just the identified as ["dataInput_0"]. A jQuery $(this) identifier maybe?
Also, the coding is limited because if you copy and paste cells which have both \t and \n, then the code doesn't work.
But it is a step in the right direction.

Issue Binding AutoPopulating List to a form Spring MVC

I have an issue binding the AutoPupulating List in a form to update the data. I was able to save the data using Autopopulating list though.
Here is the form backing model.
public class AddUpdateShot {
private Integer shootId;
private char shotSelect;
private String shotNotes;
private Integer numOfItems;
private AutoPopulatingList itemNumColors;
private Integer totalNumOfItems;
private String shotName;
----------
public void setItemNumColors(AutoPopulatingList itemNumColors){
this.itemNumColors = itemNumColors;
}
public AutoPopulatingList getItemNumColors(){
return this.itemNumColors;
}
--------
}
Where itemNumClors is a simple model
public class ItemNumColor {
private Integer id;
private Integer itemNum;
private String itemName;
private String colorCode;
private String colorName;
------get and set methods
}
When I first saved the data, depending on how many ItemColors the user wanted,using jquery I added the input fields dynamically as shown in the following code.
<form:form id="createShootForm" method="POST"
commandName="createShoot">
<tr>
<td align="left"><label for="shootName">*Shoot Name:</label></td>
<td><form:input id="shootName" class="required" path="shootName" /></td>
</tr>
------- other input fields in form backing obj----
<c:forEach var="i" begin="${start}" end="${end-1}" step="1" varStatus="status">
<tr>
<td align="left"><label for="itemNumber${i}">Item
Number${i+1}:</label></td>
<td><form:input id="itemNumber${i}"
path="createShoot.itemNumColors[${i}].itemNum" /></td>
<td><form:select id="color${i}"
path="createShoot.itemNumColors[${i}].colorCode">
<form:option value="" label="Color" />
</form:select>
</td>
</tr>
</c:forEach>
<tr id="submitRow">
<td></td>
<td></td>
<td align="right"><input name="submit" type="submit" value="Next" /></td>
</tr>
</table>
</form:form>
The above code worked perfectly fine when I initially saved the data. But now when the user want to update the earlier saved data, I am unable to bind the Autopopulating list to the JSP. Here is how am doing it.
<form:form id="updateShotForm" method="POST"
commandName="shotToUpdate">
----other input fields of form backing object---
<c:forEach var="i" begin="0" end="${totalNumOfItems-1}" step="1"
varStatus="status">
<tr><td align="left"><label for="itemNumber${i}">ItemNumber${i+1}:</label></td>
<td><form:input id="itemNumber${i}"path="shotToUpdate.itemNumColors[${i}].itemNum" /></td>
</tr>
</c:forEach>
<tr id="submitRow">
<td></td>
<td></td>
<td align="right"><input name="submit" type="submit"
value="Next" />
</td>
</table>
</form:form>
When I open the edit JSP, I get the following run time exception
Sep 7, 2011 10:38:00 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jalapeno] in context with path [/OnLocation] threw exception [An exception occurred processing JSP page /WEB-INF/views/app/updateShot.jsp at line 256
253: <tr>
254: <td align="left"><label for="itemNumber${i}">Item
255: Number${i+1}:</label></td>
256: <td><form:input id="itemNumber${i}"
257: path="shotToUpdate.itemNumColors[${i}].itemNum" /></td>
258: <td><form:select id="color${i}"
259: path="shotToUpdate.itemNumColors[${i}].colorCode">
Stacktrace:] with root cause
org.springframework.beans.NotReadablePropertyException: Invalid property 'shotToUpdate' of bean class [com.jcrew.jalapeno.app.model.AddUpdateShot]: Bean property 'shotToUpdate' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:707)
at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:555)
at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:532)
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:697)
at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:98)
at org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:224)
at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:120)
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174)
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194)
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:160)
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:123)
at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:408)
at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:140)
at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
I am not sure why I am not able to bind the object this way to the form since my form backing object does have an Autopopulating List which I initialised in the controller before loading this form
AutoPopulatingList itemNumColors = new AutoPopulatingList(ItemNumColor.class);
for( OnLocShotItemNumber onLocItemNumColor : itemNumColorsList){
ItemNumColor itemColor = new ItemNumColor();
itemColor.setId(onLocItemNumColor.getId());
itemColor.setColorCode(onLocItemNumColor.getItemColorCode());
itemColor.setItemNum(onLocItemNumColor.getItemNumber());
itemNumColors.add(itemColor);
}
shotToUpdate.setItemNumColors(itemNumColors);
model.put("shotToUpdate", shotToUpdate);
model.put("totalNumOfItems", itemNumColorsList.size());
Any help is greatly appreciated.
Thanks,
Shravanthi
Remove the 'shotToUpdate.' keyword from the PATH attribute. You have already specified the command object name so the PATH attributes should be relative to the command object.