Topic: Question about register XAJAX_CALLABLE_OBJECT

Hello,

If I using register in this way

->register(XAJAX_CALLABLE_OBJECT,$this);

every method of the class will be registered, altough I want to use only one method.

<script type="text/javascript" charset="UTF-8">
/* <![CDATA[ */
xajax_C_LOCALICE_BUTTON_Deutsch = {};
xajax_C_LOCALICE_BUTTON_Deutsch.htmlcode = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'htmlcode' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch._styleclass = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: '_styleclass' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.frame = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'frame' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch._frame = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: '_frame' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.setframe = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'setframe' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.topframe = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'topframe' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.responder = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'responder' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch._responder = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: '_responder' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.responderid = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'responderid' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch._responderid = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: '_responderid' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.fieldset = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'fieldset' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch._fieldset = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: '_fieldset' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.newform = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'newform' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.form = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'form' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch._form = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: '_form' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.get = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'get' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.post = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'post' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.method = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'method' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch._method = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: '_method' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.javascript = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'javascript' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch._javascript = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: '_javascript' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.onchange = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: 'onchange' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch._onchange = function() { return xajax.request( { xjxcls: 'C_LOCALICE_BUTTON_Deutsch', xjxmthd: '_onchange' }, { parameters: arguments } ); };
xajax_C_LOCALICE_BUTTON_Deutsch.name = function() { return xajax.request( { xjxcls: 'C_LOCALICE
</script>

How can I limit registering class method to the only one I want?

Re: Question about register XAJAX_CALLABLE_OBJECT

I had that same issue. My solution was to make all methods private or protected with the exception of the one/s you want to call from the client.

Another alternative if using php 5.x is to make only one public method. I call it dispatch().

  function dispatch($op, $data){
    return $this->$op($data);
  }

$op contains the function name and $data is the data to be passed to the function.

This allows you to call ANY xajax aware function from the browser.

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: Question about register XAJAX_CALLABLE_OBJECT

Hi Ed,

I don't understand your the second example. Do you register ->dispatch via XAJAX_CALLABLE_OBJECT or XAJAX_FUNCTION? And it works for you if this called in OOP context?

To make all my method private or public doesn't work for me.

Re: Question about register XAJAX_CALLABLE_OBJECT

If you are just registering a regular page and not a class you just use register XAJAX_FUNCTION on the dispatch function and it is the only one output. Then you would use return $op($data) to call any xajax aware function in the page in the dispatch function.

If you are registering a class you make the dispatch function the only public function in the class and use REGISTER_CALLABLE _OBJECT. It will not register private, protected or methods whose names begin with '__' like constructors.

I make everything else protected or private so I can call them using the dispatch function in the ealier post.

The only issue I have encountered is that you can't call any regular function from outside the class object. I suppose you could provide one other public method for that purpose but it would show up in the xajax javascript...

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.