-
Hello, I am currently testing with actions and action handlers. I am using the Java-EMF-Theia template. As of now, I have a working handler that gets user input and stores it inside the action through the client. The next part is, that I want to send this to the server so that it can analyze the expression given by the user and return a result. I understand that I must make an action in the server that will match the action made in the client. I am curious about how it is that from my client's action handler, I can send it to the server. Below is my action handler in the client. Thank you. @injectable()
export class MyTestResponseActionHandler implements IActionHandler {
handle(action: MyTestActionVersionTwo): void | Action {
// implement your custom logic to handle the action
console.log('I printed this from the client handler');
console.log('The text within the input is: ' + action.variable1);
// Optionally issue a response action
}
}``` |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @JValGLZ,
I would recommend to split this into two actions, let's call them On the server you have to register a handler for the result action: // Define your action
public class MyTestActionVersionTwoResult extends Action {
public static final String KIND="myTestActionVersionTwoResult";
// define the custom properties + getter&setter for your action
}
// Define an action handler
public class MyTestActionVersionTwoResultHandler extends AbstractActionHandler<MyTestActionVersionTwoResult> {
@Override
public List<Action> executeAction(final MyTestActionVersionTwoResult action) {
// Implement your custom handling
// If you want to send back an action to the client use `listOf()` otherwise simple return an empty list with `none()`
return none();
}
}
// Register your handler in your custom diagram module
public class TasklistDiagramModule extends EmfNotationDiagramModule {
//...
@Override
protected void c void configureActionHandlers(final MultiBinding<ActionHandler> binding) {
super.configureActionHandlers(binding);
binding.add(MyTestActionVersionTwoResultHandler.class);
}
} In you client action dispatcher you can then simply return the result action, and the client will take care of forwarding it to the server. @injectable()
export class MyTestResponseActionHandler implements IActionHandler {
handle(action: MyTestActionVersionTwo): void | Action {
// implement your custom logic to handle the action
console.log('I printed this from the client handler');
console.log('The text within the input is: ' + action.variable1);
// dervive the result action
const result:MyTestActionVersionTwo = ...
return result:
}
}``` |
Beta Was this translation helpful? Give feedback.
Hi @JValGLZ,
I would recommend to split this into two actions, let's call them
MyTestActionVersionTwo
andMyTestActionVersionTwoResult
for now.On the client you than handle the
MyTestActionVersionTwo
and derive theMyTestActionVersionTwoResult
from that (stores the user input) and then you send this action to the server.On the server you have to register a handler for the result action: