How to bind dropdown list with collection in adobe CQ5..? - drop-down-menu

i'm new in Adobe CQ5, i'm developing a training project, here my requirement for binding a Dropdown list using Dialog, there author can add multiple item, and these item should be display in dropdown list, so how to do this,
i create a component with dialog
i assigned field what i need & also give an property as text field i'm able to bind it but i want to use them as collection
my code for component.jsp is:
<%#include file="/libs/foundation/global.jsp"%>
<%#page import="java.util.Iterator,com.day.text.Text,com.day.cq.wcm.api.Page,com.day.cq.wcm.foundation.Image,com.day.cq.commons.Doctype" %>
<div class="main-container">
<div class="hero-dropdown-container">
<div class="dropdown">
<button aria-expanded="false" data-toggle="dropdown" id="dropdownMenu1" type="button" class="menu-black-arrow btn btn-default status dropdown-toggle"><%= properties.get("itemText") %></button>
<ul aria-labelledby="dropdownMenu1" role="menu" class="dropdown-menu">
<li role="presentation"><a tabindex="-1" role="menuitem" href='<%= properties.get("itemValue") %>'><%= properties.get("itemText") %></a></li>
<li role="presentation"><a tabindex="-1" role="menuitem"><%= properties.get("itemValue") %></a></li>
<li role="presentation"><a tabindex="-1" role="menuitem">Something else here</a></li>
<li role="presentation"><a tabindex="-1" role="menuitem">Separated link</a></li>
</ul>
</div>
</div>
</div>

Since you need to associate itemText and itemValue the required xtype would be compositefield. But it doesn't work for multiple rows. The multifield xtype that's supposed to work with multiple rows doesn't work with a compositefield. What you will have to do is write a multi-compositefield.
Method to do this well documented on stackoverflow and adobe forums , few links :
https://helpx.adobe.com/experience-manager/using/creating-custom-xtype.html
Multifield component issue
However there are few open source solutions for this :
http://adobe-consulting-services.github.io/acs-aem-commons/features/widgets.html#multi-field-panel-since-150
https://github.com/Citytechinc/multicomposite-addon

Related

How to make dropdown items "clickable" by enter button?

I'm developing an app with Angular and Semantic-UI.
I have a dropdown menu like the following: https://plnkr.co/edit/BTCxfk
<div class="ui right labeled top pointing floating icon button dropdown">
<i class="icon folder open"></i>
<span class="text">Menu</span>
<div class="menu">
<div class="item" (click)="onClickItem()" *ngFor="#m of menu">
<i class="icon sign in"></i>
{{m}}
</div>
</div>
</div>
I would like to have that users can click on a single item using tab and enter buttons.
As you can see they can only move towards menu items, but they can't trigger the click event.
Any idea?
I would give this item a tab-index of 0 since most elements like this aren't tabbable by default.
<div class="ui right labeled top pointing floating icon button dropdown">
<i class="icon folder open"></i>
<span class="text" tabindex="0" role="menu">Menu</span>
<div class="menu">
<div class="item" (click)="onClickItem()" *ngFor="#m of menu">
<i class="icon sign in"></i>
{{m}}
</div>
</div>
</div>
I added tab index of 0 and role of menu.

Selenium - salesforce.com how to select an item in dropdown

