File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes NodeSelectedEvent and instanceof operator help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Meteor in Action this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "NodeSelectedEvent and instanceof operator help " Watch "NodeSelectedEvent and instanceof operator help " New topic

NodeSelectedEvent and instanceof operator help

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 484

I have a tree where the top nodes are of the type TreeHolder Object and the nodes below it are of type DeviceChannels Object. I have my method that is bound to nodeSelectListener, and I need it to differentiate between calling the first nodes of TreeHolder Object and the second nodes of DeviceChannels Object.

I was told I could do something like this:

But Im having trouble working this into what I have.

I have been trying variations on this advice, but havent seemed to get it right yet. I have till the end of the day to get this working so Im a little worried.

Should I leave the method as it is, accepting NodeSelectedEvent event as the parameters, or should that be changed to something more general?

public void projectSelection(NodeSelectedEvent event) {

it seems to me he is saying I only need the one nodeSelectListener attribute on my tree right? And it is going to call this method.

I just need if statements covering whether the node selected is a TreeHolder Object or a DeviceChannels Object.

So it seems like he's saying I should do something like:

where projectNode is a TreeHolder Object instance and deviceNode is of DeviceChannels Object

the above gives me errors though (Incompatible conditional operand types MeasurementProject and NodeSelectedEvent)

and the other variations I have tried havent quite worked yet either.

I would keep trying until I get it, but like I said I have till tonight to get this working correctly.

True wisdom is in knowing you know nothing - Socrates
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 484

Here is the thread where I had this discussion if it helps to see everything:
I agree. Here's the link:
subject: NodeSelectedEvent and instanceof operator help