Thymleaf switch statement in table - switch-statement

I want to set my tr class to bg-success when the status is equals 'EXECUTED'. Here is my code:
<th:block th:switch="${order.status}">
<tr th:case="'EXECUTED'" class="bg-success">
<tr th:case="*" class="bg-warning">
<td>...</td>
</tr>
</th:block>
It's obvious that I append two tr rows and don't close the first one, but in reality it's just one appended.
One solution is to rewrite the <td>...</td> in every case but it's a poor one. Is there any better solution without rewriting the <td>..</td> or using javascript?

Hope this helps :
<tr th:class="${order.status.equals('EXECUTED') ? 'bg-success' : 'bg-warning'}">
<td>...</td>
</tr>

Related

How to get all td[3] tags from the tr tags with selenium Xpath in python

I have a webpage HTML like this:
<table class="table_type1" id="sailing">
<tbody>
<tr>
<td class="multi_row"></td>
<td class="multi_row"></td>
<td class="multi_row">1</td>
<td class="multi_row"></td>
</tr>
<tr>
<td class="multi_row"></td>
<td class="multi_row"></td>
<td class="multi_row">1</td>
<td class="multi_row"></td>
</tr>
</tbody>
</table>
and tr tags are dynamic so i don't know how many of them exist, i need all td[3] of any tr tags in a list for some slicing stuff.it is much better iterate with built in tools if find_element(s)_by_xpath("") has iterating tools.
Try
cells = driver.find_elements_by_xpath("//table[#id='sailing']//tr/td[3]")
to get third cell of each row
Edit
For iterating just use a for loop:
print ([i.text for i in cells])
Try following code :
tdElements = driver.find_elements_by_xpath("//table[#id="sailing "]/tbody//td")
Edit : for 3rd element
tdElements = driver.find_elements_by_xpath("//table[#id="sailing "]/tbody/tr/td[3]")
To print the text e.g. 1 from each of the third <td> you can either use the get_attribute() method or text property and you can use either of the following solutions:
Using CssSelector and get_attribute():
print(driver.find_elements_by_css_selector("table.table_type1#sailing tr td:nth-child(3)").get_attribute("innerHTML"))
Using CssSelector and text property:
print(driver.find_elements_by_css_selector("table.table_type1#sailing tr td:nth-child(3)").text)
Using XPath and get_attribute():
print(driver.find_elements_by_xpath('//table[#class='table_type1' and #id="sailing"]//tr//following::td[3]').get_attribute("innerHTML"))
Using XPath and text property:
print(driver.find_elements_by_xpath('//table[#class='table_type1' and #id="sailing"]//tr//following::td[3]').text)
To get the 3 rd td of each row, you can try either with xpath
driver.find_elements_by_xpath('//table[#id="sailing"]/tbody//td[3]')
or you can try with css selector like
driver.find_elements_by_css_selector('table#sailing td:nth-child(3)')
As it is returning list you can iterate with for each,
elements=driver.find_elements_by_xpath('//table[#id="sailing"]/tbody//td[3]')
for element in elements:
print(element.text)

xpages dijit.form.checkbox multiple values

Using xpages on domino 8.5.3 server.
Can a djcheckbox be use with muiltiple value field similar to a checkboxgroup ?
if so, would it be possible to supply a code snippet.
Thanks
dijit.form.CheckBox can deal with only one value and that's true for djCheckBox too as it's based on dijit.form.CheckBox.
You could combine several djCheckBox controls and let it look like a checkBoxGroup. Bind every djCheckBox to a viewScope variable initialized by a document item and write values back at document save.
Here is an example for UI similarity to checkBoxGroup:
<fieldset
class="xspCheckBox">
<table>
<tbody>
<tr>
<td>
<xe:djCheckBox
label="abcdefg"
id="djCheckBox4"
value="#{viewScope.abcdefg}">
</xe:djCheckBox>
</td>
<td>
<xe:djCheckBox
label="hijklmno"
id="djCheckBox5"
value="#{viewScope.hijklmno}">
</xe:djCheckBox>
</td>
<td>
<xe:djCheckBox
label="pqrstuvwxyz"
id="djCheckBox6"
value="#{viewScope.pqrstuvwxyz}">
</xe:djCheckBox>
</td>
</tr>
</tbody>
</table>
</fieldset>
I am not sure though what's the reason for your question and if it's worth the extra effort.

Selenium ide store string as number

