Foros de discusión

Possible to send an action request without the user clicking anything?

John John, modificado hace 12 años.

Possible to send an action request without the user clicking anything?

New Member Mensajes: 23 Fecha de incorporación: 13/02/12 Mensajes recientes
Basically I have a lot of code in my jsp which I would like to refactor into different classes. I have string variables whose values need to be generated upon rendering and currently this is working with all of the code in the jsp. I've had portlets call methods during the render phase to return Lists and whatnot, but what if I want this method call to set render parameters? Is this possible? I can do this by getting a PortletPreferences object and using setValue or I can use an actionresponse and use setRenderParameter. Each of these need an ActionResponse or an ActionRequest. The only time I've passed an ActionResponse or ActionRequest to a method was when clicking something using an actionURL. I feel this is probably a stupid question. Forgive me as I am new. Any insight is appreciated.
John John, modificado hace 12 años.

RE: Possible to send an action request without the user clicking anything?

New Member Mensajes: 23 Fecha de incorporación: 13/02/12 Mensajes recientes
okay right now i am accomplishing this by having a form with a hidden field and submitting that form automatically with javascript. There has to be a better way, right? How can I get an ActionRequest/response object to pass as parameters on a method call?
thumbnail
Jan Geißler, modificado hace 12 años.

RE: Possible to send an action request without the user clicking anything?

Liferay Master Mensajes: 735 Fecha de incorporación: 5/07/11 Mensajes recientes
Well as a matter of fact, what you name "click something" is the only way of determining that a User wants something from you application. Sending the Requst via JavaScript is the only option you have here, because the ActionRequest and RenderRequest are what they are named. Request. And a Request is dependent on an Action a User does (Clicking something).
John John, modificado hace 12 años.

RE: Possible to send an action request without the user clicking anything?

New Member Mensajes: 23 Fecha de incorporación: 13/02/12 Mensajes recientes
ah I see. I originally was just using a RenderRequest / response and that worked fine but this same method needs to be called as an action request (when the user clicks something) with a parameter that gets incremented. I was trying to avoid having 2 separate methods with a bunch of code duplication, one for RenderRequest and one for an ActionRequest
thumbnail
Jan Geißler, modificado hace 12 años.

RE: Possible to send an action request without the user clicking anything?

Liferay Master Mensajes: 735 Fecha de incorporación: 5/07/11 Mensajes recientes
Well, portlet specs are defining the two phases of a request cycle. you should do your logic in the Action, and the setup for the view in the renderRequest. So you can have one RenderMethod for a detail of an Entity, but two different actions (Create an empty entity for a new Record, or load the specified entry entry for an edit.) But both method use the same render Method, so you actually AVOID duplicating code.

So long
Jan