-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
b:tree data always is null #422
Comments
Hi @cooper-lyt, I've done some tests in my environment and I can't reproduce your issue. |
public class OfficeTreeProducer implements java.io.Serializable{
public class OfficeTypeNodeImpl extends DefaultNodeImpl{
public OfficeTypeNodeImpl(Office.Type type) {
super(enumHelper.getLabel(type), type.getIcon(),true);
setData(type.name());
}
public Office.Type getType(){
return Office.Type.valueOf(getData());
}
}
@Inject
private OfficeRepository officeRepository;
@Inject
private EnumHelper enumHelper;
@Produces
@Named
@SessionScoped
public Node getOfficeTree(){
Node result = new DefaultNodeImpl("root");
List<Office.Type> types = new ArrayList<Office.Type>(EnumSet.allOf(Office.Type.class));
Collections.sort(types);
for(Office.Type type: types){
List<Office> offices = officeRepository.findByCategoryVaild(type);
if (!offices.isEmpty()) {
Node typeNode = new OfficeTypeNodeImpl(type);
for (Office office: offices){
typeNode.getChilds().add(new DefaultNodeImpl(office.getName(),"asterisk",office.getId()));
}
result.getChilds().add(typeNode);
}
}
return result;
}
} @Named
public class EmployeeList implements TreeNodeEventListener, java.io.Serializable {
@Inject
private OfficeHome officeHome;
@Inject
private Logger logger;
public void processValueChange(TreeNodeSelectionEvent treeNodeSelectionEvent) {
Node node =treeNodeSelectionEvent.getNewSelectedNode();
logger.config("dd" + node.getClass().getName());
if (node instanceof OfficeTreeProducer.OfficeTypeNodeImpl){
logger.config("1.select type node!");
}else{
logger.config("1.not select type node data:" + node.getData());
}
}
public void processValueChecked(TreeNodeCheckedEvent treeNodeCheckedEvent) {
}
public void processValueUnchecked(TreeNodeCheckedEvent treeNodeCheckedEvent) {
}
public boolean isValueSelected(Node node) {
if (node instanceof OfficeTreeProducer.OfficeTypeNodeImpl){
logger.config("select type node!");
}else{
logger.config("not select type node data:" + node.getData());
}
return true;
}
public boolean isValueChecked(Node node) {
return true;
}
} <b:tree value="#{officeTree}" renderRoot="false" showCheckbox="false" showTags="true"
enableLinks="false" nodeSelectionListener="#{employeeList}"
showBorder="true"/> |
Thank you @cooper-lyt. Just a rapid question before looking deeper in your code: have you put the b:tree component inside a form? |
Sorry for my silence but i can't reproduce your bug.. Are you using the latest version of bootsfaces?anyway i'll try to look at this problem in the next few days..please be patient! :) |
@asterd version is 0.8.6 i use showcase source private void initStatefullRootNode() {
statefullRootNode = new DefaultNodeImpl("root", "arrow-right").withBackColor("#FF1188");
List<Node> nodeList = new ArrayList<Node>();
nodeList.add(new DefaultNodeImpl("Node1", "user","datatata"));
nodeList.add(new DefaultNodeImpl("Node2", "envelope","datatata"));
List<Node> subNodes = new ArrayList<Node>();
subNodes.add(new DefaultNodeImpl("Subnode1", "user","datatata"));
subNodes.add(new DefaultNodeImpl("Subnode2", "main","datatata"));
subNodes.add(new DefaultNodeImpl("Subnode3", "arrow-left","datatata"));
DefaultNodeImpl nx = new DefaultNodeImpl("Child4-Link", "arrow-right","datatata");
...
}
@Override
public void processValueChange(TreeNodeSelectionEvent event) {
System.out.println("SELEZIONATO NODO:");
System.out.println("NEW TITLE: " + event.getNewSelectedNode().getText());
if(event.getOldSelectedNode() != null)
System.out.println("OLD TITLE: " + event.getOldSelectedNode().getText());
selectedNode = event.getNewSelectedNode();
System.out.println("DATA is:" + selectedNode.getData());
} <h:form prependId="false">
<b:container id="treeContent">
<b:row>
<b:column>
<b:tree render-root="false" value="#{test.treeModel}"
node-selection-listener="#{test}" showCheckbox="true"
enableLinks="true" showBorder="false" update="chkItems" />
</b:column>
</b:row>
<b:row>
<b:inputText id="chkItems" styleClass="test" value="#{test.checkedColumns}" />
</b:row>
</b:container>
</h:form> output is
|
Hi @asterd , We use bootsfaces on our project and we have upgraded version 0.8.1 to 0.8.6. The tree component new and came from 0.8.6. I faced the same issue @cooper-lyt said. I will try to do clear explanation my issue. in jsf (xhtml) the tree component is : <b:tree id="soruListesi" value="#{soruTanimlariMb.sorularTreeList}"
render-root="false" node-selection-listener="#{soruTanimlariMb}">
</b:tree> soruTanimlariMb is Viewscoped managed bean and sorularTreeList is a Node property of mb. The mb has also a Node property seciliNode for selected node. @ManagedBean (name = "soruTanimlariMb")
@ViewScoped
public class SoruTanimlariManagedBean extends BaseManageBean implements TreeNodeEventListener {
....
private Node sorularTreeList;
private Node seciliNode;
....
// The init method
@PostConstruct
public void init () {
//root node definition, the node has no data
sorularTreeList = new DefaultNodeImpl("Soru Tanım Listesi", null, null);
// Sub node of sorularTreeList population from db codes
for (Entity item : aList) {
// i set subnode's custom data from here
Node subNode = new DefaultNodeImpl(item.getName(), null, item.getId().toString());
sorularTreeList .getChilds().add(subNode);
}
}
//action method of some commandbutton. At this method, the selected node's (seciliNode) custom data was null
public void actionEkleTekrarliSoru() {
String data = seciliNode.getData(); // data comes null at here
}
// Listener impl. event method
@Override
public void processValueChange(TreeNodeSelectionEvent event) {
seciliNode = event.getNewSelectedNode();
} At the last line of Thanks for interest |
Hi @yasinkasap, I'll going crazy to try to debug this problem, because in my environment, with the same configuration, it works without problems. Now, with your example, I have found another hint to follow: have you implemented in a correct way, the "isValueSelected" method of the TreeNodeEventListener interface?
I know that is a trivial implementation, but the renderer of the tree component, to find the real selected node, needs this method. Can you try to implement it and give me a feedback please? |
Hi @asterd My impl is :
page screenshut : eclipse debug screenshut at processValueChange method : for be sure, node's data set to some value at init method : |
Ok! finally I've found the bug!! I've committed on cc0eab5 the resolution for this issue. Maybe you have to wait for the next release or for a developer snapshot if @stephanrauh can please do that! Obviously, there is a better and more flexible way to fix this bug but now I'm a little bit busy, so I think that the "beautiful" resolution is postponed to 0.9.1 or later.. but for now, it works (i hope :) )! |
Hi @asterd , Thanks for reply. I'm waiting your news :). This will be good for us. I tried to use different tree components such as in primefaces and butterfaces. These components didn't work properly on our project. if the issue is solved, everything ok for us. One more think, it be nice a search text box for tree component :) Thanks. |
Ok.. I've done it in a more flexible way! :) waiting for developer snapshot! |
I've just uploaded the snapshot. See #369 on how to get it. |
@yasinkasap @cooper-lyt Could you give the snapshot a try and report us back if the bug has been fixed, please? Thanks in advance! |
Hi @stephanrauh, I couldn't try to the fix, because after adding new repository as you said #369 https://oss.sonatype.org/content/repositories/snapshots on pom xml and maven settings.xml, it recognized 0.9.0-SNAPSHOT version but in java classes import net.bootsfaces.* packages were not recognized. We used the packages in many classes, managed beans. Whrn i changed to 0.8.6 version errors has gone. |
I published another snapshot a couple of minutes ago. If that doesn't work, try cleaning your .m2 cache.
|
Hi @stephanrauh , sorry for late. I tested 0.9.1 snapshot version in different environment. The bug was solved and i able to get node's data many places in code. Can i a request, may you give a forecast about 0.9.1 production version date ? thanks. |
Let's publish 0.9.0 first :). Current forecast: soon. Maybe even this weekend, depending on the result on our tests. |
Excuse :) i wrote wrong. |
@SessionScoped
or@RequestScoped
call getData() always is null;The text was updated successfully, but these errors were encountered: