Thymeleaf: conditional expression is not evaluated - spring

In my current spring project, one of the views have the following thymeleaf code:
<div class="input-group" th:each="item : ${role}" th:id="${item.getId()}">
<span class="input-group-addon" th:with="possui = 'not'">
<span th:each="item2 : ${usuario.getRole()}" th:if="${item.getId() == item2.getId()}" th:with="possui = 'yes'" class="glyphicon glyphicon-check" th:id="icon__${item.getId()}__" aria-hidden="true"></span>
<span th:if="possui == 'not'" class="glyphicon glyphicon-unchecked" th:id="icon__${item.getId()}__" aria-hidden="true"></span>
</span>
<input type="text" class="form-control" th:value="${item.getNome()}" disabled="disabled"/>
<span class="input-group-btn">
<button class="btn btn-default" th:attr="data-id=${item.getId()}" type="button">
<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>
</button>
</span>
</div>
in the first block from input-group (the one with the class input-group-addon), should be displayed the checked icon if the user has the role, or the unchecked icon if the user hasn't. But with the code above, only the checked icon is displayed.
Anyone can see what's wrong with this code?

<span th:if="possui == 'not'" class="glyphicon glyphicon-unchecked" th:id="icon__${item.getId()}__" aria-hidden="true"></span>
should be
<span th:if="${possui == 'not'}" class="glyphicon glyphicon-unchecked" th:id="icon__${item.getId()}__" aria-hidden="true"></span>
Notice the ${possui == 'not'}
Tip: You ${item.getId()}, you can use ${item.id}

Related

how to make two If condition in laravel

Two conditions I want to apply for a button that will show the application when applied and if the user has a login then the button will show and ask to login.
Blade
#if (Auth::check())
#if ($tuitionJob->checkApply())
<form action="{{url('/tuition/apply')}}" method="POST">
#csrf
<input type="hidden" value="{{$tuitionJob->id}}" name="tuitionid">
<button type="submit" class="btn btn-primary login-apply-btn my-2 text-light pull-right">
Apply <i class="fa fa-send"></i>
</button>
</form>
#else
<a href="/login" class="btn btn-primary login-apply-btn my-2 text-light pull-right">
<i class="fa fa-send"></i>
Login For Apply
</a>
#else
<a href="tuition/job" class="btn btn-primary login-apply-btn my-2 text-light pull-right">
<i class="fa fa-send"></i>
Applied
</a>
#endif
#endif
Model
public function checkApply(){
return \DB::table('tuition_applies')->where('users_id', auth()->user()->id)
->where('tuition_post_id', $this->id)->exists();
}
Try && Logical Operator
#if(Auth::check() && $tuitionJob->checkApply())
//Code
#else
//Code
#endif
May be helpful for you
#if (Auth::check())
#if ($tuitionJob->checkApply())
<form action="{{url('/tuition/apply')}}" method="POST">
#csrf
<input type="hidden" value="{{$tuitionJob->id}}" name="tuitionid">
<button type="submit" class="btn btn-primary login-apply-btn my-2 text-light pull-right">
Apply <i class="fa fa-send"></i>
</button>
</form>
#else
<a href="/login" class="btn btn-primary login-apply-btn my-2 text-light pull-right">
<i class="fa fa-send"></i>
Login For Apply
</a>
#endif
#else
<a href="tuition/job" class="btn btn-primary login-apply-btn my-2 text-light pull-right">
<i class="fa fa-send"></i>
Applied
</a>
#endif
Try this

Laravel - Why my code isnt displaying all the collapses ?

This code need to display all "subcategory" for each "subcategories"
But the view result is the first subcategory only.
Where i missed please ?
View 1 :
#foreach($treeView as $category)
<div class="collapse multi-collapse collapse in " id="8" >
<div class="col-md-2"> {{ $category->account_name}}</div>
<div class=" float-right"><button class="btn btn-success" data-toggle="collapse" data-target="#{{ $category->id}}8" aria-expanded="false" aria-controls="{{ $category->id}}8" #click="getSubaccount(); getNumberrawaccount();">
<span class="glyphicon glyphicon-eye-open"></span></button></div>
<br>
<div class="list-group">
#if(count($category->subcategories))
#include('tree2',['subcategories'=>$category->subcategories])
#endif
</div>
#endforeach
View 2 : tree2
<div class='list-group'>
<br>
#foreach($subcategories as $subcategory)
<div class="list-group col-md-12">
<div class="collapse multi-collapse" id="{{ $category->id}}8" >
<div class="col-md-4"> {{ $subcategory->subaccount_name }}</div>
<div class=" float-right"><button class="btn btn-success" data-toggle="collapse" data-target="#{{ $subcategory->id}}" aria-expanded="false" aria-controls="collapseExample2">
<span class="glyphicon glyphicon-eye-open"></span></button></div>
</div>
</div>
#endforeach
</div>
Thank you

Laravel crash after adding a raw

