You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Nail, Evan Burke" <Ev...@ENRON.com> on 2004/12/02 20:35:33 UTC

DataTable and returning to same page.

I'm fairly new to JSF and am having a problem using the datatable. 
 
I'm implementing "select to delete" functionality based on some code I believe Craig posted. It uses a UISelectBoolean and UIData and iterates through them to determine the selected rows as such...
 
        int first = table.getFirst();
        int rows = table.getRows();
        
        for (int index = first; index < (first + rows); index++) {
 
            // Position the table at the current row ...
            table.setRowIndex(index);
            // And get the message bean for this row ...
            Photo photo = (Photo)
             FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("photo");
         
            // If this row is selected, delete the corresponding photo
            if (selected.isSelected()) {
                photosToDelete.add(photo);
            }
 
        }
        table.setRowIndex(-1); // We're done now
        return "go_photolist";
 
This works fine for me if my action returns to a different page ( i.e. return "go_home" ) however if I return to the same page  I get a nullpointerexception on the HtmlDataTable getFirst Method. 
 
I'm sure I just simply don't understand how the model gets updated throughout the lifecycle and somehow I'm not setting things up correctly, but I'm not sure how to accomplish this. 
 
Anyone know what I need to do?
 
 
Thanks
Burke
 
 
 


**********************************************************************
This e-mail is the property of Enron Corp. and/or its relevant affiliate and may contain confidential and privileged material for the sole use of the intended recipient (s). Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender or reply to Enron Corp. at enron.messaging.administration@enron.com and delete all copies of the message. This e-mail (and any attachments hereto) are not intended to be an offer (or an acceptance) and do not create or evidence a binding and enforceable contract between Enron Corp. (or any of its affiliates) and the intended recipient or any other party, and may not be relied on by anyone as the basis of a contract by estoppel or otherwise. Thank you. 
**********************************************************************