Thymeleaf. Building table from array & list - spring-mvc

I got this code:
<th:block th:if="${!#lists.isEmpty(partyInfoByUploaderList)}" th:each="pInfo : ${partyInfoByUploaderList}">
<h4 th:text="${pInfo.getCharName()}"></h4>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th:block th:if="${!#lists.isEmpty(pInfo.getCharColumnTitles())}" th:each="title: ${pInfo.getCharColumnTitles()}">
<td th:text="${title}"></td>
</th:block>
</tr>
</thead>
<tbody>
<tr>
<th:block th:each="val: ${pInfo.getCharColumnValues()}">
<td th:text="${val}"></td>
</th:block>
</tr>
</tbody>
</table>
And I got this result:
http://screenshot.ru/6dfbe559f905a17dff44d360b5d13f28
So this code correctly create table head, and dont parse table body.
BTW, after delpoy this code appear at another place:
<th:block th:each="val: ${pInfo.getCharColumnValues()}">
<td th:text="${val}"></td>
</th:block>
Web source code in browser:
http://screenshot.ru/9d3fab8030c5ca382ab81094e0c1ca86
Question #2:
Why this code produce TemplateProcessingException error?
P.S. Not enough reputation for images, so just links. Soz

According to Thymeleaf Documentation, <th:block></th:block> should wrap <tr></tr> and not the opposite. So you should try this :
<th:block th:each="val: ${pInfo.getCharColumnValues()}">
<tr>
<td th:text="${val}"></td>
</tr>
</th:block>

Related

HtmlAgilityPack - Stripping entire table of html attributes isn't working

I'm trying to remove all attributes (class, id and so on) from an HTML table I'm scraping.
So for example, the value for html would be the following:
<table id="tablepress-29" class="tablepress tablepress-id-29">
<thead>
<tr class="row-1 odd">
<th class="column-1">1</th>
<th class="column-2">2</th>
<th class="column-3">3</th>
</tr>
</thead>
<tbody class="row-hover">
<tr class="row-2 even">
<td colspan="3" class="column-1">
<span id="testing---id">
<h2><b>Testing</b></h2>
</span></td>
</tr>
</thead>
</table>
My C#, using HTML Agility Pack is the following:
var doc = new HtmlDocument();
doc.LoadHtml(html.ToString());
var table = doc.DocumentNode.SelectSingleNode("//table");
table.Attributes.Remove("class");
table.Attributes.Remove("id");
var final = table.OuterHtml;
Which strips the first line from
<table id="tablepress-29" class="tablepress tablepress-id-29">
to
<table>
However, it ignores the rest of the code.

Positioning image in github markdown table

I have some content which does not take up the entire column. so I was trying to postion an image to that side so that it saves some space.
I tried checking for grid layouts or column layout in md but none of it has provided info on how to do it
This is what i am looking for
the code is # here
... thanks
The Markdown table does not support cell merge by default, so you should use HTML table.
And in comment, you said
"Even this time the image took only one row, ..."
in this case just use rowspan.
<table>
<tr>
<td>- Identifying cutomer needs (requirments)</td>
<td rowspan="11">
<img src="https://user-images.githubusercontent.com/74305823/118094261-783e8280-b409-11eb-8f50-8ed0b304fef0.png" width="300"/>
</td>
</tr>
<tr>
<td>- market analysis (requirements)</td>
</tr>
<tr>
<td>- defining goals (requirements)</td>
</tr>
<tr>
<td>- Establishing functions (Prodct concept)</td>
</tr>
<tr>
<td>- Task Specifications (Prodct concept)</td>
</tr>
<tr>
<td>- Conceptualizatoin (Solution concept)</td>
</tr>
<tr>
<td>- Evaluating Alternatives</td>
</tr>
<tr>
<td>- Emnodiment Design</td>
</tr>
<tr>
<td>- Analysis and Optimization</td>
</tr>
<tr>
<td>- Experiment</td>
</tr>
<tr>
<td>- Marketing</td>
</tr>
</table>
EDIT
AS #tarleb said, using <ul>...</ul> tag can be more simple.
<table>
<tr>
<td>
<ul>
<li>Identifying cutomer needs (requirments)</li>
<li>market analysis (requirements)</li>
<li>defining goals (requirements)</li>
<li>Establishing functions (Prodct concept)</li>
<li>Task Specifications (Prodct concept)</li>
<li>Conceptualizatoin (Solution concept)</li>
<li>Evaluating Alternatives</li>
<li>Emnodiment Design</li>
<li>Analysis and Optimization</li>
<li>Experiment</li>
<li>Marketing</li>
</ul>
</td>
<td>
<img src="https://user-images.githubusercontent.com/74305823/118094261-783e8280-b409-11eb-8f50-8ed0b304fef0.png" width="300"/>
</td>
</tr>
</table>

