Subj : Re: rhino - dynamic dispatching of function calls question To : Biker Conrad From : Igor Bukanov Date : Mon Feb 23 2004 09:12 pm Biker Conrad wrote: > I am new to Rhino so please bear with me if I am missing something > obvious... > > I want to dynamically redirect javascript function calls to a java > object method, without having to define these functions as methods of > the java object. In this case the function name would be passed as a > parameter along with the actual parameters. For instance, if I have an > javascript object called customer, I want to handle the calls > customer.address, customer.postal_code with the same java method of > the Customer class, let's say getAttribute(String attributeName), > without having to define the jsGet_address and jsGet_postal_code in my > java class. Similar, if I want to assign an address I would use a > function setAttribute(String attributName, Object value) instead of > having multiple set functions. Note that in JavaScript customer.address is no a call but rather a property access. To implement custom property access and assigning in Rhino you have to override has, get and put methods of org.mozilla.javascript.Scriptable object. See also examples/Matrix.js from Rhino distribution for an example of such customization. Regards, Igor .