You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Martin Grigorov <mg...@apache.org> on 2014/11/30 22:02:41 UTC

Actions producing JSONP

Hi,

I want my action button to produce some JSON and send it back to the
browser where I will use this data to update a custom component.

Looking at
https://github.com/apache/isis/blob/master/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/ActionLinkFactoryAbstract.java#L168
I see there are two special cases covered:
- redirect when the result is java.net.URL
- download when the result is Lob

What is needed to achieve my goal ?
Is there a way to plug a special handler for a custom result type ?
Or I need to add the new type to org.apache.isis.applib.value package
and extend the code in ALFA ?


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

Re: Actions producing JSONP

Posted by Martin Grigorov <mg...@apache.org>.
Thanks, Dan!

I'll experiment locally and if it goes well then I'll send a pull request.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Dec 1, 2014 at 8:41 AM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> On 30 November 2014 at 21:02, Martin Grigorov <mg...@apache.org>
> wrote:
>
> > Hi,
> >
> > I want my action button to produce some JSON and send it back to the
> > browser where I will use this data to update a custom component.
> >
> > Looking at
> >
> >
> https://github.com/apache/isis/blob/master/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/ActionLinkFactoryAbstract.java#L168
> > I see there are two special cases covered:
> > - redirect when the result is java.net.URL
> > - download when the result is Lob
> >
> > What is needed to achieve my goal ?
> > Is there a way to plug a special handler for a custom result type ?
> >
>
> No, there isn't any plugin point.
>
> I'm not convinced we need a formal API for this, rather just extend the
> existing handler code to support the extra behaviour required...
>
>
> > Or I need to add the new type to org.apache.isis.applib.value package
> >
>
> ... rather than introduce a new JsonP class, my suggestion is that if a
> Clob object returned whose contentType is either "application/javascript"
> or "text/javascript" (the two media types for JSON-P) then this triggers
> whatever new behaviour you require.
>
>
>
> > and extend the code in ALFA ?
> >
> >
> yes, just extend the code there.
>
> Cheers
> Dan
>
>
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
>

Re: Actions producing JSONP

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 30 November 2014 at 21:02, Martin Grigorov <mg...@apache.org> wrote:

> Hi,
>
> I want my action button to produce some JSON and send it back to the
> browser where I will use this data to update a custom component.
>
> Looking at
>
> https://github.com/apache/isis/blob/master/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/ActionLinkFactoryAbstract.java#L168
> I see there are two special cases covered:
> - redirect when the result is java.net.URL
> - download when the result is Lob
>
> What is needed to achieve my goal ?
> Is there a way to plug a special handler for a custom result type ?
>

No, there isn't any plugin point.

I'm not convinced we need a formal API for this, rather just extend the
existing handler code to support the extra behaviour required...


> Or I need to add the new type to org.apache.isis.applib.value package
>

... rather than introduce a new JsonP class, my suggestion is that if a
Clob object returned whose contentType is either "application/javascript"
or "text/javascript" (the two media types for JSON-P) then this triggers
whatever new behaviour you require.



> and extend the code in ALFA ?
>
>
yes, just extend the code there.

Cheers
Dan


>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>