[
https://issues.jboss.org/browse/RF-12638?page=com.atlassian.jira.plugin.s...
]
Brian Leathem updated RF-12638:
-------------------------------
Steps to Reproduce:
1.) call the view with
"http://localhost:8084/web-jsf-richfaces/ajtest.html?dsId=55" the Id on the
right site will be 55 (Its the viewParam).
2.) select a node.
3.) press submit button ==> Id will be "null"
4.) select a node Id will be 55 again and so on
{code:title=ajtest.xml}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:metadata>
<f:viewParam name="dsId" value="#{myBean.dataSourceId}"
/>
</f:metadata>
<f:view>
<h:head>
<title>Tree Test</title>
<meta http-equiv="content-type" content="text/xhtml;
charset=UTF-8" />
</h:head>
<h:body>
<h1>Tree Test</h1>
<h:panelGrid columns="3" id="pagePanelGrid" >
<h:form id="plSearchForm">
<rich:panel title="PL Search"
id="plSearchPanel">
<rich:tree value="#{myBean.rootFolder}"
var="node" toggleType="client" selectionType="ajax"
selectionChangeListener="#{myBean.processPlTreeSelectionChange}">
<rich:treeNode>
<h:outputText value="#{node.name}" />
</rich:treeNode>
</rich:tree>
</rich:panel>
</h:form>
<a4j:outputPanel ajaxRendered="true"
id="plDpEditPanelGrid">
<h:form id="dsEditForm">
<rich:panel id="dsPropEditPanel">
<h:outputLabel value="Test" />
<a4j:commandButton id="dsSaveButton"
render="@form :plListForm:plListPanel" execute="@form"
action="#{myBean.saveDataSource}" />
<h:panelGrid columns="2">
<h:outputLabel value="Id:"
for="dsName"/>
<h:inputText value="#{myBean.id}"
id="dsName" />
</h:panelGrid>
</rich:panel>
</h:form>
</a4j:outputPanel>
</h:panelGrid>
</h:body>
</f:view>
</html>
{code}
{code:title=MyBean.java}
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.AbortProcessingException;
import org.richfaces.event.TreeSelectionChangeEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ManagedBean
@ViewScoped
public class MyBean implements Serializable {
private final static Logger LOG = LoggerFactory.getLogger(MyBean.class);
private Integer dataSourceId;
private MyTreeNode rootFolder;
public MyBean() {
super();
}
public Integer getDataSourceId() {
return dataSourceId;
}
public void setDataSourceId(Integer id) {
this.dataSourceId = id;
}
public void saveDataSource() {
}
public MyTreeNode getRootFolder() {
if (rootFolder == null) {
rootFolder = new MyTreeNode("ROOT");
rootFolder.addChild("a", rootFolder);
rootFolder.addChild("b", rootFolder);
rootFolder.addChild("c", rootFolder);
}
return rootFolder;
}
public void setRootFolder(MyTreeNode rootFolder) {
this.rootFolder = rootFolder;
}
public void processPlTreeSelectionChange(TreeSelectionChangeEvent event) throws
AbortProcessingException {
}
public String getId() {
return String.valueOf(dataSourceId);
}
}
{code}
{code:title=MyTreeNode.java}
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.richfaces.model.TreeNode;
public class MyTreeNode implements TreeNode, Serializable {
private String name;
private List<TreeNode> nodes = new ArrayList();
private List<String> names = new ArrayList();
public MyTreeNode() {
super();
}
public MyTreeNode(String name) {
this();
this.name = name;
}
@Override
public TreeNode getChild(Object o) {
if (o instanceof String) {
return nodes.get(names.indexOf(o));
} else {
throw new RuntimeException("Unknown object: " + o);
}
}
@Override
public int indexOf(Object o) {
if (o instanceof String) {
return names.indexOf(o);
} else {
throw new RuntimeException("Unknown object: " + o);
}
}
@Override
public Iterator<Object> getChildrenKeysIterator() {
return new Iterator<Object>() {
int pos;
@Override
public boolean hasNext() {
return pos < names.size();
}
@Override
public Object next() {
return names.get(pos++);
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
@Override
public boolean isLeaf() {
return name.isEmpty();
}
@Override
public void addChild(Object o, TreeNode tn) {
((MyTreeNode) tn).names.add((String) o);
((MyTreeNode) tn).nodes.add(new MyTreeNode((String) o));
}
@Override
public void insertChild(int i, Object o, TreeNode tn) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeChild(Object o) {
throw new UnsupportedOperationException("Not supported yet.");
}
public String getName() {
return name;
}
@Override
public String toString() {
return getName();
}
}
{code}
was:
1.) call the view with
"http://localhost:8084/web-jsf-richfaces/ajtest.html?dsId=55" the Id on the
right site will be 55 (Its the viewParam).
2.) select a node.
3.) press submit button ==> Id will be "null"
4.) select a node Id will be 55 again and so on
Code:
ajtest.xml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:metadata>
<f:viewParam name="dsId" value="#{myBean.dataSourceId}"
/>
</f:metadata>
<f:view>
<h:head>
<title>Tree Test</title>
<meta http-equiv="content-type" content="text/xhtml;
charset=UTF-8" />
</h:head>
<h:body>
<h1>Tree Test</h1>
<h:panelGrid columns="3" id="pagePanelGrid" >
<h:form id="plSearchForm">
<rich:panel title="PL Search"
id="plSearchPanel">
<rich:tree value="#{myBean.rootFolder}"
var="node" toggleType="client" selectionType="ajax"
selectionChangeListener="#{myBean.processPlTreeSelectionChange}">
<rich:treeNode>
<h:outputText value="#{node.name}" />
</rich:treeNode>
</rich:tree>
</rich:panel>
</h:form>
<a4j:outputPanel ajaxRendered="true"
id="plDpEditPanelGrid">
<h:form id="dsEditForm">
<rich:panel id="dsPropEditPanel">
<h:outputLabel value="Test" />
<a4j:commandButton id="dsSaveButton"
render="@form :plListForm:plListPanel" execute="@form"
action="#{myBean.saveDataSource}" />
<h:panelGrid columns="2">
<h:outputLabel value="Id:"
for="dsName"/>
<h:inputText value="#{myBean.id}"
id="dsName" />
</h:panelGrid>
</rich:panel>
</h:form>
</a4j:outputPanel>
</h:panelGrid>
</h:body>
</f:view>
</html>
MyBean.java
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.AbortProcessingException;
import org.richfaces.event.TreeSelectionChangeEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ManagedBean
@ViewScoped
public class MyBean implements Serializable {
private final static Logger LOG = LoggerFactory.getLogger(MyBean.class);
private Integer dataSourceId;
private MyTreeNode rootFolder;
public MyBean() {
super();
}
public Integer getDataSourceId() {
return dataSourceId;
}
public void setDataSourceId(Integer id) {
this.dataSourceId = id;
}
public void saveDataSource() {
}
public MyTreeNode getRootFolder() {
if (rootFolder == null) {
rootFolder = new MyTreeNode("ROOT");
rootFolder.addChild("a", rootFolder);
rootFolder.addChild("b", rootFolder);
rootFolder.addChild("c", rootFolder);
}
return rootFolder;
}
public void setRootFolder(MyTreeNode rootFolder) {
this.rootFolder = rootFolder;
}
public void processPlTreeSelectionChange(TreeSelectionChangeEvent event) throws
AbortProcessingException {
}
public String getId() {
return String.valueOf(dataSourceId);
}
}
MyTreeNode.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.richfaces.model.TreeNode;
public class MyTreeNode implements TreeNode, Serializable {
private String name;
private List<TreeNode> nodes = new ArrayList();
private List<String> names = new ArrayList();
public MyTreeNode() {
super();
}
public MyTreeNode(String name) {
this();
this.name = name;
}
@Override
public TreeNode getChild(Object o) {
if (o instanceof String) {
return nodes.get(names.indexOf(o));
} else {
throw new RuntimeException("Unknown object: " + o);
}
}
@Override
public int indexOf(Object o) {
if (o instanceof String) {
return names.indexOf(o);
} else {
throw new RuntimeException("Unknown object: " + o);
}
}
@Override
public Iterator<Object> getChildrenKeysIterator() {
return new Iterator<Object>() {
int pos;
@Override
public boolean hasNext() {
return pos < names.size();
}
@Override
public Object next() {
return names.get(pos++);
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
@Override
public boolean isLeaf() {
return name.isEmpty();
}
@Override
public void addChild(Object o, TreeNode tn) {
((MyTreeNode) tn).names.add((String) o);
((MyTreeNode) tn).nodes.add(new MyTreeNode((String) o));
}
@Override
public void insertChild(int i, Object o, TreeNode tn) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeChild(Object o) {
throw new UnsupportedOperationException("Not supported yet.");
}
public String getName() {
return name;
}
@Override
public String toString() {
return getName();
}
}
Selecting a trree node with ajax, will delete any viewParam to the
view
-----------------------------------------------------------------------
Key: RF-12638
URL:
https://issues.jboss.org/browse/RF-12638
Project: RichFaces
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 4.2.3.Final
Environment: tomcat 7, OpenJDK7
Reporter: Arne Plöse
Labels: richfaces
Having a tree in one h:form and using a h:form within a4j:outputPanel will set a
viewParam to null if the tree was selected and the form is submitted.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira