1

I cant see the difference between MVCActionCommand vs MVCResourceCommand in coding OSGI portlets. The two interfaces seem to be interchangeable. With ActionResponse you can jump to a URL. With ResourceResponse, I can set the content to view the content on the page.

  1. If i need to refresh the content on the page i.e refresh a particulat , should I use ActionReponse ? Most of the examples i found on the net make use of ResourceResponse resourceResponse.getWriter().write("Success");

  2. How do I know when to use ResourceResponse and not ActionResponse?

Many thanks.

avocadoLambda
  • 1,332
  • 7
  • 16
  • 33
user9718914
  • 103
  • 9

1 Answers1

2

The origin of the separation lies within the Java Portlet LifeCycle (JSR 286). The command interfaces allow hooking into the lifecycle phases and provide the execution of your custom code.

There are three very different (in purpose) portlet url handlers:

  • MVCActionCommand to execute command, to change data, to perform actions (and do not return any to the frontend)

  • MVCRenderCommand to provide presentation & view to the client, to view results from a model selection, to render data through jsp/jsf/etc

  • MVCResourceCommand to provide the content in response: download files, download json csv excel pdf ...

André
  • 172
  • 13
Daniele Baggio
  • 2,157
  • 1
  • 14
  • 21
  • on top: _render_ always renders part of the resulting page, e.g. it returns HTML - but without the `` and `` parts. A _resource_ request stands on its own and can generate arbitrary results, e.g. XML, JSON, TXT, GIF, DOC, ... . Also, _action_ is typically followed by _render_, while a _resource_ request has only that single phase. – Olaf Kock Jul 06 '20 at 08:38