Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8879649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:59:43+00:00 2026-06-14T19:59:43+00:00

I am using netbeans 7.2.1 with jdk version 6 and primefaces 3.4.1. I have

  • 0

I am using netbeans 7.2.1 with jdk version 6 and primefaces 3.4.1. I have created a database, and created Entities from the database and then JSF pages from the entities.

I now have a jsf managed bean which is creating a mindmap for the program by extracting the users from the database and connecting them according to whether or not their username is contained in a certain string.

There is a double click facility in mindmap which I want to use to update the database, but for some reason it isn’t working. I don’t get an error message, just nothing changes.

This is what I’ve tried to use to implement the update function:

package jpa.session;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import jpa.entities.Enginetable;


@Stateless
public class EnginetableFacade extends AbstractFacade<Enginetable> {
    @PersistenceContext(unitName = "Networks0.75PU")
    private EntityManager em;


    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public EnginetableFacade() {
        super(Enginetable.class);
    }        

    public Enginetable setUserdetails( Enginetable user ) {
        try 
        {        
            return em.merge(user); 
        } 

        catch (NoResultException nre) 
        {
            return null;
        }
    }

}

But it doesn’t work. Note that I have no problem accessing the database but haven’t included the code here.

This is the relevant method:

    public void onNodeDblselect(SelectEvent event) {
        this.user.setConnections( this.user.getConnections() + "-" + this.selectedNode.getLabel() );
        this.selectedNode = (MindmapNode) event.getObject();
        this.ejbFacade.setUserdetails( this.user );
    }

This is the call from the xhtml

    <p:mindmap value="#{mmBean.root}" style="width:100%;height:600px">
        <p:ajax event="dblselect" listener="#{mmBean.onNodeDblselect}" update="output" />
    </p:mindmap>    

Please, any advice would be fantastic.

This is the full code for the bean:

package jsf;

import java.io.Serializable;
import java.sql.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ViewScoped;
import javax.inject.Named;
import javax.persistence.Version;
import jpa.entities.Enginetable;
import jpa.session.EnginetableFacade;
import org.primefaces.event.SelectEvent;
import org.primefaces.model.mindmap.DefaultMindmapNode;
import org.primefaces.model.mindmap.MindmapNode;

/**
 *
 * @author AOL
 */
@Named(value = "mmBean")
@ViewScoped
public class mmBean implements Serializable{

    @EJB
    private jpa.session.EnginetableFacade ejbFacade;
    private MindmapNode root;

    private MindmapNode selectedNode;

    PreparedStatement pst = null;

    private List<Enginetable> elements;
    private List<Enginetable> filteredElements;
    private List<Enginetable> userlist;


    private Enginetable selectedElement;
    private Enginetable[] selectedElements; 



    private Enginetable current;

    private Enginetable nodeentity = new Enginetable();
    private Enginetable user = new Enginetable();
    private String connections;
    private String[] strConnections;
    private String[] userConn;
    private List<String> indirectConn = new ArrayList<String>();
    private String[]  iConn;

    private Object rootlabel;

    //ADDED BY AODHÁN
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;

    String url = "jdbc:mysql://localhost:8080/networkdb";
    String theuser = "Aodhan";
    String password = "Cavelcade1988";


    /**
     * Creates a new instance of MmBean
     */
    public mmBean() {
    }

    @PostConstruct
    public void init() {

        this.userlist = this.getFullList();
        Enginetable entity;

        //remoteuser=null;

        // filteredElements = new ArrayList<Enginetable>();
        this.user = this.userlist.get(0);

        this.userConn = this.user.getConnections().split("-");

        root = new DefaultMindmapNode(user.getStartnode(), "Google", "006666", false);


        this.rootlabel = this.root.getLabel();
        for( int i = 0 ; i < this.userlist.size() ; i++){

                    entity = this.userlist.get(i);

                    if ( !rootlabel.equals(entity.getStartnode() ) && Arrays.asList(this.userConn).contains( entity.getStartnode() ) ) {
                        connections = entity.getConnections();
                        iConn = connections.split("-");
                        boolean addAll;
                        addAll = this.indirectConn.addAll(Arrays.asList(iConn));
                    }

        }

        for( int i = 0 ; i < this.userlist.size() ; i++){

                    entity = this.userlist.get(i);

                    if ( !rootlabel.equals(entity.getStartnode() ) ) {


                if ( Arrays.asList(this.userConn).contains( entity.getStartnode() ) )  { 

                                root.addNode(new DefaultMindmapNode(entity.getStartnode() , "Malicious Software: ", "33FF00"));

                            } 



                                else if ( !Arrays.asList(this.userConn).contains( entity.getStartnode() ) && this.indirectConn.contains( entity.getStartnode() ) ){

                                    root.addNode(new DefaultMindmapNode(entity.getStartnode() , "Malicious Software: ", "00FFFF"));

                                } 


                else{

                                    root.addNode(new DefaultMindmapNode( entity.getStartnode() , "Malicious Software: ", "CC0000"));

                }

            }

        }

    }

    public MindmapNode getRoot() {
        return root;
    }

    public MindmapNode getSelectedNode() {
        return selectedNode;
    }
    public void setSelectedNode(MindmapNode selectedNode) {
        this.selectedNode = selectedNode;
    }

    public void onNodeSelect(SelectEvent event) {
        MindmapNode node = (MindmapNode) event.getObject();


            for( int i = 0 ; i < this.userlist.size() ; i++){
                    Enginetable entity;
                    Object label = node.getLabel();

                    entity = userlist.get(i);
                    if ( entity.getStartnode() == label ){
                        this.nodeentity = entity;
                    }

            }
    //load children of select node and add via node.addNode(childNode);
    //populate if not already loaded
            if(node.getChildren().isEmpty()) {
               this.setChildNodes( node ); 
            }
        }


