Re: [coldbox:28024] Rest Pagination

27 views
Skip to first unread message

Jon Clausen

unread,
Dec 5, 2020, 10:16:03 AM12/5/20
to col...@googlegroups.com

If you’re using one of the REST templates, then the `Response` object which generates that pagination struct is located at coldbox/system/web/context/Response.cfc

If you want to change the pagination structure, then you will need to clone that component ( or extend it ) and modify the `setPagination` method to your desired structure.

Then, add a preProcess interception ( which will fire before the aroundHandler method in the base RestHandler.cfc ) which sets prc.response to your new component. 

From that point on, it should work exactly as it currently does, with a different pagination structure.

 

HTH,

 

Jon


 

From: <col...@googlegroups.com> on behalf of Roberto Marzialetti <roberto.m...@gmail.com>
Reply-To: "col...@googlegroups.com" <col...@googlegroups.com>
Date: Saturday, December 5, 2020 at 8:23 AM
To: ColdBox Platform <col...@googlegroups.com>
Subject: [coldbox:28024] Rest Pagination

 

Hi everyone

 

I started playing with Coldbox to create a Rest application.

In a short time I was able to get it working :-)

 

I have a problem: I would like to replace the default structure with a custom one. Is  possible?

 

MY80kAAAAASUVORK5CYII=

 

I don't find anything for this in docs or config.

 

I'm using coldbox 6.

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/79e954f0-8b15-4107-9bda-0c003e0130ben%40googlegroups.com.

Roberto Marzialetti

unread,
Dec 7, 2020, 4:47:19 AM12/7/20
to ColdBox Platform
Excuse me Jon,
but I can't set my custom response.

I added "preHandler" in my Echo.cfc, like this:


===
 
function preHandler (event, rc, prc, action, eventArguments) {
   prc.setResponse( new api.model.APIResponse() )
}

function index( event, rc, prc ) {
}

===  


But i can't use rpc.setResponse: 
Error: The function [setResponse] does not exist in the Object  

the same for event.setResponse


prc contains only a string, like this:  

prc-Immagine 2020-12-07 100931.png

I should replace all the response object, not only pagination:

objs.jpg


Should I replace RestHandler too?

Any hint?

Many thanks :-)

Jon Clausen

unread,
Dec 7, 2020, 8:32:11 AM12/7/20
to col...@googlegroups.com
“prc” is a struct. You would need to use dot notation to set that value.


From: col...@googlegroups.com <col...@googlegroups.com> on behalf of Roberto Marzialetti <roberto.m...@gmail.com>
Sent: Monday, December 7, 2020 4:47:19 AM
To: ColdBox Platform <col...@googlegroups.com>
Subject: Re: [coldbox:28034] Rest Pagination
 
Reply all
Reply to author
Forward
0 new messages