2013-10-05

In my Java Tapestry application, I have a class called NachrichtenBubble.java which tests to see if there are any messages to announce, and therefor if a particular element should be shown. It looks like this:

Now, in a different place in my application, I want to determine whether to show or hide an element based on how many messages there are. Since this is already done in NachrichtenBubble.ShowBubble(), I'd like to be able to call ShowBubble() from my separate class (let's call it OtherClass.java) and act on the result.

If I put this into my OtherClass.java, I get an "Cannot make a static reference to the non-static method ShowBubble() from the type NachrichtenBubble" error:

I have read through the answers to other static/non-static method questions on here, which has been educational, but I have been unable to apply them successfully to this problem. I have tried to create a new Context method in NachrichtenBubble.java and called that from OtherClass.java, but it's not working.

Should I persist with attempting a Context-based solution, or is there something else that I could try to get a useable result from NachrichtenBubble.ShowBubble() into OtherClass.ShowNachrichten()?

Show more