EL Expression, set var if test condition is true - el

I have the following code block within my TAG file -
(See comment inside code block for my question)
<c:forEach var="headerTab" items="${KualiForm.headerNavigationTabs}" varStatus="status">
<c:if test="${headerTab.headerTabDisplayName != 'S2S'}">
<c:choose>
<c:when test="${headerTab.headerTabDisplayName == 'Key Personnel'}">
// (Set the value of the var evaluated in the test above here)
// How do I do the following using EL Notation:
// headerTab.headerTabDisplayName = 'Some other string';
</c:when>
</c:choose>

Have you tried using the c:set JSTL Tag? It should be something like this:
<c:set target="headerTab" property="headerTabDisplayName"
value="Some other string"/>

Related

Razor-Pages - HTML markup

Following the answer on this post I was using #:<div class="col-md-6">
Problems
The Formatting gets all messed up:
The intellicode gets all messed up (I only deleted the paragraph on the second #:)
Also, my if (i == (Model.CellsNotStarted.Count - 1) && i % 2 != 0) won't work when using the #:; it will always go on the else. If I don't use the #: markup, and if I, for instance put all my html in a if/else instead of only the <div> tag it will work with no problems.
My question is:
Is the #: markup viable? If so, what am I doing wrong. If not what is the alternative (that does not imply putting my entire code in an if/else)
PS: I know I should not post images of code, but I wanted to show the format and syntax errors.
There are neater ways to manage conditions within your Razor code. It's difficult to provide a full example because you don't provide the full code, but you can do this, for example:
<div class="col-md-#(i+1 == Model.CellsNotStarted.Count && i % 2 ! = 0 ? "12" : "6")">
Whenever you are tempted to use a remainder operator (%) in Razor, you should also consider whether a GroupBy would be better. It most often is, as I was shown in this question: Building tables with WebMatrix
You can try to use js to set html.Here is a demo:
<div id="myDiv"></div>
<script>
$(function () {
var html = "";
if ("#(Model.CellsNotStarted != null)"=="True")
{
for (var i = 0; i <#Model.CellsNotStarted.Count; i++)
{
if (i == (#Model.CellsNotStarted.Count - 1) && i % 2 != 0)
{
html += '<div class="col-md-12">';
}
else
{
html += '<div class="col-md-6">';
}
html += i+'</div>';
}
}
$("#myDiv").html(html);
})
</script>
result:

Selenium and JavaScript: Accessing multiple elements with the same ID

I've got a page (Angular8) with multiple button/input elements having the same ID.
The ID's are, in the order the appear on the page:
1: for="lastOppDokument-0-VERGE-LEGITIMASJON"
2: for="lastOppDokument-1-VERGE-VERGEMAL"
...
3: for="lastOppDokument-0-VERGE-LEGITIMASJON"
4: for="lastOppDokument-1-VERGE-VERGEMAL"
The elements on lines 1,3 and 2,4 have the same ID.
I'm trying to access the elements using XPath and index like this:
driver.findElement(By.xpath("(//input[#for='lastOppDokument-0-VERGE-LEGITIMASJON'])[1]
driver.findElement(By.xpath("(//input[#for='lastOppDokument-0-VERGE-LEGITIMASJON'])[2]
If I check the size:
int x = driver.findElements(By.xpath("(//input[#for='lastOppDokument-0-VERGE-LEGITIMASJON'])")).size();
it says "2", which is correct.
However, when I try to click those two buttons, the first one (LINE 1) is clicked, but then the next button on the page (LINE 2) i clicked istead of the one on LINE 3.
There's obviously something wrong with my XPath expression, but what? Also, the page is an Angular page, and in the markup code "for" is used to automatically index the ID. But selenium finds the elements (albeit not all the correct ones) using ID. But maybe I need to use something else to identify the correct elements?
UPDATE:
To troubleshoot, I'm skipping the use of a loop and just trying to access the two elements manually:
WebElement buttonToClick = driver.findElement(By.xpath("(//input[#id='lastOppDokument-0-VERGE-LEGITIMASJON'])[1]"));
filUtils.uploadFile(buttonToClick, legitimasjonfil);
WebElement buttonToClick2 = driver.findElement(By.xpath("(//input[#for='lastOppDokument-0-VERGE-LEGITIMASJON'])[2]"));
filUtils.uploadFile(buttonToClick2, legitimasjonfil);
The uploadFile (and related) methods:
public void uploadFile(WebElement id, String filename) {
id.sendKeys(getAbsolutePathToTestFile(TESTFILER_PATH + "/" + filename));
}
private String getAbsolutePathToTestFile(String path) {
return copyFileToTargetTempPath(path, path);
}
private String copyFileToTargetTempPath(String originPath, String destinationPath) {
InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(originPath);
File destination = new File(TARGET_TEMP_PATH + destinationPath);
try {
assert resourceAsStream != null;
org.apache.commons.io.FileUtils.copyInputStreamToFile(resourceAsStream, destination);
} catch (IOException e) {
throw new RuntimeException(e);
}
return destination.getAbsolutePath();
}
UPDATE 2:
<td>
<span class="hb-felt knappesamling-gruppe hb-avstandIngen ng-star-inserted">
<input class="hb-lastOppFil-input hb-bare-skjermleser" type="file" id="lastOppDokument-0-VERGE-LEGITIMASJON"
accept=".pdf,.bmp,.gif,.jpeg,.jpg,.png,.tiff">
<label class="hb-knapp hb-knapp--standard hb-spinner-tekst" for="lastOppDokument-0-VERGE-LEGITIMASJON"> Velg fil </label><!---->
</span>
</td>
<td>
<span class="hb-felt knappesamling-gruppe hb-avstandIngen ng-star-inserted">
<input class="hb-lastOppFil-input hb-bare-skjermleser" type="file" id="lastOppDokument-1-VERGE-VERGEMAL"
accept=".pdf,.bmp,.gif,.jpeg,.jpg,.png,.tiff"><label class="hb-knapp hb-knapp--standard hb-spinner-tekst" for="lastOppDokument-1-VERGE-VERGEMAL"> Velg fil </label><!----></span>
<label class="hb-knapp hb-knapp--standard hb-spinner-tekst" for="lastOppDokument-1-VERGE-VERGEMAL"> Velg fil </label>
</span>

BLOGGER - Use custom variables inside <b:if> tag?

I am trying to create a conditional statement depending on the value of a custom variable called "pp". However I received this message and my widget cannot be loaded:
The expression 'pp == "left"' is not valid.
This is my code:
<script type='text/javascript'>
var pp = "left";
</script>
<b:loop index='postcont' values='data:posts' var='post'>
<b:if cond= 'pp == "left"'>
<b:include name='leftpost'/>
<b:elseif cond='pp= mid'/>
<b:include name='midpost'/>
<b:else/>
<b:include name='rightpost'/>
</b:if>
</b:loop>
Is there any way to use custom variables inside tag? Or any other option to achieve what I am looking for.
Thank you.
BR.
Use b:with tag to define a blogger variable
<b:with var='pp' value='"left"'>
<b:loop index='postcont' values='data:posts' var='post'>
<b:if cond='data:pp == "left"'>
<b:include name='leftpost'/>
<b:elseif cond='data:pp == "mid"'/>
<b:include name='midpost'/>
<b:else/>
<b:include name='rightpost'/>
</b:if>
</b:loop>
</b:with>

Typo3 GP variables in TSSETUP

I use typo3 7.6.10
I learn how get a url variable and store it in other variable for fluid in TSSETUP:
lib.pippomio = TEXT
lib.pippomio.data = GP:cat
example url: index.php?id=10&cat=pino
I print the variable in my template:
<f:cObject typoscriptObjectPath="lib.pippomio" />
Ok it works.
Now i need to print the variable in input by Search Indexed Engine:
<input class="tx-indexedsearch-searchbox-sword" id="tx-indexedsearch-searchbox-sword" type="text" name="tx_indexedsearch_pi2[search][sword]" value="progetto">
How can i store in lib.pippomio the POST Variable "tx_indexedsearch_pi2[search][sword]" ???
I tried
lib.pippomio.data = GP:tx_indexedsearch_pi2[search][sword]
But it doesn't works.
I want to print the word searched in an other place.
You can use a pipe "|" to get it
lib.pippomio.data = GP:tx_indexedsearch_pi2|search|sword
TYPOSCRIPT Reference => getText

how to set flow variables inside expression component in mule

<set-variable variableName="tempId" value="8000" doc:name="Variable" />
<expression-component doc:name="Expression">
<![CDATA[
temp1 = message.payload.getRootElement().selectNodes('//palns/*');
foreach (plan1 : temp1){
plan1.selectSingleNode('planid').text = #[flowVars.tempId];
} ]]></expression-component>
Above is my code . I can't set flow variable value inside expression component.
if i hardcode my value like below plan1.selectSingleNode('planid').text = '4000';
It is working.
But I want my flow variables value . Any thoughts?
Just remove the expression wrapper #[] as its not needed in expression-component:
plan1.selectSingleNode('planid').text = flowVars.tempId;
<set-variable variableName="tempId" value="8000" doc:name="Variable" />
<expression-component doc:name="Expression">
<![CDATA[
temp1 = message.payload.getRootElement().selectNodes('//palns/*');
foreach (plan1 : temp1){
plan1.selectSingleNode('planid').text = flowVars.tempId;
} ]]></expression-component>
Expression component doesn't take #[]