Property 'onExpand' not found error(in fact, 'onExpand' is a
chicochen Jul 4, 2007 11:33 PMI got a error :
/page/test.xhtml: Property 'onExpand' not found on type com.eastidea.qaforum.test.Bean_$$_javassist_21
bug in fact, 'onExpand' is a even.
test.xhtml, using facelets
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:dnd="http://richfaces.ajax4jsf.org/drag-drop" xmlns:rich="http://richfaces.ajax4jsf.org/tree" xmlns:s="http://jboss.com/products/seam/taglib"> <head> <title></title> <style type="text/css"> .inputs { font-size : 11px; font-family : verdana; } .customNode { color : #00FFFF; cursor: crosshair; } .colored { background-color: #FEFEDE; } </style> </head> <body> <f:view> <a4j:outputPanel ajaxRendered="true"> <h:messages /> </a4j:outputPanel> <h:form> <dnd:dragIndicator id="treeIndicator"> <f:facet name="single"> <f:verbatim>{marker} <br /> {treeParam} <br /> {nodeParam}</f:verbatim> </f:facet> </dnd:dragIndicator> <h:selectOneRadio binding="#{skinBean.component}" /> <h:commandLink action="#{skinBean.change}" value="set skin" /> <br /> <h:outputText value="Change tree switchType:" /> <h:selectOneRadio value="#{bean.switchType}" onclick="submit()"> <f:selectItem itemLabel="client" itemValue="client" /> <f:selectItem itemLabel="server" itemValue="server" /> <f:selectItem itemLabel="ajax" itemValue="ajax" /> </h:selectOneRadio> <h:outputText value="SwitchType is: #{bean.switchType}" /> <br /> <h:outputText value="Drag switch:" /> <h:selectOneRadio value="#{bean.dragOn}" onclick="submit()"> <f:selectItem itemLabel="on" itemValue="#{true}" /> <f:selectItem itemLabel="off" itemValue="#{false}" /> </h:selectOneRadio> <h:outputText value="Render facets:" /> <h:selectOneRadio value="#{bean.renderFacets}" onclick="submit()"> <f:selectItem itemLabel="true" itemValue="#{true}" /> <f:selectItem itemLabel="false" itemValue="#{false}" /> </h:selectOneRadio> <h:outputText value="Drag is: #{bean.dragOn ? 'on' : 'off'}" /> <br /> <h:commandButton value="#{bean.commandButtonCaption}" actionListener="#{bean.changeIcons}" /> <rich:tree id="tree" switchType="#{bean.switchType}" value="#{bean.data}" var="data" nodeFace="#{data.name != 'param-value' ? 'input' : 'text'}" changeExpandListener="#{bean.onExpand}" nodeSelectListener="#{bean.onSelect}" binding="#{bean.tree}" onselected="window.status='selectedNode: '+event.selectedNode;" onexpand="window.status='expandedNode: '+event.expandedNode" oncollapse="window.status='collapsedNode: '+event.collapsedNode" ajaxSubmitSelection="true" reRender="outputText, selectOneListbox" preserveModel="none" dragIndicator="treeIndicator" immediate="false" acceptedTypes="file1" dragType="#{bean.dragOn ? 'file1' : ''}" iconCollapsed="#{bean.iconCollapsed}" iconExpanded="#{bean.iconExpanded}" iconLeaf="#{bean.iconLeaf}" icon="#{bean.icon}" dropListener="#{bean.processDrop}"> <f:facet name="icon"> <h:outputText value="icon" rendered="#{bean.renderFacets}"/> </f:facet> <f:facet name="iconLeaf"> <h:outputText value="leaf" rendered="#{bean.renderFacets}"/> </f:facet> <f:facet name="iconExpanded"> <h:outputText value="expanded" rendered="#{bean.renderFacets}"/> </f:facet> <f:facet name="iconCollapsed"> <h:outputText value="collapsed" rendered="#{bean.renderFacets}"/> </f:facet> <dnd:dndParam name="treeParam" value="Tree Parameter" /> <dnd:dndParam name="accept" value="accept" /> <rich:treeNode type="input" dropListener="#{bean.processDrop}" oncollapse="Element.removeClassName(event['treeItem'].getElement(), 'colored')" onexpand="Element.addClassName(event['treeItem'].getElement(), 'colored')"> <h:outputText value="#{data} : " /> <h:inputText value="#{data.name}" required="true" styleClass="inputs"> </h:inputText> <dnd:dndParam name="nodeParam" value="Node Parameter" /> </rich:treeNode> <rich:treeNode type="text" nodeClass="customNode" acceptedTypes="file2" onselected="return false;"> <h:outputText value="#{data}" /> </rich:treeNode> </rich:tree> <h:outputText value="Enter path to expand, eg. [webApp_:id__1 , webApp_:id__1:7 ]:" /> <h:inputText value="#{bean.pathToExpand}"> <a4j:support event="onchange" reRender="tree" action="#{bean.expandNode}"/> </h:inputText> <f:verbatim> <br /> <br /> </f:verbatim> <rich:tree id="testTree" var="_data" switchType="ajax" ajaxSubmitSelection="true" preserveModel="none" value="#{bean.data1}" nodeSelectListener="#{bean.onSelectInc}" nodeFace="node"> <rich:treeNode type="node"> <h:outputText value="#{_data}" /> </rich:treeNode> </rich:tree> </h:form> <a4j:status startText="...start..." /> <a4j:log hotkey="O" /> </f:view> </body> </html>
package com.eastidea.qaforum.test; import java.io.IOException; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import javax.faces.FacesException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.event.FacesEvent; import org.ajax4jsf.dnd.event.DropEvent; import org.ajax4jsf.framework.ajax.AjaxContext; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.richfaces.component.ListRowKey; import org.richfaces.component.TreeNode; import org.richfaces.component.TreeNodeImpl; import org.richfaces.component.TreeRowKey; import org.richfaces.component.UITree; import org.richfaces.component.UITreeNode; import org.richfaces.component.events.NodeExpandedEvent; import org.richfaces.component.events.NodeSelectedEvent; import org.richfaces.component.xml.XmlTreeDataBuilder; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.jboss.seam.annotations.Scope; import org.jboss.seam.ScopeType; @Name("bean") @Scope(ScopeType.SESSION) public class Bean { private String switchType = "client"; private TreeNode data; private TreeNode selectedNode = null; private Map selectedNodeChildren = new LinkedHashMap(); private String commandButtonCaption = "Set user icons"; private String iconCollapsed = null; private String iconExpanded = null; private String iconLeaf = null; private String icon = null; private boolean renderFacets = false; private String pathToExpand; private boolean dragOn = true; private TreeNodeImpl data1; private int counter = 0; public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public String getCommandButtonCaption() { return commandButtonCaption; } public void setCommandButtonCaption(String commandButtonCaption) { this.commandButtonCaption = commandButtonCaption; } public void changeIcons(javax.faces.event.ActionEvent event) { if (null == icon) { iconCollapsed = "/images/header.png"; iconExpanded = "/images/item.png"; iconLeaf = "/images/ajax_process.gif"; icon = "/images/ajax_stoped.gif"; commandButtonCaption = "Set defoult icons"; } else { iconCollapsed = null; iconExpanded = null; iconLeaf = null; icon = null; commandButtonCaption = "Set user icons"; } } public Bean() { try { FacesContext context = FacesContext.getCurrentInstance(); data = XmlTreeDataBuilder.build(new InputSource( getClass().getResourceAsStream("test.xml"))); TreeNode pomData = XmlTreeDataBuilder.build(new InputSource( getClass().getResourceAsStream("pom_sample.xml"))); Iterator children = pomData.getChildren(); while (children.hasNext()) { Map.Entry entry = (Map.Entry) children.next(); data.addChild(new Long(1), (TreeNode) entry.getValue()); } } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } data1 = new TreeNodeImpl(); data1.setData("Root node"); for (int i = 0; i < 10; i++) { TreeNodeImpl child = new TreeNodeImpl() { public Object getData() { return super.getData() + " " + counter; } }; String id = Integer.toString(i); child.setData("Node: " + id); data1.addChild(id, child); } initData(); } public TreeNode getData() { return data; } public String getSwitchType() { return switchType; } public void setSwitchType(String switchType) { this.switchType = switchType; } private UITree getTree(FacesEvent event) { UIComponent component = event.getComponent(); if (component instanceof UITree) { return ((UITree) component); } if (component instanceof UITreeNode) { return ((UITree) component.getParent()); } return null; } public void up() { if(selectedNode.getParent()!=null) { selectedNode = selectedNode.getParent(); } initData(); } public void onSelect(NodeSelectedEvent event) { System.out.println("Node selected: " + getTree(event).getRowKey()); if (getTree(event).getTreeNode()!=null) { selectedNode = getTree(event).getTreeNode(); initData(); } } public void onSelectInc(NodeSelectedEvent event) { counter ++; UITree tree = getTree(event); TreeRowKey key = (TreeRowKey)tree.getRowKey(); Set keys = tree.getAjaxKeys(); if (keys == null) { keys = new HashSet(); tree.setAjaxKeys(keys); } AjaxContext ajaxCtx = AjaxContext.getCurrentInstance(); FacesContext fctx = FacesContext.getCurrentInstance(); tree.setRowKey(null); // Force more than one node to update here: for (int i = 0; i < 5; i++) { ListRowKey dirtyKey = new ListRowKey(Integer.toString(i)); keys.add(dirtyKey); tree.setRowKey(dirtyKey); ajaxCtx.addComponentToAjaxRender(tree.getParent(), tree.getClientId(fctx)); } tree.setRowKey(key); } private void initData() { selectedNodeChildren.clear(); if (selectedNode != null) { Iterator iter = selectedNode.getChildren(); int i = 0; while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); selectedNodeChildren.put(((TreeNode)entry.getValue()).getData(), Integer.toString(i++)); } } } public void onExpand(NodeExpandedEvent event) { UITree tree = getTree(event); System.out.println("Node " + (tree.isExpanded() ? "expanded" : "collapsed") + " " + tree.getRowKey()); } private String expandPath; private UITree tree; public String expand() { if (expandPath != null && expandPath.length() != 0) { try { tree.queueNodeExpand(new ListRowKey(expandPath)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; } public String getExpandPath() { return expandPath; } public void setExpandPath(String expandPath) { this.expandPath = expandPath; } public UIComponent getTree() { return tree; } public void setTree(UIComponent tree) { this.tree = (UITree) tree; } public String collapseAll() throws IOException { this.tree.queueCollapseAll(); return null; } public String expandAll() { try { this.tree.queueExpandAll(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } public Map getSelectedNodeChildren() { return selectedNodeChildren; } public void setSelectedNodeChildren(Map selectedNodeChildren) { this.selectedNodeChildren = selectedNodeChildren; } public TreeNode getSelectedNode() { return selectedNode; } public void setSelectedNode(TreeNode selectedNode) { this.selectedNode = selectedNode; } public void processDrop(DropEvent dropEvent) { System.out.println("Should be printed twice per event!!!"); System.out.println(dropEvent); System.out.println("DragValue: " + dropEvent.getDragValue()); System.out.println("DropValue: " + dropEvent.getDropValue()); System.out.println("Drag row data: " + getTree(dropEvent).getRowData(dropEvent.getDragValue())); System.out.println("Drop row data: " + getTree(dropEvent).getRowData(dropEvent.getDropValue())); System.out.println("+++++"); } public String getIconCollapsed() { return iconCollapsed; } public void setIconCollapsed(String iconCollapsed) { this.iconCollapsed = iconCollapsed; } public String getIconExpanded() { return iconExpanded; } public void setIconExpanded(String iconExpanded) { this.iconExpanded = iconExpanded; } public String getIconLeaf() { return iconLeaf; } public void setIconLeaf(String iconLeaf) { this.iconLeaf = iconLeaf; } public String getPathToExpand() { return pathToExpand; } public void setPathToExpand(String pathToExpand) { this.pathToExpand = pathToExpand; } public String expandNode() { String pathToExpand = getPathToExpand(); if (pathToExpand != null && pathToExpand.trim().length() != 0) { try { ((UITree) getTree()).queueNodeExpand(new ListRowKey(pathToExpand)); } catch (IOException e) { throw new FacesException(e); } } return null; } public boolean isDragOn() { return dragOn; } public void setDragOn(boolean dragOn) { this.dragOn = dragOn; } public TreeNodeImpl getData1() { return data1; } public void setData1(TreeNodeImpl data1) { this.data1 = data1; } public boolean isRenderFacets() { return renderFacets; } public void setRenderFacets(boolean renderFacets) { this.renderFacets = renderFacets; } }