0
I was studying JSF and found this site where teaches to create a basic chat using JSF, primefaces and ajax: https://jetcracker.wordpress.com/2012/03/04/jsf-how-to-create-a-chat-with-ajax/
I have the Messagemanager class
public class MessageManager implements MessageManagerLocal {
private final List messages =
Collections.synchronizedList(new LinkedList());;
@Override
public void sendMessage(Message msg) {
messages.add(msg);
msg.setDateSent(new Date());
}
@Override
public Message getFirstAfter(Date after) {
if(messages.isEmpty())
return null;
if(after == null)
return messages.get(0);
for(Message m : messages) {
if(m.getDateSent().after(after))
return m;
}
return null;
}
}
But an error occurs on this line return messages.get(0);
and in this for(Message m : messages) {
.
The first mistake tells to make one cast, then I did and the mistake was gone, but the second mistake (for(Message m : messages) {
) he points out the following message:
Type Mismatch: cannot Convert from element type Object to Message
How can I fix this mistake?
thank you very much!
– Fernando Tricks Combo