I use ibatis. And below is my query.
<select id="mnote" parameterClass="Map" resultMap="ContentStatismnote">
SELECT
NVL(DAY, 'TOTAL') DAY
, SUM(A), SUM(B), SUM(C)
FROM
(
SELECT Z.*
FROM TABLE Z
where b.day between to_char(to_date('#startDt#'), 'yyyy.mm.dd') and to_char(to_date('#endDt#'), 'yyyy.mm.dd')
)
GROUP BY ROLLUP(DAY);
And JSP page is this:
<colgroup>
<col style="width:25%;"/>
<col style="width:25%;"/>
<col style="width:25%;"/>
<col style="width:25%;"/>
</colgroup>
<thead>
<tr>
<th>DAY</th>
<th>A</th>
<th>B</th>
<th>C </th>
</tr>
</thead>
<tbody>
<br><c:forEach var="contentStatis" items="${resultCount}" >
<tr>
<td align="center"><c:out value="${contentStatis.day}" /></td>
<td align="center"><c:out value="${contentStatis.studentPkg}" /></td>
<td align="center"><c:out value="${contentStatis.shared}" /></td>
<td align="center"><c:out value="${contentStatis.nonShared}" /></td>
<tr>
</c:forEach>
</tbody>
When I run the query alone in TOAD, it runs fine and display data.
But when I want to show the data in JSP, it shows me
--- Check the parameter mapping for the 'startDt' property.
--- Cause: java.sql.SQLException: 'Invalid column index
Can anyone help me?
Try to alias fields and tables:
SELECT
NVL(DAY, 'TOTAL') DAY
, SUM(A) SUMA, SUM(B) SUMB, SUM(C) SUMC --fields
FROM
(
) T --table
Related
I would like to scrape name, address informations between tag contains defendent text and another tag,
My HTML structure is:
<hr>
<H5>Defendant/Respondent Information</H5>
<span class="InfoChargeStatement">(Each Defendant/Respondent is displayed below)</span>
<table>
<tr>
<td><span class="FirstColumnPrompt">Party Type:</span></td><td><span class="Value">Defendant</span><span class="Prompt">Party No.:</span><span class="Value">1</span></td>
</tr>
</table>
<table>
<tr>
<td><span class="FirstColumnPrompt">Name:</span></td><td><span class="Value">Name 1</span></td>
</tr>
</table>
<table>
<tr>
<td><span class="FirstColumnPrompt">Address:</span></td><td><span class="Value">Addr 1</span></td>
</tr>
<tr>
<td><span class="FirstColumnPrompt">City:</span></td><td><span class="Value">city1</span><span class="Prompt">State:</span><span class="Value">aa</span><span class="Prompt">Zip Code:</span><span class="Value">Zip1</span></td>
</tr>
</table>
<hr>
<table>
<tr>
<td><span class="FirstColumnPrompt">Party Type:</span></td><td><span class="Value">Defendant</span><span class="Prompt">Party No.:</span><span class="Value">2</span></td>
</tr>
</table>
<table>
<tr>
<td><span class="FirstColumnPrompt">Name:</span></td><td><span class="Value">Name 2</span></td>
</tr>
</table>
<table>
<tr>
<td><span class="FirstColumnPrompt">Address:</span></td><td><span class="Value">Addr2</span></td>
</tr>
<tr>
<td><span class="FirstColumnPrompt">City:</span></td><td><span class="Value">City2</span><span class="Prompt">State:</span><span class="Value">st2</span><span class="Prompt">Zip Code:</span><span class="Value">zip2</span></td>
</tr>
</table>
<hr>
<H5>Related Persons Information</H5>
<span class="InfoChargeStatement">(Each Related person is displayed below)</span>
<table>
<tr>
<td><span class="FirstColumnPrompt">Name:</span></td><td><span class="Value">Unwanted Name</span></td>
</tr>
</table>
<table>
<tr>
<td><span class="FirstColumnPrompt">Address:</span></td><td><span class="Value">un addr</span></td>
</tr>
<tr>
<td><span class="FirstColumnPrompt">City:</span></td><td><span class="Value">Unwanted City</span><span class="Prompt">State:</span><span class="Value">Unwanted city</span><span class="Prompt">Zip Code:</span><span class="Value">12345</span></td>
</tr>
</table>
<table></table>
<hr>
My current XPATH capturing the first occurence of Name and address properly, but if need to extract the multiple occurences, it also scrape the information from the unwanted h5 tags.
My current XPATH is,
"//*[contains(text(),'Defendant')]//following-sibling::table//span[text()='Name:' or text()='Business or Organization Name:']/ancestor-or-self::td/following-sibling::td//text()")
I tried including preceding sibling and following sibling but nothing gives my expected output,
My current output is..
names - [
Name1,
Name2
Unwanted Name,
]
Expected output is,
[
Name1
Name2
]
Kindly help.
try this:
"//H5[contains(text(),'Defendant')]/following-sibling::table[not(preceding-sibling::H5[not(contains(text(),'Defendant'))])]/tr[td[1][span[text()[.='Name:' ]]]]/td[2]/span/text()"
It first selects the table that has not a preceding-sibling::h5 with text() that not contains 'Defendant' and than
selects from the correct table the tr where the first td meets your requirements and selects the second td
No need for double slashes which is bad for performance
EDIT 1
Since there are more preceding-sibling::h5 than the example shows, this XPath will deal with that:
"//H5[contains(text(),'Defendant')]/following-sibling::table[preceding-sibling::H5[1][contains(text(),'Defendant')]]//tr[td[1][span[text()[.='Name:' ]]]]/td[2]/span/text()"
This will only select those tables that have as there first preceding-sibling::h5 the same h5 as we were interested in
EDIT 2
Actually now the first h5 select is redundant. This XPath will do:
"//table[preceding-sibling::H5[1][contains(text(),'Defendant')]]//tr[td[1][span[text()[.='Name:' ]]]]/td[2]/span/text()"
I would like to use footable (I've already use footable for its responsive exploding display )and this to show records coming from a database but with a need to have a column (which display the stock quantity of products) that thye user can modify just by typing. Is there any way of having some sort of content editable column....
Any idea will be welcome
You can render the column as HTML, which will prevent footable from taking over the content of the cell, and have an <input type="text" /> for each row.
Something like:
<table>
<thead>
<tr>
<th>Name</th>
<th data-type="html">In stock</th>
</tr>
</thead>
<tbody>
<tr>
<td>Apples</td>
<td><input type="number" step="any" value="3"/></td>
</tr>
<tr>
<td>Oranges</td>
<td><input type="number" step="any" value="0"/></td>
</tr>
</tbody>
</table>
Check the documentation at https://fooplugins.github.io/FooTable/docs/getting-started.html , look for "Column Options" > "Type" .
After rendering you can attach an event listener to the input fields and send ajax calls accordingly.
I have two queries and each query is outputted on the screen in separate table. Both quires have the same number of records but I would like to check if each field is equal if not I want to set different background color for that table row. Here is the code that I have so far:
<cfquery name="oldData" datasource="test">
SELECT
old_id,
old_userid,
old_first,
old_last,
old_dob
FROM OldTest
</cfquery>
<cfquery name="newData" datasource="test">
SELECT
new_id,
new_userid,
new_first,
new_last,
new_dob
FROM NewTest
</cfquery>
And here is code for both tables:
<table>
<tr>
<td valign="top">
<table class="oldData">
<caption>Old Data</caption>
<thead>
<tr>
<th>ID</th>
<th>UserID</th>
<th>First</th>
<th>Last</th>
<th>DOB</th>
<tr>
</thead>
<tbody>
<cfoutput query="oldData">
<tr>
<td>#old_id#</td>
<td>#Trim(old_userid)#</td>
<td>#Trim(old_first)#</td>
<td>#Trim(old_last)#</td>
<td>#Trim(old_dob)#</td>
</tr>
</cfoutput>
</tbody>
</table>
</td>
<td valign="top">
<table class="newData">
<caption>New Data</caption>
<thead>
<tr>
<th>ID</th>
<th>UserID</th>
<th>First</th>
<th>Last</th>
<th>DOB</th>
<tr>
</thead>
<tbody>
<cfoutput query="newData">
<tr>
<td>#new_id#</td>
<td>#Trim(new_userid)#</td>
<td>#Trim(new_first)#</td>
<td>#Trim(new_last)#</td>
<td>#Trim(new_dob)#</td>
</tr>
</cfoutput>
</tbody>
</table>
</td>
</tr>
</table>
I'm wondering if I should compare data rows before the output something like:
<cfif oldData.old_first[currentrow] NEQ newData.new_first[currentrow]>
<cfset rowColor = "red">
</cfif>
Or there is better way to approach this. If anyone knows better way please let me know.
I would use looping:
<cfloop from="1" to="#oldData.recordCount#" index="r">
Question #oldData.old_id[r]# = #oldData.new_id[r]#? Answer: #oldData.old_id[r] eq oldData.new_id[r]#<br>
</cfloop>
You can wrap the loop around TRs and TDs if you desire.
This method also eliminates the need for a QofQ, which are resource intensive.
I suggest a query of queries resembling this:
select 'same' comparison, field1, field2, etc
from query1, query2
where query1.someField = query2.someField
union
select 'different' comparison, field1, field2, etc
from query1
where somefield not in (<cfqueryparam value="#valueList(query2.someField#") list = true>
Your table row colour can be specified with a ternary operator.
<tr bgcolor="#comparison is 'same' ? 'white' : 'red'#">
Here is the table that I am using to get the table row element that has specific element such as the href that has 'Harvest' in text and also checking if text 'running' exists in the same table row.
<table id="execTable" class="tableHistory jobtable translucent">
<colgroup>
<col class="execid">
<col class="titlecol">
</colgroup>
<tbody>
<tr>
<th>Id</th>
<th>Name</th>
</tr>
</tbody>
<tr id="8571">
<td>8571</td>
<td class="titlecol">
<div id="hitdiv-8571" class="arrow"></div>
Harvest
</td>
<td>09-03-2015 09:45:04</td>
<td>-</td>
<td>2m 6s</td>
<td>running</td>
<td>view/restart</td>
</tr>
<tr id="8571-child" class="childRow" style="display: none;"></tr>
<tr id="8566">
<td>8566</td>
<td class="titlecol">
<div id="hitdiv-8566" class="arrow"></div>
mk
</td>
<td>09-03-2015 03:30:00</td>
<td>09-03-2015 04:16:50</td>
<td>46m 50s</td>
<td>succeeded</td>
<td>view/restart</td>
</tr>
<tr id="8555-child" class="childRow" style="display: none;"></tr>
</table>
I am not able to get the TRs.
WebElement table = driver.findElement(By.id("execTable"));
List<WebElement> trows = table.findElements(By.tagName("tr"));
List<WebElement> all = driver.findElements(By.xpath(".//*[#id='execTable']/*"));
for (WebElement a : all) {
if(a.getTagName().equalsIgnoreCase("tr")) { ....}
}
I was able to get the above code working. Thank you!
I'm attempting to write some cucumber/capybara tests to validate data in a KendoGrid UI component and am having some real trouble determining how to select and validate the data on the page.
I've found the basic tutorials and examples on utlizing cucumber/capybara with table data but it appears that KendoGrid utilizing a slightly different configuration of it's tables and data where 1.) there is no "id" to easily select the grid on the page and 2.) there are multiple tables (one for the header) and another for the actual data itself.
Here is an excerpt of my current kendoGrid data I want to check:
<div id="item_grid" data-role="grid" class="k-grid k-widget k-secondary" style="">
<div class="k-grid-header" style="padding-right: 17px;">
<div class="k-grid-header-wrap">
<table role="grid">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th role="columnheader" data-field="ItemA" data-title="Item A" class="k-header" data-role="sortable">
<a class="k-link" href="#">Item A</a>
</th>
<th role="columnheader" data-field="ItemB" data-title="Item B" class="k-header" data-role="sortable">
<a class="k-link" href="#">Item B</a>
</th>
<th role="columnheader" data-field="ItemC" data-title="Item C" class="k-header" data-role="sortable">
<a class="k-link" href="#">Item C</a>
</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="k-grid-content">
<table role="grid">
<colgroup>
<col>
<col>
<col>
</colgroup>
<tbody>
<tr data-uid="2c77ea57-50ea-474d-950a-8379b3690936" role="row">
<td role="gridcell">A</td>
<td role="gridcell">223.63</td>
<td role="gridcell">0</td>
</tr>
<tr class="k-alt" data-uid="979534bc-7dea-47e9-9471-088c5bffe5b5" role="row">
<td role="gridcell">B</td>
<td role="gridcell">223.63</td>
<td role="gridcell">180</td>
</tr>
<tr data-uid="4d4c31e7-4daf-44ad-b6c1-20ffdfde57c4" role="row">
<td role="gridcell">C</td>
<td role="gridcell">143.58</td>
<td role="gridcell">0</td>
</tr>
<tr class="k-alt" data-uid="8d315558-b014-4219-b21b-dbe52cc6dd18" role="row">
<td role="gridcell">D</td>
<td role="gridcell">143.58</td>
<td role="gridcell">180</td>
</tr>
</tbody>
</table>
</div>
</div>
Where is the best place to start for writing tests to cover this scenario?
I have done some additional playing with the Telerik Test Studio and testing this specific scenario in that application is extremely easy!
One approach would be to collect the table of data into a 2D array using:
data_rows = page.all(:css, 'div#item_grid div.k-grid-content tr')
data = data_rows.collect do |tr|
tr.all(:css, 'td').collect(&:text)
end
p data
#=> [["A", "223.63", "0"], ["B", "223.63", "180"], ["C", "143.58", "0"], ["D", "143.58", "180"]]
Then with the data (and assuming you know what data should be in the table), you can validate the data array:
# If you want to validate the entire table and row order matters:
expect(data).to eql([["A", "223.63", "0"], ["B", "223.63", "180"], ["C", "143.58", "0"], ["D", "143.58", "180"]])
# If you want to validate the entire table and row order does not matter:
expect(data).to match_array([["B", "223.63", "180"], ["A", "223.63", "0"], ["D", "143.58", "180"], ["C", "143.58", "0"]])
# If you want to validate a specific row exists:
expect(data).to include(["B", "223.63", "180"])