Client side code snipets
- by raghu.yadav
function clientMethodCall(event) {
component = event.getSource();
AdfCustomEvent.queue(component, "customEvent",{payload:component.getSubmittedValue()}, true);
event.cancel();
}
]]--
<af:document> <f:facet name="metaContainer"> <af:group> <!--[CDATA[ <script> function clientMethodCall(event) { component = event.getSource(); AdfCustomEvent.queue(component, "customEvent",{payload:component.getSubmittedValue()}, true); event.cancel(); } </script> ]]--> </af:group> </f:facet> <af:form> <af:panelformlayout> <f:facet name="footer"> <af:inputtext label="Let me spy on you: Please enter your mail password"> <af:clientlistener method="clientMethodCall" type="keyUp"> <af:serverlistener type="customEvent" method="#{customBean.handleRequest}"> </af:serverlistener>bean code public void handleRequest(ClientEvent event){ System.out.println("---"+event.getParameters().get("payload")); } tree<af:tree id="tree1" value="#{bindings.DepartmentsView11.treeModel}" var="node" selectionlistener="#{bindings.DepartmentsView11.treeModel.makeCurrent}" rowselection="single"> <f:facet name="nodeStamp"> <af:outputtext value="#{node}"> </af:outputtext> <af:clientlistener method="expandNode" type="selection"> </af:clientlistener></f:facet> <f:facet name="metaContainer"> <af:group> <!--[CDATA[ <script> function expandNode(event){ var _tree = event.getSource(); rwKeySet = event.getAddedSet(); var firstRowKey; for(rowKey in rwKeySet){ firstRowKey = rowKey; // we are interested in the first hit, so break out here break; } if (_tree.isPathExpanded(firstRowKey)){ _tree.setDisclosedRowKey(firstRowKey,false); } else{ _tree.setDisclosedRowKey(firstRowKey,true); } } </script> ]]--> </af:group> </f:facet> </af:tree> </af:clientlistener></af:inputtext></f:facet></af:panelformlayout></af:form></af:document>
bean code
public void handleRequest(ClientEvent event){
System.out.println("---"+event.getParameters().get("payload"));
}
tree
function expandNode(event){
var _tree = event.getSource();
rwKeySet = event.getAddedSet();
var firstRowKey;
for(rowKey in rwKeySet){
firstRowKey = rowKey;
// we are interested in the first hit, so break out here
break;
}
if (_tree.isPathExpanded(firstRowKey)){
_tree.setDisclosedRowKey(firstRowKey,false);
}
else{
_tree.setDisclosedRowKey(firstRowKey,true);
}
}
]]--