    public void onNodeDblselect(SelectEvent event) {
        this.user.setConnections( this.user.getConnections() + "-" + this.selectedNode.getLabel() );
        this.selectedNode = (MindmapNode) event.getObject();
        this.ejbFacade.setUserdetails( this.user );
    }

    public void setUserlist(List<Enginetable> elements) {
        this.userlist = elements;
    }

    public List<Enginetable> getUserlist() {
        return this.userlist;
    }

    public void setUser(Enginetable element) {
        this.user = element;
    }

    public Enginetable getUser() {
        return this.user;
    }

    public void setFilteredElements(List<Enginetable> filteredElements) {
        //this.filteredElements = filteredElements;
        this.elements=filteredElements;
    }

    public List<Enginetable> getFilteredElements() {
        return filteredElements;
    }

    public void setSelectedElements(Enginetable[] selectedElements) {
        this.selectedElements = selectedElements;
    }

    public Enginetable[] getSelectedElements() {
        return selectedElements;
    }

    public void setSelectedElement(Enginetable selectedElement) {
        this.selectedElement = selectedElement;
    }

    public Enginetable getSelectedElement() {
        return selectedElement;
    }

    private EnginetableFacade getFacade() {
        return ejbFacade;
    }  

    // ADDED BY AODHÁN

    public List<Enginetable> getListByUsername(String user){
       return this.ejbFacade.getEnginetableByUsername(user);
    } 

    public List<Enginetable> getListByUserID( int id ){
       return this.ejbFacade.getEnginetableByUserid(id);
    } 

    public List<Enginetable> getFullList(){
       return this.ejbFacade.getFullEnginetable();
    } 

    public Enginetable setUserdetails( Enginetable user ){
       return this.ejbFacade.setUserdetails( user );
    } 

    public void setChildNodes( MindmapNode node ){

        Object label = node.getLabel();
        this.rootlabel = this.root.getLabel();
        this.strConnections = nodeentity.getConnections().split("-");

        for( int i = 0 ; i < this.userlist.size() ; i++){

            Enginetable entity;

            entity = this.userlist.get(i);


            if ( !label.equals(entity.getStartnode() ) && !this.rootlabel.equals( entity.getStartnode() ) ) {

                if ( Arrays.asList(this.userConn).contains( entity.getStartnode() ) && !Arrays.asList(this.strConnections).contains( entity.getStartnode() ) ){

                    node.addNode(new DefaultMindmapNode(entity.getStartnode() , "Malicious Software: ", "33FF00"));

                }   

                else if ( !Arrays.asList(this.userConn).contains( entity.getStartnode() ) && this.indirectConn.contains( entity.getStartnode() ) ){

                    node.addNode(new DefaultMindmapNode(entity.getStartnode() , "Malicious Software: ", "00FFFF"));

                } 

                else if ( Arrays.asList(this.userConn).contains( entity.getStartnode() ) && Arrays.asList(this.strConnections).contains( entity.getStartnode() ) ){

                    node.addNode(new DefaultMindmapNode(entity.getStartnode() , "Malicious Software: ", "0066FF"));

                }

        else if ( !Arrays.asList(this.userConn).contains( entity.getStartnode() ) && Arrays.asList(this.strConnections).contains( entity.getStartnode() ) ){

                    node.addNode(new DefaultMindmapNode(entity.getStartnode() , "Malicious Software: ", "FFCC00"));

                } 

                else if ( !Arrays.asList(this.userConn).contains( entity.getStartnode() ) && !Arrays.asList(this.strConnections).contains( entity.getStartnode() ) ){

                    node.addNode(new DefaultMindmapNode(entity.getStartnode() , "Malicious Software: ", "CC0000"));

                } 

            }

        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:59:44+00:00Added an answer on June 14, 2026 at 7:59 pm

    I realised what the problem was, and it was twofold, it seems.

      public void onNodeDblselect(SelectEvent event) {
            this.user.setConnections( this.user.getConnections() + "-" + this.selectedNode.getLabel() );
            this.selectedNode = (MindmapNode) event.getObject();
            this.ejbFacade.setUserdetails( this.user );
        }
    

    I was calling this.selectedNode before it was defined, here.

    public Enginetable setUserdetails( Enginetable user ) {
        try 
        {        
            return em.merge(user); 
        }  
    
        catch (NoResultException nre) 
        {
            return null;
        }
    }
    

    It doesn’t like this return statement, so I broke it up.

    public Enginetable setUserdetails( Enginetable user ) {
        try 
        {        
            em.merge(user); 
            em.flush();
            return user;
        } 
    
        catch (NoResultException nre) 
        {
            return null;
        }
    }
    

    I will have to make the page update, but that is a html problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a gui (swing) project developed using netbeans 7 and JDK 6. Then
I created a JApplet using Netbeans 6.5.1 that accesses a database. When the program
I am trying to create a mindmap-style application using: Netbeans 7.2 jdk 6.35 Primefaces
I am using JDK 7 and Netbeans IDE 7.1.2. Going through Using string in
When using Netbeans' features for generating event handlers from a GUI, for example, while
im using netbeans with svn. i've checked out a project and then i used
im using netbeans for svn. i open a project in netbeans and then i
I have recently started using Netbeans with following stack Liferay, icefaces with jBoss. Is
Java, ANTLR and Netbeans newbie here. I have installed a jdk and netbeans. I
I can't build my project using jdk 1.7.0 due to following error on NetBeans

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.