commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject [OT][Jelly] dealing with reserved terms 'this', 'super'
Date Tue, 04 Feb 2003 15:40:57 GMT
I posted this message to the BSF lists with "0" response. I 'm hoping 
maybe someone who is using BSF in the Jelly taglibrary might be able to 
shed some light on my issue, thanks.


I'm using BSF in a method of a class kinda like this:

public class Test{

     protected BSFManager manager = null;

     protected double value;

     public Test()throws BSFException{

         manager = new BSFManager();

         manager.declareBean("this",this, this.getClass());
     }

     public Object myMethod(String script) throws BSFException{

        BSFEngine engine = manager.loadScriptingEngine("javascript");

        return engine.eval("my_generated_method",0, 0, script);

    }

    public void setValue(double value){
        this.value = value;
    }

    public double getVlaue(){
        return value;
    }
}

this idea is that I could write script that looks very much like java
code that would normally go into "myMethod". However, it appears that
words like "this" and "super" are reserved words in BSF/Javascript. Is 
there anyway I can
get "this" to "reference the object instance of this class in my scripts?

I.E. I want a javascript that looks something like this to run an object
instance of this class.

{
this.setValue(0.04322*100);
this.getValue();
}

Is there a means to define a reference to "this" as available in the BSF 
ObjectRegistery?

Thanks
-Mark Diggory


---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-dev-help@jakarta.apache.org



Mime
View raw message