In my application I have three listitems File Upload,View Reports and Change Password. I need to hide View Reports if the login is by normal user and i need to display View Reports if the login is by manager. Below is the code of my tabs
Code in master page-
<div class="wrapper">
<div class="menu">
<div class="menu">
<ul id="drop-nav">
<li id="MenuFileUpload" runat="server">File Upload
<ul>
<li>View Uploaded Data</li>
</ul>
</li>
<li id="MenuReports" runat="server">View Reports<ul>
<li>Report1</li>
<li>Reports2</li>
<li>Report3</li>
</ul>
</li>
<li id="lichangepwd" runat="server"><a id="A1" href="ChangePassword.jsp" runat="server">Change Password</a></li>
<div style="width:auto;float:right;font-weight:bold;padding-right:0cm;">
<li id="lilogout"> Logout</li></div>
<div style="float: left;text-align:right; width: 64%;">
<asp:Label ID="lblmsg" runat="server" ForeColor="Red" BorderColor="White" Text="Label" Font-Size="Small"></asp:Label> </div>
</ul>
</div>
</div>
code in login page-
if(role.equals("Supervisor"))
{
reports.visible=false;
}
I had tried by making reports.visible=false; which we will do in .net but its not working in java
Well basically, you pass some dto that represents logged user into the view.
Dto (Data transfer object) in most cases contains (login, firstname, lastname and role). Then in the code you do some thing like this:
<c:if test="${loggedUserDto.getRole() eq 'ADMIN'}">
<li id="MenuReports" runat="server">View Reports<ul>
....
</li>
</c:if>
If you use spring security :
<%# taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authorize access="hasRole('ADMIN')">
<li ....>
</sec:
Related
I'm trying to click on a Submit button within an iFrame. Trying to switch with iFrame id gives "Blocked a frame with origin from accessing a cross-origin frame" error.
<iframe id="challengeFrame" name="challengeFrame" width="250" height="400">
<html>
<body>
<form id="capture" class="challenge-form" action="capture" method="POST">
<div class="column">
<ul class="options">
<li>
....
</li>
<li>
...
</li>
</ul>
</div>
<div class="column">
<input type="submit" class="button" value="Submit">
</div>
</form>
</body>
</html>
</iframe>
In the above iFrame I need to click on the submit button. Please suggest any method with example to achieve this in Selenium Java/JS framework.
Be sure to include in your chrome options this argument:
options.add_argument("--disable-web-security")
This should disable the CORS check.
On users.html, there is the main and industries tab.
When I load users.html I want industries tab to load. how do I do it?
<div class='tabs-x tabs-above tabs-krajee'>
<ul id="myTab-tabs-above" class="nav nav-tabs" role="tablist">
<li class="active">
Main</li>
<li>Industries</li>
</ul>
<!-- Tab content refers to this part -->
<div id="tabs-content" class="tab-content">
<div id="home-tabs" class="tab-pane fade in active">
<div th:include="fragments/admin/companyProfile::companyProfile(${currentAccountant})"></div>
</div>
<div id="users-tabs" class="tab-pane fade">
<div th:include="fragments/admin/users::users">a</div>
</div>
</div>
</div>
Following code loads userDetails but I want a specific tab to be selected on loading. How do I do it?
#RequestMapping(value = "/load", method = RequestMethod.GET)
public ModelAndView load() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("userDetails");
return modelAndView;
}
You need to trigger tab show on document load.
Check documentation
<div class='tabs-x tabs-above tabs-krajee'>
<ul id="myTab-tabs-above" class="nav nav-tabs" role="tablist">
<li class="active">
Main</li>
<li>Industries</li>
</ul>
<!-- Tab content refers to this part -->
<div id="tabs-content" class="tab-content">
<div id="home-tabs" class="tab-pane fade in active">
<div th:include="fragments/admin/companyProfile::companyProfile(${currentAccountant})"></div>
</div>
<div id="users-tabs" class="tab-pane fade">
<div th:include="fragments/admin/users::users">a</div>
</div>
</div>
</div>
<script th:inline="javascript">
var tabToSelect = "users-tabs";
$(document).ready(function() {
$('#myTab-tabs-above a[href="#'+tabToSelect+'"]').tab('show')
});
</script>
You are not specified that which tab to select. How do you want to separate the logic for adding Main and industries.
In Controller
if you want to show MainTab
modelAndView.addObject("mainTabAddOrNot","show");
otherwise
modelAndView.addObject("mainTabAddOrNot",null);
In Thymeleaf side:
<li th:if="$(mainTabAddOrNot)" >
Main</li>
<li>Industries</li>
It is just an example to give an idea to use conditions in thymeleaf for specific tag adding. Hope it will give you an idea.
There is no need to change your controller code neither javascript. Just set your tab active .
Also you must set the Industries tab active.
<a class="list-group-item list-group-item-action active" data-toggle="list" href="#industries"
role="tab">
Industries Tab Data
</a>
<div class="tab-pane fade show active" id="industries" role="tabpanel">
How can I retrieve a set of links present as list items in an ordered list using XPath? I need to retrieve all sections from a forum with the following html code:
<div id="pagewrapper" class="fixed">
<div id="toplinks" class="toplinks" style="position: relative; top: 145px;">
<div class="above_body" style="height: 210px;">
<div class="body_wrapper">
<div id="breadcrumb" class="breadcrumb">
<div id="pagetitle">
<ol id="forums" class="floatcontainer">
<li id="cat3" class="forumbit_nopost new L1">
<div class="forumhead tcat foruminfo L1 collapse">
<div class="tbody_left">
<div class="tbody_right">
<ol id="c_cat3" class="childforum">
<li id="forum9" class="forumbit_post new L2">
<div class="forumrow table">
<div class="foruminfo td" style="padding-top: 12px; padding-bottom: 12px;">
<img id="forum_statusicon_9" class="forumicon" alt="" src="elitex360/statusicon/forum_new-48.png">
<div class="forumdata">
<div class="datacontainer">
<div class="titleline">
<h2 class="forumtitle">
Forum index <!-- get this link -->
</h2>
</div>
<p class="forumdescription">
</div>
</div>
</div>
<h4 class="nocss_label">Forum Actions:</h4>
<h4 class="nocss_label">Forum Statistics:</h4>
<ul class="forumstats td" style="padding-top: 18px; padding-bottom: 12px;">
<div class="forumlastpost td">
</div>
</li>
<li id="forum22" class="forumbit_post new L2">
<li id="forum40" class="forumbit_post new L2">
</ol>
<div class="tbody_under"></div>
</div>
</div>
<div class="tfoot">
</li>
<li id="cat4" class="forumbit_nopost new L1">
<li id="cat52" class="forumbit_nopost new L1">
<li id="cat5" class="forumbit_nopost new L1">
<li id="cat6" class="forumbit_nopost new L1">
<li id="cat7" class="forumbit_nopost old L1">
</ol>
The section links I have to retrieve are marked in the code above (<!-- get this link -->). I am now using the following string to retrieve all list items:
//div[#id='pagewrapper']/div[3]/ol
retrieving all list items. But I don't know how to "enter" each list item and retrieve the link label's contents. In the examples I found, knowledge of the number of list items is necessary prior to accessing them. That is not the case as the forum may have a different number of list items (the template is for a forum engine, not a forum in particular).
How can I retrieve all links within the list items?
Try below xpath to get the URL:-
//a[contains(.,'Forum index')]/#href
If you want all li in ol as I understand from you question then the xpath is as below:-
//div[#id='pagewrapper']//li[#id='cat3']//ol//li
I think Below is the xpath you are expecting:-
//div[#id='pagewrapper']//div/#href
Hope it will help you :)
I need a condition in product.tag based on current user is logged in or not?
Can I put this based on spring header.tag file
<div id="userSettings" class="top-nav-bar-layer user-settings header-popup menu-container" style="display:none; right:0;">
<ul data-role="listview" data-inset="true" data-theme="f">
<sec:authorize ifAnyGranted="ROLE_ANONYMOUS">
</sec:authorize>
<li>
</li>
<sec:authorize ifNotGranted="ROLE_ANONYMOUS">
<li>
</li>
</sec:authorize>
</ul>
</div>
Use this tag:
<sec:authorize ifAnyGranted="ROLE_CUSTOMERGROUP"></sec:authorize>
I have a tree generated with JSTree in my JSP page (part of a Struts2 webapp) as follows:
<div class="panel">
<div id="demo1" class="demo">
<ul>
<li id="node"><s:property value="product"/>
<ul>
<li id="node">
Dependents
<ul>
<s:iterator value="dependentsList" id="dependent">
<li id="node">
<a href="#">
<s:property value="productName"/></a>
<ul>
<li>
<a href="#">
Version Number: <s:property value="version" />
</a>
</li>
<s:if test="documentationLink != ''">
<li>
<a href="<s:property value="documentationLink" />">
Link to Product Documentation
</a>
</li>
</s:if>
</ul>
</li>
</s:iterator>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<script type="text/javascript" >
$(function () {
$("#demo1").jstree(
{
"core" :
{
"initially_open" : [ "#node" ]
},
"themes" :
{
"theme" : "default",
"icons" : false
},
"plugins" : [ "themes", "html_data", "ui"]
});
});
</script>
Thing is the links to product documentation show up on my browser (I tried using both Firefox and Internet Explorer) on the bottom status bar, but when I click on them, nothing pops up (I checked my HTML source code, and the anchor tags are showing the correct URL links). Could anyone figure out why my links aren't working? I am using both the latest versions of JQuery and JSTree. Thanks!
I got the links to work after removing the UI plugin, I guess the UI plugin doesn't like to work with HTML links...