WebSphere Portal Server - Portlet Brodcasting problem.

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > August 2004 > Portlet Brodcasting problem.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Portlet Brodcasting problem.

2004-08-10, 5:58 pm

I am trying to brodcast a message as a DefaultMessage so the portlet which is in another application can receive the same. Portlets which are in the same page are able to receive the message but not in the other application.Trying to run example in Chapte
r 7 in Portla documentation. Code looks like this.

//Sending the message
public void actionPerformed(ActionEvent event) throws PortletException {
if( getPortletLog().isDebugEnabled() )
getPortletLog().debug("ActionListener - actionPerformed called");
// ActionEvent handler
String actionString = event.getActionString();

// Add action string handler here
if(actionString.equalsIgnoreCase(ACTION_RED)){

// Create the string of HTML to be rendered
String value = "Action <FONT color=\"#ff0000\">RED</FONT>";

// Create a portlet request
PortletRequest request = event.getRequest();
// Create an instance of portlet data to store values

PortletData portData = request.getData();

try{
// Save value into portlet data
portData.setAttribute("value", value);
portData.store();
}
catch (AccessDeniedException ade){
}catch (IOException ioe){}

// Send a portlet message
PortletMessage message = new DefaultPortletMessage(value);
try{
this.getPortletConfig().getContext().send(null,message);

}catch (AccessDeniedException e){}

}


}

//In receiving portlet which is in another application(Both applications are in same DefaultEar).

public void messageReceived(MessageEvent event) throws PortletException {
if( getPortletLog().isDebugEnabled() )
getPortletLog().debug("MessageListener - messageReceived called");
// MessageEvent handler
PortletMessage msg = event.getMessage();
// Add PortletMessage handler here
if( msg instanceof DefaultPortletMessage ) {
String messageText = ((DefaultPortletMessage)msg).getMessage();
// Add DefaultPortletMessage handler here
PortletRequest request = event.getRequest();
request.setAttribute("message", messageText);
}
else {
// Add general PortletMessage handler here
}
}

If I put this code in a portlet which runs in same application..then it works. Have any idea ?

Thanks.
Sudhakar

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com