how to passthrough a csjs function via property definition - javascript

on my application I have a dialog which I re-use across my application. sometimes I call it via ssjs and sometimes csjs. the dialog contains buttons and sometimes I want for them the oncomplete event for an eventhandler to perform a csjs action and sometimes not.
I was wondering how I can pass through csjs code/function to the custom control and use it in the oncomplete event of an eventhandler.
normally I would use the compositeData method to get the value but that is ssjs.
can anyone guide me?

You can provide the CSJS, that should be executed in the oncomplete event, as string property to the custom control and compute the client-side code for the event on the server-side.
If you, for example, name the property csjsOncomplete, the computed value for the client-side event would be #{javascript:return (compositeData.csjsOncomplete || '');} .

Related

Is there a way to use Frida or any other tool to invoke a method in an IOS application with your own argument?

Is there a way, maybe a script or API to invoke a method in an IOS application without manually triggering it on the application itself and also replacing the values? The goal for this is to make sure that the query from a server will return the values that I want.
Example:
If the value 1 is sent to the server, it return will back "True", but I want the return value to be "False", so I need to invoke the method that queries the server and change the argument value to 0. Can frida force activate a method without interaction or is there another tool that can perform this?
If you want to intercept all function calls in order to alter the return value, read up on the basic interception functionality using Interceptor.attach
If you want to instantiate your own or an existing object, look at the following examples:
https://github.com/frida/frida/issues/567#issuecomment-406897414

calling .trigger on javascript createElement

I am implementing a CSRF solution that automatically injects a token stored on the session into all forms before subitting them. I have implemented 2 solutions to ensure all submissions are handled
For ajax submissions I have implemented a jquery.ajaxPreFilter method that adds the token to the data attributes before passing it through to the ajax handler.
For other forms, I bind to the submit event using jquery.on('submit').
For forms being submitted via javascript I have changed my .submit() calls to .trigger('submit');
There are some javascript methods in our code that will use javascript document.createElement() to create a form, before calling form.submit(). I am unable to change these to form.trigger('submit') as jquery does not recognise them; I get error "form.trigger is not a function".
How can I handle these types of form submissions to trigger the submit event so that my binding method will pick it up?
I have now found a solution, and didn't realise it was so simple.
Instead of calling
form.submit();
I just call
$(form).trigger('submit');

What exactly happens when you save a Backbone model?

What exactly happens when you save a Backbone model? Here's the best I can piece together by reading the documentation here:
model.save([attributes], [options]) is called
A "change" event is fired (but only if the attributes are new)
The server is notified of the change?
A "sync" event is called once the server returns
But I'm a Backbone noob and I'm sure someone else could do a way better job of explaining.
I'm partly just curious what happens. I'm also having trouble understanding how Backbone comes up with the JSON object it sends to the server. I'm having a separate problem where the JSON object is not what I want it to be, but I don't know how to change it.
The detailed process can be found in the annotated source code for Backbone.Model.save and Backbone.sync.
If you ignore options.wait and options.silent, your decomposition is mostly correct.
When you issue a model.save:
the attributes passed to the function are set, a change event is fired if the values changed
save delegates the request to model.sync or Backbone.sync
sync serializes the data to a JSON string by calling JSON.stringify(model.toJSON())
An Ajax request is sent to sent to server, a POST request for a new object, a PUT for an update. The target URL is defined by model.url (or collection.url/id)
When the request completes, the model is updated with the server response, if any, and triggers a change event accordingly.
Success or error callbacks are called, a sync event is triggered if no success callback is defined.
Usually, you can customize this behaviour by overriding model.toJSON or model.sync
first,I suggest you read the source code of the backbone, is really very simple.Default backbone and server-side interaction is achieved through backbone.sync.
second,You can trace debug model.save method of code again, naturally know the details.
I suggest you start hereļ¼š
http://backbonejs.org/examples/todos/index.html

What is the a4j event sequence?

What is the event sequence of a a4j:commandLink or a4j:commandButton?
Is it right: onclick->actionListner->oncomplete->reRender?
Is reRender comes before oncomplete?
When action happens?
The onclick JavaScript is called the first when the enduser clicks the generated HTML element. When the JavaScript code does not return false, then all associated ActionListener implementations in the JSF side will be invoked, in the order of their association with the component. If the listeners haven't thrown any exception, then the real action will be invoked. When the action returns a successful response, then the components specified in reRender will be updated in the client side. Finally the oncomplete JavaScript will be called.
It's pretty easy to track yourself if you have a debugger in both the client and server side and know how to use it. I strongly recommend Firebug for the client side and Eclipse for the server side. You can of course also always do poor man's debugging using alert()s or System.out.println()s.

Postback without a control context

I have a situation where I want to use several server side controls, which have clients side state. I want to check the state when events occur (like various clicks), and when the state is where i want it, I want to postback to the server and do some processing.
In particular, I need to make sure that at least 3 different controls have selections before I want to do a postback. Since there is no specific control that will initiate the postback, I just want to capture the selection events on the client side, then call __doPostBack() (or something similar) to initiate the processing. So i have disabled all server side events, turned off autopostback, and have wired up some javascript to handle this.
I've got all the client side code written and working, however I cannot seem to get the server-side to recognize the postback. I'm overriding RaisePostBackEvent, and checking the eventArgument for my custom argument. This doesn't work, as RaisePostBackEvent is never called.
This method has worked when I had autopostback enabled (for example, the Telerik Radgrid OnSelectChanged server side event).
Any suggestions on the best way to handle this?
Update:
When asked for sample code, it's exactly as I say above. Not rocket science.
Javascript:
function CheckState(source, eventArgs) {
// logic to test state of controls
__doPostBack("", "DoMyWork:");
}
Then in code behind I have:
protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument)
{
if (eventArgument.IndexOf("DoMyWork") != -1)
{
// do my server side work.
}
}
RESOLUTION:
Because this is somewhat confusing.. I'll just say what my solution was.
I used one of the controls involved in the postback and used it's UniqueID for the control parameter, then my method as the event.
if you call the __doPostBack() without parameters, asp.net cannot figure out which control fired the event and thus it cannot determine which event to fire.
you need to add the name of the control as a parameter to __doPostBack() and an argument which could be null if you dont need one
__doPostBack('textbox1','') //no arguments
__doPostBack('textbox1','12')
you can read the argument you passed in from code behind like this:
Dim arg As String = Request("__EVENTARGUMENT")

Categories

Resources