Documentation / Tutorials / Awesome Enterprise,Generic,Quick Samples,SPA
Ticket Handler
/ Awesome Enterprise,Generic,Quick Samples,SPA / Ticket Handler
- Ticket Handler module works as intermediate module between destination module and route call
- For eg: route_ajax=“ticket-handler/<ticket_id>/submit”
- Here submit module is destination module
- At first ticket-handler module will get executes and here session ticket get verified.
- Use session_ticket.get to get session ticket data.
- Check details here – session_ticket-get
- Please consider following example,
- Calling Code snippet in samples app:
-
123456789101112[templates.add main][session_ticket.create nonce=yes set=template.ticket_id /][session_ticket.set_activity {template.ticket_id} app='samples' module='test_2' /]<button type="button" name="singlebutton"class="btn btn-sm btn-primary js-submit-job"> Call Test </button><script type=spa/axn axn='route.run' bind='click' bind_selector='.js-submit-job'route_ajax='ticket-handler/[template.ticket_id /]' disable_selector='.js-submit-job'></script>[/templates.add]
- In this code, session activity is set as app=”samples” which is used as router
and destination module is “test_2” in samples app. - When Call Test will get click event, route will happen to ticket-handler module in same app.
- Ticket handler code:
-
12345678910111213[templates.add main][aw2.get qs.0 set=ticktt /][session_ticket.get main="{ticktt}" set=ticket_data /][if.not_empty tikcett_data][aw2.get tikcett_data.ticket_activity.json_decode set=route_details /]//** route as per requirement | route to module, service or template **//[/if.not_empty][/templates.add]
- In above snippet, qs.0 is valued as ticket_id since route call is like that.
- Using the same ticket_id, ticket_data is getting fetched.
- If: ticket_data is not_empty which means ticket is valid and it has data.
- Further, you can execute the routing as per session ticket activity.
- It can be service, module or template.
- So simple it is, try this in your app.
- Happy coding.
- Ps: In near future, this will get update as ticket-handler as service perhaps there will be modification in routing too.