I am trying to iterate over a List < Lits < Record > > with Freemaker. I have tried this but it is not working:
<#list keyTranslations as keyTranslation>
<tr>
<#list keyTranslation as translation>
<td style="padding:5px;">
${translation.translationValue}
</td>
</#list>
</tr>
</#list>
Does someone know how can I do it?
Related
Have some for:
for(int i = 0; i < ids.size(); i++){
List<NomenclatureTypeFirst> nmtf = nomenclatureTypeFirstService.getAllByRequest(ids.get(i));
map.put(ids.get(i), nmtf);
}
Tried to uset th:text on value like this:
<table>
<tr th:each="entry, stats : ${map}">
<td th:text="${entry.key}"></td>
<td th:text="${entry.value.detname}"></td>
</tr>
</table>
But catch:
Property or field 'detname' cannot be found on object of type 'java.util.ArrayList' - maybe not public or not valid?
How can I do this?
The value of your map is a list, so you have to iterate over the values:
<table>
<tr th:each="entry, stats : ${map}">
<td th:text="${entry.key}"></td>
<table>
<tr th:each="value : ${entry.value}">
<td th:text="${value.detname}"></td>
</tr></table>
</tr>
</table>
I need to find the whole text according last word in the string. I have something like this:
<table>
<tr>
<td style='white-space:nowrap;'>
<a href=''>test</a>
</td>
<td>any text</td>
<td>text text texttofind</td>
<td>Not Available</td>
<td class='aui-lozenge aui-lozenge-default'>text</td>
</tr>
<tr>
<td style='white-space:nowrap;'>
<a href=''>test</a>
</td>
<td>any text</td>
<td>text text texttofind2</td>
<td>Not Available</td>
<td class='aui-lozenge aui-lozenge-default'>text</td>
</tr>
<tr>
<td style='white-space:nowrap;'>
<a href=''>test</a>
</td>
<td>any text</td>
<td>text text texttofind3</td>
<td>Not Available</td>
<td class='aui-lozenge aui-lozenge-default'>text</td>
</tr>
</table>
I need to find whole text vallue according last word texttofind
<td>text text texttofind</td>
I cant use contains, because it will find multiple values. I need something like ends-with but I am using xpath 1.0.
I tried something like this, but I am not sure what is wrong because it is not working
//tr[substring(., string-length(#td)
- string-length('texttofind') + 1) = 'texttofind']
or maybe it would be better to use matches?
You're almost there; try changing your xpath expression to
//tr//td[substring(., string-length(.)
- string-length('texttofind') + 1) = 'texttofind']
and see if it works.
please assist with the below. I am trying to display an arraylist returned from the controller and display it to an Html table but I get the above error.
here is my controller code:
#GetMapping(value="/chart" )
public List<List<CanvasjsChartData.DataPointModel>> chart(Model modelMap) {
List<List<CanvasjsChartData.DataPointModel>> dataPointsList = canvasjsChartService.getCanvasjsChartData();
modelMap.addAttribute("dataPointsList", dataPointsList);
System.out.println("dataPointsList");
return dataPointsList;
}
and this is the table I want to display my list in
<table class="table" id="dataTable" style="width:100%">
<thead>
<th>Level</th>
<th>Occurences</th>
</thead>
<tbody>
<tr th:each="item :${dataPointsList}">
<td th:text="${item.LEVEL}"> </td>
<td th:text="${item.OCCURENCES}"> </td>
</tr>
</tr>
</tbody>
I know for sure the ArrayList has the data I require as shown below I dont know why its giving me the error
Your debug shows you have an List<List<CanvasjsChartData.DataPointModel>> (two Lists inside of each other) -- when your HTML is expecting List<CanvasjsChartData.DataPointModel>. You should fix that in your controller/model by only returning a single list.
You could also display your HTML like this (where you loop over the 0th element of the outer array):
<tr th:each="item :${dataPointsList[0]}">
<td th:text="${item.LEVEL}" />
<td th:text="${item.OCCURENCES}" />
</tr>
I would like in Freemaker that my value is listed in 2 columns.
My code so far :
<#list orderItem.options as option>
<tr>
<td style="font-family: Arial,Helvetica,sans-serif;font-size: 16px;">
<div class="row">
<#if option.fileUrls??>
<span>
<span>${option.name}:
</span>
<#fileLinks option.fileUrls = "option.fileUrls"/>
</span>
<#else>
<#if option.value != 'Geen'>
<div class="column">${option.name}: ${option.value}</div>
${option.name}: ${option.value}
- -
</#if>
</#if>
</div>
</td>
</tr>
</#list>
So I want :
I have a webshop where people can buy food.
Food can have multiple options : Size, Salt, Saus
I want that my products will be printed in my mail this way :
Product name : Product name:
Size: small Size: Big
Salt : Yes Salt: no
Saus: Mayonaise Saus: Cocktail
You really should be limiting the scope of your question's example. I am not sure what the extra markup should do, or where it should be placed. But is it something like this you are looking for?
<table>
<#list orderItem.options as option>
<#if option.fileUrls??>
<tr>
<td>
<span>${option.name}</span>
<span><#fileLinks option.fileUrls/></span>
</td>
<td>
<#if option.value != 'Geen'>
<span>${option.value}</span>
</#if>
</td>
</tr>
</#if>
</#list>
</table>
I am sorry if this is not exactly what you are looking for, but your example is confusing. At least you might take my example response and go from there.
I have couple questions if you don't mind:
Is Product name also part of the options stored in orderItem.options ?
Is having file link exclusive to a certain option ?
Please edit your question and post the Java model (class) OrderItem
I got what you want, need to know your design approach to provide the best solution that suites your design.
I am using Webdriver in Ruby and I want to verify three text exists on a page.
Here is the piece of html I want to verify:
<table class="c1">
<thead>many subtags</thead>
<tbody id="id1">
<tr class="c2">
<td class="first-child">
<span>test1</span>
</td>
manny other <td></td>
</tr>
<tr class="c2">
<td class="first-child">
<span>test2</span>
</td>
manny other <td></td>
</tr>
<tr class="c2">
<td class="first-child">
<span>test3</span>
</td>
manny other <td></td>>
</tr>
</tbody>
</table>
How do I verify "test1", "test2" and "test3" presents on this page using
find_element
find_elements
getPageSource?
What is the best approach for it?
Thank you very much.
I would go with #find_elements method,because with other 2 options there will be a chance to get no such element exception.
First collect it in an array -
array = driver.find_elements(:xpath,"//table[#class='c1']//tr[#class='c2']//span[text()='test1']")
Now check the array size
"test1 is present" unless array.empty?
The same way we can test for test2 and test3.
Following sample code will help you to perform your task :
def check_element_exists
arr = ["test1", "test2", "test3"]
arr.each do |a|
if $driver.page_source.include? a
puts a
else
print a
puts " Not present"
end
end