Announcement Announcement Module
Collapse
No announcement yet.
problems portlet eventRequest.setAttribute Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problems portlet eventRequest.setAttribute

    Hi,

    I am facing a problem with event handling method in Spring portlet mvc 3.

    Inside the event method (public final void receiveMessage) i added an attribute into the model

    Code:
    model.addAttribute("receivedMessage", msg);
    but the attribute is not available in the render method executed after the event request (ofcourse, ${receivedMessage} in JSPs is also empty).

    i also tried request.setAttribute("receivedMessage", msg) But no result.


    The complete code,

    Code:
    @Controller
    @RequestMapping("VIEW")
    public class ReceiveMessageController {
        
        /** Log. */
        private Log log = LogFactory.getLog(ReceiveMessageController.class);
    
        @RequestMapping
        public final String viewMessage(final RenderRequest request, 
                final RenderResponse response, final Model model) {
            log.debug("inside ReceiveMessageController.viewMessage");
            
            if (!model.containsAttribute("receivedMessage")) {
                log.debug("receivedMessage is empty");
                model.addAttribute("receivedMessage", "no message");
            }
            return "message";
        }
    
        @EventMapping(value = "{http://jishin.org/events}onMessage")
        public final void receiveMessage(final EventRequest request, 
                final EventResponse response, final Model model) {
            log.debug("inside ReceiveMessageController.receiveMessage");
            Event event = request.getEvent();
            String msg = (String) event.getValue();
            log.debug("ReceiveMessageController received message = " + msg);
            
            model.addAttribute("receivedMessage", msg);
        }
    }
    The liferay portal log,


    INFO: DEBUG - inside ReceiveMessageController.receiveMessage

    INFO: DEBUG - ReceiveMessageController received message = Hello World

    INFO: DEBUG - inside ReceiveMessageController.viewMessage

    INFO: DEBUG - receivedMessage is empty

    Am i doing something wrong, or Is it a bug in Spring Portlet MVC 3 ?

    Thanks in Advance,
    Jishin
    Last edited by jishin; Jul 30th, 2010, 09:51 AM.

  • #2
    Its a bug in spring. Its fixed in version 3.0.4

    https://jira.springframework.org/browse/SPR-7407

    Thanks,
    Jishin

    Comment

    Working...
    X