Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Christian Perez
Using method without ActionRequest and ActionResponse
June 5, 2014 4:24 PM
Answer

Christian Perez

Rank: Junior Member

Posts: 46

Join Date: July 19, 2013

Recent Posts

Hi
I have a method that receive two parameters an object of the type ActionRequest and ActionResponse
1
2public void doSomething(ActionRequest, ActionResponse)
3{
4//logic
5}
and works fine, but I want to excute this method in a schedule
something like this
 1
 2public class Calendarizado implements MessageListener{
 3    
 4    private static final Log LOGGER = LogFactoryUtil.getLog(Calendarizado.class);
 5       
 6        public void receive(Message arg0) throws MessageListenerException {
 7call doSomething(param, param);
 8}
 9}


but at this point I donde have any request or any response, can I make my own response and request in the class Calendarizado?

or can I convert some data in request Object?
Andew Jardine
RE: Using method without ActionRequest and ActionResponse
June 5, 2014 5:15 PM
Answer

Andew Jardine

Rank: Liferay Master

Posts: 508

Join Date: December 22, 2010

Recent Posts

practicante,

I think the MessageListener is the handler for the event -- or more accurately the message placed onto the bus. I think what you are probably looking to do is retrieve the "message data" from the actionRequest in your processAction method, construct a Message object and place it on the bus for it to get to the Listener. If the message contains everything the Listener needs to process, then you shouldn't need the actionRequest in the Listener class. So, something like --

 1
 2public void processAction(ActionRequest actionRequest, ActionResponse actionResponse )
 3{
 4    // build your message to be sent to the listener
 5    Message message = new Message();
 6    message.put("key", ParamUtil.getString(actionRequest, "variable-name");
 7
 8   // place it on the bus
 9   MessageBusUtil.sendSynchronousMessage( <destination>, message);
10}
Pankaj Kathiriya
RE: Using method without ActionRequest and ActionResponse
June 5, 2014 5:40 PM
Answer

Pankaj Kathiriya

Rank: Liferay Master

Posts: 671

Join Date: August 4, 2010

Recent Posts

Scheduler jobs are something thats runs offline(without any browser request which leads request-response life cycle) as per interval defined without any request-response cycle. You cant define or make use of actionRequest or actionResponse in scheduler method.