Reputation: 1203
I am writing a oracle ADF fusion web app using jdeveloper 11.1.2.0.0. In a jspx page I have a drop down list which is populated by a menu model. I want it to be shown expanded when the page loads in the browser. Please give me an idea.
Thanks Sameera
Upvotes: 0
Views: 1712
Reputation: 29806
it is true that there is no direct or programmatic way to emulate the triggering of click event on a dropdown to open it, but you can do this by the following code. What you need are:
The bean who supplies the List of SelectItem is:
import java.util.ArrayList;
import java.util.List;
import javax.faces.model.SelectItem;
public class BackBean {
private List<SelectItem> options;
public BackBean() {
options = new ArrayList<SelectItem>(0);
options.add(new SelectItem("Option 1", "Option 1"));
options.add(new SelectItem("Option 2", "Option 2"));
options.add(new SelectItem("Option 3", "Option 3"));
options.add(new SelectItem("Option 4", "Option 4"));
options.add(new SelectItem("Option 5", "Option 5"));
}
public void setOptions(List<SelectItem> options) {
this.options = options;
}
public List<SelectItem> getOptions() {
return options;
}
}
And the jspx page is:
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document title="Home" id="d1">
<af:form id="f1">
<af:resource type="javascript" source="/js/jquery-1.7.1.min.js"/>
<af:resource type="javascript" source="/js/ExpandSelect.js"/>
<af:panelStretchLayout id="psl1">
<f:facet name="center">
<af:selectOneChoice label="Menu" id="soc1" clientComponent="true" styleClass="menu">
<f:selectItems value="#{backingBeanScope.backBean.options}" id="si1"/>
</af:selectOneChoice>
</f:facet>
</af:panelStretchLayout>
</af:form>
<af:resource type="javascript">
$(document).ready(function(){
ExpandSelect(document.getElementById($($('.menu > tbody > tr > td').next().find('select')).attr('id')));
});
</af:resource>
</af:document>
</f:view>
</jsp:root>
Here is the screenshot I have:
Hope this will help. Let me know your feedback.
Upvotes: 0
Reputation: 4812
There is no programmatic(meaning javascript) way of triggering the disclosure of a native dropdown element. As advised by others, consider using a different UI strategy. Maybe an af:table that is selectable?
Upvotes: 0
Reputation: 3721
Consider using another type of component instead of a drop down. For example how about just using an iterator to show the list of options?
Upvotes: 1