it just exists...it's in the code i posted
IModel mailList = new LoadableDetachableModel()
{
protected Object load() {
user.openPopServer();
try {
messages=folder.getMessages();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List mailList1=Arrays.asList(messages);
return mailList1;
}
};
}
maybe the problem is that the new mails are not downloaded?!I've to start a
new session or reconnect to the pop folder in some way (i think it just
happens with folder.openPopServer() )??
igor.vaynberg wrote:
>
> you should use a loadable detachable model for your listview, that way
> it will work transparently.
>
> -igor
>
> On Fri, May 23, 2008 at 9:25 AM, Davidoff <[EMAIL PROTECTED]> wrote:
>>
>> this is code for the mail list (i implemented modal windows in order to
>> show
>> emails but JWebUnit tests returned errors then i have to find some other
>> way
>> to show mails...my priority now is to find the way to refresh the mail
>> listview:
>>
>> public class MailAccount extends WebPage {
>> private ModalWindow modal;
>> private Folder folder;
>> private User user;
>> private ListView listTable;
>> private List<Message> test;
>> private Message[] messages;
>> private Message msg;
>> private int index;
>> public MailAccount(String username, String password)
>> {
>> Manager manager=new Manager("AjaxUbiMailDB",1000);
>> user=manager.authenticate(username, password);
>> add(new Label("message","Hello " + user.firstName() +" "+
>> user.lastName()));
>> Properties sysProperties = System.getProperties();
>> Session session=Session.getDefaultInstance(sysProperties,
>> null);
>> session.setDebug(false);
>>
>> folder=user.openPopServer();
>> try {
>>
>> add(new Label("contains","Your MailBox contains "+
>> folder.getMessageCount() + " messages."));
>>
>>
>> } catch (MessagingException e) {
>> // TODO Auto-generated catch block
>> add(new Label("contains","Wrong Username or
>> password"));
>> System.out.println("Error on opening pop folder or
>> something else");
>> //e.printStackTrace();
>> }
>>
>>
>> initMailList();
>>
>> WebMarkupContainer listContainer = new
>> WebMarkupContainer("theContainer");
>> //generate a markup-id so the contents can be updated
>> through an AJAX call
>> listContainer.setOutputMarkupId(true);
>> listContainer.add(new
>> AjaxSelfUpdatingTimerBehavior(Duration.seconds(5)));
>> // add the list view to the container
>> listContainer.add(listTable);
>> // finally add the container to the page
>> add(listContainer);
>> user.closePopServer();
>> modal = new ModalWindow("modal");
>> addOrReplace(modal);
>> }
>>
>> public void initMailList(){
>> listTable=new ListView("listview",mailList)
>> {
>> private Folder folder=user.openPopServer();
>>
>> public void populateItem(ListItem item)
>> {
>> try {
>> final Message msg=(Message)
>> item.getModelObject();
>> Address[]
>> add=msg.getFrom();
>> index=msg.getMessageNumber();
>> AjaxLink rate = new
>> AjaxLink("mess") {
>> public void
>> onClick(AjaxRequestTarget target) {
>>
>>
>>
>> GetMessage getMessage;
>>
>>
>> getMessage = new GetMessage(modal.getContentId(), msg){};
>>
>>
>> modal.setContent(getMessage);
>>
>>
>> modal.setInitialHeight(600);
>>
>>
>> modal.setInitialWidth(1000);
>>
>>
>> modal.show(target);
>>
>>
>> modal.setTitle("Mail View");
>>
>>
>> }
>> };
>>
>> rate.add(new
>> Label("prova",String.valueOf(msg.getMessageNumber())));
>>
>> item.add(rate);
>>
>> item.add(new AttributeAppender("class", true, new
>> Model(index % 2 ==0 ? "odd": "even"), " "));
>>
>> item.add(new Label("subject",
>> msg.getSubject().toString()));
>>
>> item.add(new Label("from", add[0].toString()));
>> if
>> (msg.getSentDate()!=null)
>>
>> item.add(new Label("date",
>> msg.getSentDate().toString()));
>> else
>>
>> item.add(new Label("date", "Nothing"));
>> } catch (MessagingException e) {
>> System.out.println("Error
>> populate item");
>> //
>> e.printStackTrace();
>> }
>>
>> }
>> };
>> }
>> IModel mailList = new LoadableDetachableModel()
>> {
>>
>>
>> protected Object load() {
>>
>> user.openPopServer();
>> try {
>> messages=folder.getMessages();
>> } catch (MessagingException e) {
>> // TODO Auto-generated catch block
>>
>> e.printStackTrace();
>> }
>> List mailList1=Arrays.asList(messages);
>> return mailList1;
>> }
>> };
>> }
>>
>>
>>
>>
>> igor.vaynberg wrote:
>>>
>>> On Fri, May 23, 2008 at 2:20 AM, Davidoff <[EMAIL PROTECTED]> wrote:
>>>>
>>>> I'm creating a simple webmail application: i've created a listview
>>>> where
>>>> the
>>>> items are rows containing the number of the message, the subject and so
>>>> on... my target is to reproduce what Gmail does: clicking on the number
>>>> of a
>>>> mail i wanto to read it's content, and clicking again i want to return
>>>> to
>>>> the list (the content collapses).How can i do this?
>>>
>>> include a hidden webmarkupcontainer which you then replace with some
>>> other component that contains the mail content when the header is
>>> clicked. replace it back with a webmarkupcontianer to collapse.
>>>
>>>> Second question: i created a list like this
>>>> http://www.google.it/search?q=ajax+listview&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:it:official&client=firefox-a
>>>> but even if i send emails to the address in list, the listview will not
>>>> refresh(the messages are always the same).
>>>
>>> show us some code
>>>
>>> -igor
>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Ajax-ListView-as-Gmail-tp17421986p17421986.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Ajax-ListView-as-Gmail-tp17421986p17428158.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/Ajax-ListView-as-Gmail-tp17421986p17430132.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]