|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
Calling custom java classes from studio
I need to use a custom java class to do COM interfacing. I've got the class written and it works if I write a standalone java app and run it at the command line. But I'm having problems getting it to work in studio.
Here's what happens... under an Item widget inside a menu, I have an Action that evaluates a "new" expression and sets a variable. I then try to call a method inside that class using the variable reference. I always get a null pointer exception. If I use the evaluation tool to evaluate the new command it returns a value, but the variable that I want to set to that value does not persist. Here's an example. I have Foo.jar in the sagetv/JARs directory. Action widget: obj = new_Foo_Bar() Action widget: Foo_Bar_fubar(obj) The first statement evaluates fine, but the second one give a null pointer exception. On the other hand, the following works: Action widget: Foo_Bar_fubar(new_Foo_Bar()) Any ideas? Why isn't the obj variable getting set? I want it to persist so that I can use it in future widgets. I am a java newbie, so thanks in advance for being gentle. I figure I'm making some sort of newb mistake. |
#2
|
||||
|
||||
Probably not a Java issue - do you have a variable widget named 'obj' in a parent widget to whereever you want to use it?
Studio has nested variables, so a variable set in one tree is only accessible down the line, not back up it. In order to make a variable accesible to all trees, you should put a variable widget (the blue arrow up) at the menu level with value 'null', then any time you set it, all parts of the menu will be able to access it. |
#3
|
||||
|
||||
I'll leave the java comments to someone else for now, but since "Foo_Bar_fubar(new_Foo_Bar())" is working, it sounds like it may just be a variable scope issue. (See p. 45 of the Studio manual for info on that.)
Make sure the use of the 'obj' variable after it is initialized is in a child tree of where it was set, or place an attribute widget that declares the 'obj' variable at a higher point in the tree that is a shared parent of any place you are trying to use 'obj' in a menu. To simplify remote Studio debugging, you might want to post a screen shot of the section of code where those lines are contained. - Andy
__________________
SageTV Open Source v9 is available. - Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1. - Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus - HD Extenders: A) FAQs B) URC MX-700 remote setup Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request. |
#4
|
||||
|
||||
It probably is getting set, but it is probably going out of scope before you are using it.
As you are usign implicit variables, check the docs on scope... the second action must both be children of the same widget for the second to see the implicit variable 'obj' which is defined in the first... Secondly how persistant do you want your object?
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki |
#5
|
||||
|
||||
Quote:
Edit: I guess everyone thinks it is a variable usage issue. - Andy
__________________
SageTV Open Source v9 is available. - Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1. - Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus - HD Extenders: A) FAQs B) URC MX-700 remote setup Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request. |
#6
|
||||
|
||||
"scope" !
That's the word I couldn't think of. Quote:
|
#7
|
||||
|
||||
Not trying to promote my own stuff (as I'm far from a Java master), but check out the DVDPro2Sage stuff in either Meekell or SageMC 169, should give you an idea of how to deal with external Java classes.
|
#8
|
||||
|
||||
I'm guessing the problem is that he put both Action Widgets underneath the Item Widget so that its only executing the second one and not executing the chain.
You should make "obj = new_Foo_Bar()" a child of the Item Widget and then make "Foo_Bar_fubar(obj)" a child of "obj = new_Foo_Bar()"
__________________
Jeffrey Kardatzke Founder of SageTV |
#9
|
||||
|
||||
Thanks for all the input, folks. It was indeed a scoping issue. I added an attribute widget to the menu and all was well!!!
|
#10
|
||||
|
||||
Quote:
well, tie, but I was first. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|