I was studying JSF and found this site where it teaches to create a basic chat using JSF, primefaces and ajax: link
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;
}
}
However, an error occurs in this line return messages.get(0);
and in this for(Message m : messages) {
.
The first error is to cast cast , so I did and the error disappeared, but the second error ( for(Message m : messages) {
) points to the following message:
Type mismatch: can not convert from object type Object to Message
How can I resolve this error?