Vue template colspan not working properly

Hi im having a issue with a simple problem. because for some reason i dont find anything wrong with my codes. Seems like my code is not reading my colspan. seems like this problem as been mark as duplicate. but i dont want to specify the width of the table since i want the table to be responsive and i use bootstrap table
<div>
<table class="table table-condensed">
<thead>
<tr class="text-uppercase text-contrail table-dark-head">
<th colspan="3">Spillage</th>
<th>Total</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">Material Cost / Kg</td>
<td>
<input></input>
</td>
<td>
<input></input>
</td>
</tr>
<tr>
<td>Spillage at 0.5%</td>
</tr>
</tbody>
</table>
</div>
i put this code inside my template. please see the image for the result. The Total and Remarks should be on the right side. but it end up with balance width.

How to loop through Map in Thymeleaf

I am trying to understand how to loop through all entries in a Map in Thymeleaf. I have a domain object being processed by Thymeleaf that contains a Map.
How do I loop through the keys and fetch the values ?
Thanks.
Nevermind... I found it...
<tr th:each="instance : ${analysis.instanceMap}">
<td th:text="${instance.key}">keyvalue</td>
<td th:text="${instance.value.numOfData}">num</td>
</tr>
Thanks.
In case you have a List as the value. For example, when you have a map with key being the category, and value being a list of items pertaining to that category, you can use this:
<table>
<tr th:each="element : ${catsAndItems}">
<td th:text="${element.key}">keyvalue</td>
<table>
<tr th:each="anews : ${element.value}">
<td th:text="${anews.title}">Some name</td>
<td th:text="${anews.description}">Some name</td>
<td th:text="${anews.url}">Some name</td>
<td th:text="${anews.logo}">Some name</td>
<td th:text="${anews.collectionDate}">Some name</td>
</tr>
</table>
</tr>
</table>

webdriver getText() issue with large amount of values

I'll try to explain what I see in a few words.
I use webdriver + testNG on a win7 machine.
I have a table and get a reference to it. When I try to get all the text contained in such table, if it's empty (only header) then there are no problems .
But, if there are more rows, the table.getText() is not working properly and the result is:
A script on this page may be busy, or it may have stopped responding.
You can stop the script now, or you can continue to see if the script will complete.
Script: file:///C:/Users/VM-AUT~1/AppData/Local/Temp/anonymous2085126608473413720webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:6047
I have tried increasing the timeout but the result is the same. If I decide to continue, getText() returns me all the values and the script continues.
This is a very short description but I don't want to be boring, but if more details are needed just let me know.
A few more infos:
If the table has +-5 records it works fine.
There is a problem if it has +-20 records per page (it's possible to switch between pages)
The problem persists with FF 23 ( looks fine with chrome & IE) but didnt check with previous FF versions
I use java + testNG + selenium grid but have the same problem on my local machine as well
If I select CONTINUE at the "A script on this page may be busy....." message, gettext()returns me the correct values I use the selenium 2.33
Table looks like:
driver.findElement(By.xpath(".//*[#id='smslog_outer_table']")).getText()
<table id="smslog_outer_table" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="left" style="vertical-align: top;">
<table class="table table-condensed" cellspacing="0" cellpadding="0">
<colgroup>
<tbody>
<tr class="gwtutility-table-tr-head">
<tr class="delivered">
<td class="" colspan="1">
<div class="gwt-Label">043081410085553301</div>
</td>
<td class="log_date_time" colspan="1">
<td class="" colspan="1">
<td class="" colspan="1">
<td class="" colspan="1">
<td class="" colspan="1">
<td class="" colspan="1">
<td class="" colspan="1">
<td class="log_status" colspan="1">
<td class="log_date_time" colspan="1">
<td class="log_message" colspan="1">
</tr>
<tr class="delivered">
<tr class="delivered">
</tbody>
</table>
</td>
</tr>
<tr>
</tbody>
</table>

Resources