You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "simon.robins" <si...@mac.com> on 2003/04/14 23:28:26 UTC
BSF and other stuff
Firstly, I think that there may be a small problem with the <SCRIPT>
code where ${some_value} is replaced. If there is a dollar sign before
the ${} tag then the replacement seems to be is a character earlier
than expected. This is in 2.4alpha5.
Secondly, has anyone had success with the BSF using a script language
other than jython? I've tried Rhino (javascript) and have been very
successful. Even to the point of creating Hibernate objects and
persisting them to a database:
<component id="javascript" type="DirectLink">
<listener-binding name="listener" language="javascript">
<![CDATA[
Table = Packages.com.ibase.hibernate.Table
table = new Table
java.lang.System.out.println("table="+table)
cycle.getMonitor().save(table)
java.lang.System.out.println("table="+table)
]]>
</listener-binding>
</component>
I've not been so successful with BeanShell. It seems that although
various docs state that BSH is supported directly by BSF, if you check
the actual .jar file this isn't the case. Consequently it looks like
you need to register BSH with BSF for it to be recognised. Currently,
there doesn't seem to be a way to do this.
While I'm at it I have also had problems instantiating objects under
Jython that are outside the java package. For example:
from com.ibase.hibernate import Table
throws the following error:
org.apache.tapestry.ApplicationRuntimeException: Unable to execute
listener script "classpath:/com/ibase/jfreechart/pages/Home.page, line
9": exception from Jython: Traceback (innermost last): File
"<string>", line 3, in ? ImportError: No module named ibase
org.apache.tapestry.ApplicationRuntimeException
Unable to execute listener script
"classpath:/com/ibase/jfreechart/pages/Home.page, line 9": exception
from Jython: Traceback (innermost last): File "<string>", line 3, in
? ImportError: No module named ibase
component:
com.ibase.jfreechart.pages.Home@a8e283[Home]
location:
classpath:/com/ibase/jfreechart/pages/Home.page, line 9
org.apache.bsf.BSFException
exception from Jython: Traceback (innermost last): File "<string>",
line 3, in ? ImportError: No module named ibase
reason:
100
org.python.core.PyException
Stack Trace:
File "<string>", line 3, in ?
ImportError: No module named ibase
org.python.core.Py.ImportError(Py.java)
org.python.core.imp.import_logic(imp.java)
org.python.core.imp.import_name(imp.java)
org.python.core.imp.importName(imp.java)
org.python.core.ImportFunction.load(__builtin__.java)
org.python.core.ImportFunction.__call__(__builtin__.java)
org.python.core.PyObject.__call__(PyObject.java)
org.python.core.__builtin__.__import__(__builtin__.java)
org.python.core.imp.importFromAs(imp.java)
org.python.core.imp.importFrom(imp.java)
org.python.pycode._pyx0.f$0(<string>:3)
org.python.pycode._pyx0.call_function(<string>)
org.python.core.PyTableCode.call(PyTableCode.java)
org.python.core.PyCode.call(PyCode.java)
org.python.core.Py.runCode(Py.java)
org.python.core.Py.exec(Py.java)
org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
org.apache.bsf.engines.jython.JythonEngine.exec(Unknown Source)
org.apache.bsf.BSFManager$6.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
org.apache.bsf.BSFManager.exec(Unknown Source)
org.apache.tapestry.binding.ListenerBinding.actionTriggered(ListenerBind
ing.java:182)
Re: BSF and other stuff
Posted by Christian Sell <ch...@netcologne.de>.
simon.robins wrote:
> Firstly, I think that there may be a small problem with the <SCRIPT>
> code where ${some_value} is replaced. If there is a dollar sign before
> the ${} tag then the replacement seems to be is a character earlier
> than expected. This is in 2.4alpha5.
>
> Secondly, has anyone had success with the BSF using a script language
> other than jython? I've tried Rhino (javascript) and have been very
> successful. Even to the point of creating Hibernate objects and
> persisting them to a database:
>
> <component id="javascript" type="DirectLink">
> <listener-binding name="listener" language="javascript">
> <![CDATA[
> Table = Packages.com.ibase.hibernate.Table
> table = new Table
> java.lang.System.out.println("table="+table)
> cycle.getMonitor().save(table)
> java.lang.System.out.println("table="+table)
> ]]>
> </listener-binding>
> </component>
>
> I've not been so successful with BeanShell. It seems that although
> various docs state that BSH is supported directly by BSF, if you check
> the actual .jar file this isn't the case. Consequently it looks like
> you need to register BSH with BSF for it to be recognised. Currently,
> there doesn't seem to be a way to do this.
there is a bsh-bsf.jar (or similar) file that comes with bsh and
includes the integration class. I think the newer (beta) bsf code
already has this.
>
> While I'm at it I have also had problems instantiating objects under
> Jython that are outside the java package. For example:
>
> from com.ibase.hibernate import Table
>
> throws the following error:
>
> org.apache.tapestry.ApplicationRuntimeException: Unable to execute
> listener script "classpath:/com/ibase/jfreechart/pages/Home.page, line
> 9": exception from Jython: Traceback (innermost last): File
> "<string>", line 3, in ? ImportError: No module named ibase
>
> org.apache.tapestry.ApplicationRuntimeException
>
> Unable to execute listener script
> "classpath:/com/ibase/jfreechart/pages/Home.page, line 9": exception
> from Jython: Traceback (innermost last): File "<string>", line 3, in
> ? ImportError: No module named ibase
>
> component:
> com.ibase.jfreechart.pages.Home@a8e283[Home]
>
> location:
> classpath:/com/ibase/jfreechart/pages/Home.page, line 9
>
> org.apache.bsf.BSFException
>
> exception from Jython: Traceback (innermost last): File "<string>",
> line 3, in ? ImportError: No module named ibase
>
> reason:
> 100
>
> org.python.core.PyException
>
> Stack Trace:
>
> File "<string>", line 3, in ?
> ImportError: No module named ibase
> org.python.core.Py.ImportError(Py.java)
> org.python.core.imp.import_logic(imp.java)
> org.python.core.imp.import_name(imp.java)
> org.python.core.imp.importName(imp.java)
> org.python.core.ImportFunction.load(__builtin__.java)
> org.python.core.ImportFunction.__call__(__builtin__.java)
> org.python.core.PyObject.__call__(PyObject.java)
> org.python.core.__builtin__.__import__(__builtin__.java)
> org.python.core.imp.importFromAs(imp.java)
> org.python.core.imp.importFrom(imp.java)
> org.python.pycode._pyx0.f$0(<string>:3)
> org.python.pycode._pyx0.call_function(<string>)
> org.python.core.PyTableCode.call(PyTableCode.java)
> org.python.core.PyCode.call(PyCode.java)
> org.python.core.Py.runCode(Py.java)
> org.python.core.Py.exec(Py.java)
> org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
> org.apache.bsf.engines.jython.JythonEngine.exec(Unknown Source)
> org.apache.bsf.BSFManager$6.run(Unknown Source)
> java.security.AccessController.doPrivileged(Native Method)
> org.apache.bsf.BSFManager.exec(Unknown Source)
> org.apache.tapestry.binding.ListenerBinding.actionTriggered(ListenerBind
> ing.java:182)
>