I need help. I have been trying to automate selecting an item from a drop down menu. I have try many ways but I cannot get it to work. I using Selenium 2.39 firefox. The sample application is on https://www.salesforce.com/form/signup/freetrial-sales.jsp?d=70130000000EqoP&internal=true.
Any help will be appreciated. Thanks
The Xpath is: //*[#id='form-container']/ul/li[14]/div/div[2]/a/span[1]
Surrounded by :
<div id="form-container" class="clearfix wide-fields style-placeholder">
<div id="globalErrorMessage" style="display:none"> Please fill out the highlighted fields below </div>
<ul class="clearfix vertical form-ul">
<li class=" type-hidden">
<li class=" type-hidden">
<li class=" type-hidden">
<li class=" type-hidden">
<li class=" type-hidden">
<li class=" type-hidden">
<li class=" type-hidden">
<li class=" type-text">
<li class=" type-text">
<li class=" type-text">
<li class=" type-text">
<li class=" type-text">
<li class=" type-text">
<li class=" type-select">
<div class="control-container error">
<div class="label">
<div class="field">
<select id="CompanyEmployees" class="selectBox" name="CompanyEmployees" style="display: none;">
<a class="selectBox selectBox-dropdown" style="width: 296px; display: inline-block; -moz-user-select: none; "title="" tabindex="0">
<span class="selectBox-label" style="width: 262px;">Employees</span>
<span class="selectBox-arrow" />
</a>
<span class="form-field-error show-form-field-error">Select the number of employees</span>
</div>
<div class="info">
</div>
</li>
<li class=" type-hidden">
<li class=" type-hidden">
I have already tried using Select class but does not work.
Select select = new Select(driver.findElement(By.name("CompanyEmployees")));
select.selectByValue("250");
I get the following error:
....
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element is not currently visible and so may not be interacted with
...
There are 2 points for you to be noted:
It's not a dropdown control as such. You might have to go through some basic HTML sources on how to achieve a DropDown scenario without using the actual DropDown control.
Escaping sequence (notice inverted commas inside the XPath expression)
Below is C# code. I'm sure you can figure out the code in the language of your choice.
Driver.FindElement(By.XPath(#"(//*[#id=""form-container""])/ul/li[14]/div/div[2]/a/span[1]")).Click(); //Click on the DropDown
Driver.FindElement(By.XPath(#"/html/body/ul[1]/li[4]/a")).Click(); //selects "21 - 100 Employees"
Please try the following code for "employees" selection:
public void selectEmployees(){
WebDriver driver = new FirefoxDriver();
WebDriverWait driverWait = new WebDriverWait(driver, 30);
driver.get("https://www.salesforce.com/form/signup/freetrial-sales.jsp?d=70130000000EqoP&internal=true");
// Wait for visibility of Employees combobox and click on it to open drop-down list
// Combo-box is selected by css locator which searches for ".selectBox" element that are preceded by "#CompanyEmployees" element
WebElement emplyeesCombobox = driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#CompanyEmployees ~ .selectBox")));
emplyeesCombobox.click();
//Wait for visibility of required drop-down list item ("6 - 20 employees" in this example) and select it by clicking
// Drop-down list item is selected by XPath locator which searches for "a" element with "6 - 20 employees" text
WebElement itemToSelect = driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[text()='6 - 20 employees']")));
itemToSelect.click();
}
Hope it will help.

How capture dynamically populated dropdown list ids in Capybara

I am using Capybara,Rspec and Ruby for my development. I am having drop down list which is populated with values with dynamic ids because of which I am not able locate the element correctly. Here is HTML code. I tried to get the solution from this site as well as by googling. But I couldn't get the correct solution
when I am doing the firebug I am getting Xpath as //[#id='select2-result-label-8'] and every time I am getting new id in the last meaning, next time if I go I will get it as //[#id='select2-result-label-11']. How to resolve this issue. I am having similar issues with my group of check box also. Hope this solution will help there also
<ul id="Values" class="check" role="listbox">
<li class="Reports " role="presentation">
<div id="select2-result-label-3" class="history" role="option">
<span class="same"/>
Add New
</div>
</li>
<li class="Reports-highlighted" role="presentation">
<div id="select2-result-label-4" class="history" role="option">
<span class="same"/>
Multiple
</div>
</li>
<li class="Reports" role="presentation">
<div id="select2-result-label-5" class="history" role="option">
<span class="same"/>
Last
</div>
</li>
</ul>

Bootstrap hyperlink in navbar dropdown

Hyperlink in navbar dropdown doesn't seem to work.Even the "disabled" doesn't seem to work.
Here is my code
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li class="dropdown">
<a class="dropdown-toggle disabled"
data-toggle="dropdown" href="http://www.google.com"> Link
<b class="caret"></b> </a>
<ul class="dropdown-menu">
<li>menu1</li>
<li>menu2</li></ul>
</li>
</ul>
</div>
</div>
</div>
Clicking the link where you have set Google as the link won't take you to that link as the click action on that link opens/closes the dropdown menu.
If you put a link on another anchor tag you'll see that those will work fine.

Twitter Bootstrap Dropdown Hover Open and Stay Active

I read the question on how to get the dropdown to open on hover which was an excellent fix, however I would like to get the nav li to keep "open" class when going down into "dropdown-menu" ul. Here is a jsfiddle http://jsfiddle.net/someyoungideas/29txm/ for my problem.
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Help</a>
<ul class="dropdown-menu">
<li>New Item</li>
</ul>
</li>
</ul>
</div>
</div>​
One way to address your concern is to make use of the twitter-bootstrap-hover-dropdown plugin found on github. The plugin is also one of the answers in the old question: https://stackoverflow.com/a/12851616/538962.
Note the use of data-hover="dropdown" to call the plugin.
<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown"
data-delay="1000" data-close-others="false">Help</a>
Here is a working sample:
http://jsbin.com/xuwokuva/1

Resources