I need to store two text value and use them as numbers for subtraction:
<span id="user-account-balance">593 455,07</span> $
<span id="user-account-balance-points">12454</span> P
I need to subtract both values, but it doesn't work for me:
<tr>
<td>storeText</td>
<td>//a/span[#id='user-account-balance']</td>
<td>a</td>
</tr>
<tr>
<td>storeEval</td>
<td>storedVars['a'].match(/^\d+/);</td>
<td>one</td>
</tr>
<tr>
<td>storeText</td>
<td>//span[#id='user-account-balance-points']</td>
<td>c</td>
</tr>
<tr>
<td>storeEval</td>
<td>storedVars['c'].match(/^\d+/);</td>
<td>two</td>
</tr>
<tr>
<td>store</td>
<td>javascript{storedVars['one']+storedVars['two']}</td>
<td>r</td>
</tr>
<tr>
<td>echo</td>
<td>${r}</td>
<td></td>
</tr>
The result is [info] echo: 59312454. So there are two problems, the first number is cut out after the space and it doesn't even subtract anyway
So first, your regex
/^\d+/
will only capture the uninterrupted sequence of numbers at the very beginning of the string. You will need to modify the first .match() regex to handle textual numbers with spaces as thousand separators and commas as decimal separators. Documentation on match says that a //g regex will return an array of strings, so you could probably do something like
storedVars['a'].match(/\d+(,\d\d)?/g).join('').replace(',', '.');
to capture the currency string and store it in a string-to-number convertible manner. Then your last JavaScript expression would be something like
storeEval
parseFloat(storedVars['one']) + parseInt(storedVars['two'])
This worked for me when total was stored as $xxx,xxx.xx:
<tr>
<td>storeText</td>
<td>xpath=.//*[#id='table-header']/tbody/tr[1]/td[5]/b</td>
<td>Total1</td>
</tr>
<tr>
<td>storeEval</td>
<td>storedVars['Total'].replace(',', '').replace('$', '');</td>
<td>Amount1</td>
</tr>

JavaFX hide text of column in tableview

I have a tableview and I want to show an image in the first column. My problem is I can't sort the column then. My idea is to set text in the column too and hide the text so it is only for the correct sorting set. Is there a way to do that? Or what other solutions are possible for my problem?
I think this is the perfect example what you wants to do.Still let me know if you have any issue.
Check here
I would have a look at TableColumn.setCellValueFactory() and TableColumn.setCellFactory(). The further is used to provide the actual cell value (used for sorting!), the latter is used to provide the rendering.
In other words: If you need the sort order, you must not change the content, but only the Cell rendering. The methods mentioned above let you do exactly this.
Hope that helps ...
You could do it with just CSS using text-indent. You would also need to set the image as a css background. You did not provide an code of your table, but below is some example:
HTML:
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td class="hidetext image">Text 1</td>
<td>Some text to show</td>
</tr>
<tr>
<td class="hidetext image">Text 2</td>
<td>Some text to show</td>
</tr>
<tr>
<td class="hidetext image">Text 3</td>
<td>Some text to show</td>
</tr>
<tr>
<td class="hidetext image">Text 4</td>
<td>Some text to show</td>
</tr>
</table>
CSS:
.hidetext {text-indent:-9000px}
.image {background:url(http://www.madisoncopy.com/images/jpeg.jpg) no-repeat;}
See how in the left column the text does not show (but it is actually there just indented off the screen).
See this fiddle: http://jsfiddle.net/D297P/

Alternating row colors in ExpressionEngine table

I have some code that creates a table that alternates row colors based on the row value of the entry.
<table class="authorList" cellspacing="0">
{exp:channel:entries channel="team" disable="categories|member_data|pagination" orderby="team-last-name" sort="asc"}
{if team-not-with-us != 'y'}
<tr class="{switch="odd|even"} authorInfo">
<th class="authorName">
{if team-bio != ''}<a href="{site_url}about/the-team/{url_title}">{/if}
{title}
{if team-bio != ''}</a>{/if}
</th>
<td class="position">{team-position}</td>
</tr>
{/if}
{/exp:channel:entries}
</table>
The problem is when I delete an entry, I end up having two odd or two even numbers in a row, leaving me with two like-colored rows side by side.
While the switch function is convenient, it is referencing the row count within the database. I don't believe I can apply it to reference the actual row count in the if statement which would solve my problem. (Correct me if I'm wrong.)
I know how to make this change with php:
<?php $oddevenrow = 0; ?>
{if team-not-with-us != 'y'}
<?php $oddevenrow++; ?>
<?php ($oddeven = ($oddevenrow % 2 ? 'odd' : 'even')); ?>
<tr class="<?php echo $oddeven; ?> authorInfo">
But I'm not allowed to turn PHP on in the EE install.
Is there something similar I can do in EE?
Thanks!
You're looking for the switch tag.
{switch="odd|even"}
But it looks like you already knew that. It looks like you're requiring the variable team-not-with-us to != 'y'. Because you're doing that validation after results have been returned you'll end of with multiple odd or even rows next to each other. The easy way to avoid this is to use the channel:entries search param. Example: search:team-not-with-us="not y"
<table class="authorList" cellspacing="0">
{exp:channel:entries
channel="team"
disable="categories|member_data|pagination"
orderby="team-last-name"
sort="asc"
search:team-not-with-us="not y"
}
<tr class="{switch="odd|even"} authorInfo">
<th class="authorName">
{if team-bio != ''}<a href="{site_url}about/the-team/{url_title}">{/if}
{title}
{if team-bio != ''}</a>{/if}
</th>
<td class="position">{team-position}</td>
</tr>
{/exp:channel:entries}
</table>
You might want to try asking the EE peeps at https://expressionengine.stackexchange.com/ The {count} tag should work. That simply counts every entry that (in your case) is in the Team Channel and is not Y in your "team-not-with-us" field group, which I'm assuming is a switch or a select box or something.
What does your outputted code look like?

Resources