Calling javascript from tree component
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Yes there's a way but not built-in yet. For now after body is loaded you can do something like;
And <t:tree widgetVar="yourtree" .../>
Code: Select all
yourtree.subscribe("labelClick", function(node) {
//your code here
});
Hi Cagatay. I could not get you. My tree.jsp is like this:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://primefaces.prime.com.tr/ui" prefix="p"%>
<%@ taglib uri="primefaces-ui.tld" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<f:view>
<f:loadBundle basename="com.dms.res.caption" var="msg" />
<head>
<title></title>
<p:resources />
</head>
<body>
<style type="text/css">
.yui-skin-sam .yuimenuitemlabel {
color: #000000;
font: Arial;
font-size: 12px;
font-weight: BOLD;
}
</style>
<h:form>
<input type="button" value="Process" onclick="menu.show()"/> <img height="25" src="../images/refresh.gif" /><br><br>
<s:tree value="#{treeBean.model}" cache="false" toggleMode="async" nodeSelectListener="#{treeBean.onNodeSelect}" nodeExpandListener="#{treeBean.onNodeExpand}" nodeCollapseListener="#{treeBean.onNodeCollapse}" ></s:tree> </h:form>
</body>
</f:view>
</html>
please make me understand
yourtree.subscribe("labelClick", function(node) {
//your code here
});
Where I should write this??
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://primefaces.prime.com.tr/ui" prefix="p"%>
<%@ taglib uri="primefaces-ui.tld" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<f:view>
<f:loadBundle basename="com.dms.res.caption" var="msg" />
<head>
<title></title>
<p:resources />
</head>
<body>
<style type="text/css">
.yui-skin-sam .yuimenuitemlabel {
color: #000000;
font: Arial;
font-size: 12px;
font-weight: BOLD;
}
</style>
<h:form>
<input type="button" value="Process" onclick="menu.show()"/> <img height="25" src="../images/refresh.gif" /><br><br>
<s:tree value="#{treeBean.model}" cache="false" toggleMode="async" nodeSelectListener="#{treeBean.onNodeSelect}" nodeExpandListener="#{treeBean.onNodeExpand}" nodeCollapseListener="#{treeBean.onNodeCollapse}" ></s:tree> </h:form>
</body>
</f:view>
</html>
please make me understand
yourtree.subscribe("labelClick", function(node) {
//your code here
});
Where I should write this??
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
You need to place it in a script like(ideally in <head></head> tags);
And attach it after body loads, legacy way to do is;
<body onload="ontreelabelclick();">
Code: Select all
<script type="text/javascript">
function ontreelabelclick() {
yourtree.subscribe("labelClick", function(node) {
//your code here
});
}
</script>
<body onload="ontreelabelclick();">
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Please see the discussions above.
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Do you have <p:tree widgetVar="yourtee"... ?
Hi....... I am waiting for your reply.
Calling a javascript applying your suggestion is working fine in Mozilla. However the javascript error "yourtree as an undefined object" is there when I am opening my page in IE6/IE7. Please let me know how to solve this problem.
Calling a javascript applying your suggestion is working fine in Mozilla. However the javascript error "yourtree as an undefined object" is there when I am opening my page in IE6/IE7. Please let me know how to solve this problem.
-
- Information
-
Who is online
Users browsing this forum: Baidu [Spider] and 20 guests