Transferring Requests

Release 1.0 - ...

Using request.transfer(), we can transfer to another item on the server, without losing scope, hierarchy and request settings.

Transfer can be seen as an optimal mix between redirecting and embedding. It is a way to render items in the current location without the problems with links and state that embed and redirect have.

On the page transferred to, the context of the current page is still present: request headers, form data, and even savebuffers set previously are kept intact, and so are the item number and the parent of the item.

However, you can get to the overriden data, because it is stored inside request metadata (headers):

  • Original_Location
    Location of the item that started the transfer.
  • Original_ItemNumber
    Original itemnumber of the item that was transferred to.
  • Original_Parent
    Original parentnumber of the item that was transferred to.

Consider the following code (let's say in item 2395, in folder 2394):

Smartsite SXML CopyCode image Copy Code
{buffer.set('transferred', 'Hello there, you have been transferred to another location!')}
{request.transfer('/smartsite.net?id=2396&test=2')}

In the example above, item 2396 is transferred to. Consider the following content of that item:

Smartsite SXML CopyCode image Copy Code
<ul><br/>
  <li>Current url: {request.url()}</li>
  <li>Original url: {request.metadata('Original_Location', default=request.url())}</li>
  <li>Current itemnumber: {itemdata.number()}</li>
  <li>Original itemnumber: {request.metadata('Original_ItemNumber', default=itemdata.number())}</li>
  <li>Current parent: {itemdata.parent()}</li>
  <li>Original parent: {request.metadata('Original_Parent', default=itemdata.parent())}</li>
  <li>Buffer set on other page: {buffer.get('transferred', default='')}</li>
</ul>
<se:xlinks />

The result of the transfer will look like this:

  • Current url: /smartsite.net?id=2396&test=2
  • Original url: http://localhost:7812/test.net?id=2395
  • Current itemnumber: 2395
  • Original itemnumber: 2396
  • Current parent: 2394
  • Original parent: 2397
  • Buffer set on other page: Hello there, you have been transferred to another location!