Im displaying a treeview data and everything works perfecly.
But when i add the fourth raw, Laravel crash.
I want to post my code but i don't even know which one and where that came from..
view :
<div class="list-group">
<div class="col-md-12">
<div class="col-md-2">Departement</div>
<div class=" float-right">
<button class=" btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1" >
<span class="glyphicon glyphicon-eye-open"></span></button>
<button type="submit" class="btn btn-warning " data-toggle="modal" data-target="#exampleModalposition"><span class="glyphicon glyphicon-plus-sign"></span></button> </div>
</div>
<div class="list-group-item" name="state">
#foreach($treeViewPosition as $departement)
<div class=" collapse multi-collapse collapse in " id="8" >
<div class="col-md-2"> {{ $departement->departement_name}}</div>
<div class=" float-right"><button class="btn btn-success" data-toggle="collapse" data-target="#{{ $departement->id}}8" aria-expanded="false" aria-controls="{{ $departement->id}}8">
<span class="glyphicon glyphicon-eye-open"></span></button></div>
<div class="list-group">
#if(count($departement->position))
#include('treeposition2',['position'=>$departement->position])
#endif
</div>
#endforeach
</div>
</div>
</div>

Robot Framework doesn't find element correctly by xpath

Robot framework doesn't identify the element by xpath.
Following is the code
<div id="sticky-actions-sticky-wrapper" class="sticky-wrapper" style="height: 100px;"><section class="content-header" id="sticky-actions" style="">
<h1>Curriculum</h1>
<div class="breadcrumb save-message hidden">
<label class="text-success">
<i class="flaticon flaticon-circle-check"></i>
Saved <span>a few seconds ago</span>
</label>
</div>
<div class="row p-t-15">
<div class="col-xs-12">
<button type="button" class="btn btn-primary add-task-btn" disabled="">Create New Task</button>
<div class="btn-group m-r-15">
<button type="button" class="btn btn-primary dropdown-toggle add-statement-btn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="">
Create <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a tabindex="0" class="add-curriculum-btn">Curriculum</a></li>
<li><a tabindex="0" class="add-learning-area-btn hidden">Learning Area</a></li>
<li><a tabindex="0" class="add-topic-btn hidden">Topic</a></li>
<li><a tabindex="0" class="add-outcome-btn hidden">Outcome</a></li>
</ul>
</div>
<button type="button" class="btn btn-circle btn-xs blue link-statements-btn" disabled="" data-toggle="tooltip" data-placement="top" title="" data-original-title="Link selected statements">
<i class="fa fa-link"></i>
</button>
</div>
</div>
</section></div>
Xpath I used to for find "Create" button:
xpath=//*[#id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button
xpath=//*[#id="sticky-actions"]/div[2]/div/div/button[.//text() = 'Create']
Robot Framework step:
click element xpath=//*[#id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button
Error:-
ValueError: Element locator 'xpath=//*[#id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button' did not match any elements.
According to your XML, there is a section element inside the first div which you didn't include in your XPath. It should work if you add it:
//*[#id="sticky-actions-sticky-wrapper"]/section/div[2]/div/div/button
or
//*[#id="sticky-actions"]/div[2]/section/div/div/button[.//text() = 'Create']

How can I select drop down menu and click on the drop down item with watir webdriver

My code to click on the Drop Down:
browser.select_list(:class => "ui-select-match").click
My Code to select from the list:
browser.select_list(:name => "system-parameter").clear
puts browser.select_list(:name => "system-parameter").options
browser.select_list(:name => "system-parameter").select("Brand")
HTML to click on Drop down menu:
<div class="ui-select-match" ng-hide="$select.open" ng-disabled="$select.disabled" ng-class="{'btn-default-focus':$select.focus}" placeholder="Select System Parameter">
<span tabindex="-1" class="btn btn-default form-control ui-select-toggle" aria-label="Select box activate" ng-disabled="$select.disabled" ng-click="$select.activate()" style="outline: 0;">
<span ng-show="$select.isEmpty()" class="ui-select-placeholder text-muted ng-binding">Select System Parameter</span>
<span ng-hide="$select.isEmpty()" class="ui-select-match-text pull-left ng-hide" ng-class="{'ui-select-allow-clear': $select.allowClear && !$select.isEmpty()}" ng-transclude="">
<span class="ng-binding ng-scope"></span>
</span> <i class="caret pull-right" ng-click="$select.toggle($event)">
</i> <a ng-show="$select.allowClear && !$select.isEmpty()" aria-label="Select box clear" style="margin-right: 10px" ng-click="$select.clear($event)" class="btn btn-xs btn-link pull-right ng-hide">
<i class="glyphicon glyphicon-remove" aria-hidden="true">
</i>
</a>
</span>
</div>
HTML code to select from the list:
<a href="javascript:void(0)" class="ui-select-choices-row-inner" uis-transclude-append="">
<div ng-bind-html="constant.Value | highlight: $select.search" name="Brand" class="ng-binding ng-scope">Brand</div>
</a>
<a href="javascript:void(0)" class="ui-select-choices-row-inner" uis-transclude-append="">
<div ng-bind-html="constant.Value | highlight: $select.search" name="Group" class="ng-binding ng-scope">Group</div>
</a>
<a href="javascript:void(0)" class="ui-select-choices-row-inner" uis-transclude-append="">
<div ng-bind-html="constant.Value | highlight: $select.search" name="Unit" class="ng-binding ng-scope">Unit</div>
</a>
I am trying to click on the Drop-Down list and not able to select also from the list.
You need to use select_list for elements within a select tag as per the ruby docs suggest
See more here
Class::Watir::SelectList

Resources