I would use a UserCredentials interface that gets passed down to the DAO.  My 
action would be more like:

public void execute(...) {
    // marshall the input 
    UserCredentials userCredentials = new 
PresentationLayerUserCredentials(request);
    // invoke the business layer
    PapersList list = PapersList.find(userCredentials);
    // save the results
    request.setAttribute("PapersList", list);
    // redirect
    return mapping.findForward("success");
}

Note that
 1. The PresentationLayerUserCredentials knows how to extract the proper 
information from the request, encapsulating that knowledge.
 2. The business layer just uses the generic UserCredentials interface.
 3. The list to be displayed is encapsulated in an object, not a naked 
collection.
 4. The action doesn't call directly to the DAO.
 5. The UserCredentials interface has a method that returns a value useful for 
the DAO to use in a SQL WHERE clause.

The business layer class might PapersList include something like:

static PapersList find(UserCredentials userCredentials) {
        PapersList results = new PapersList();  // create an empty list
        dao.find(results, userCredentials);             // fill the list from 
the dao
        return results;
}


> -----Original Message-----
> From: Joel Alejandro Espinosa Carra 
> [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, February 07, 2006 5:22 PM
> To: user@struts.apache.org
> Subject: Populate action
> 
> 
> Hi all,
> 
> I think this is more a design question than a struts question, but I 
> want to know who is the struts-way to do this.
> I have a requeriment of listing some items (in my case, scientific 
> papers) in a html table view.
> Another requirement is that users can see diferent listing of data 
> depending of theirs permissions, and the administrator can see 
> everything (like always)
> I want to know how much code I'm able to save if I design ONLY ONE 
> action for hadle the prepopulation of the items list that will be 
> displayed latter in a jsp page, or if its better to do more than one 
> single action for the prepopulation of data.
> 
> My action would be like this:
> 
> public void execute(...) {
>     List list = new LinkedList();
>    
>     if("admin".equals(request.getUserRole().toString())) {
>        //go to the DAO Layer and get the list of beans for 
> the admin role
>        list = dao.getPapersForAdmin();
>     }
>     //and so on for the others roles
>     .
>     .
>     .
>    
> } //note that I wrote this little code in my email client not 
> in my IDE
> 
> But what can I do in the case of one user could have more than one 
> option for display items, like the administrator are be able 
> to see only 
> the rejected papers but also can see all the papers.
> 
> Any ideas?
> 
> Best regards.
> 
> -- 
> Ing. Joel Alejandro Espinosa Carra
> CINVESTAV CTS - Centro de TecnologĂ­a de Semiconductores
> Tel. +52 (33) 3770-3700 ext. 1049
> http://www.cts-design.com 
> 
> 
> -- 
> Este mensaje ha sido analizado por MailScanner
> en busca de virus y otros contenidos peligrosos,
> y se considera que está limpio.
> MailScanner agradece a transtec Computers por su apoyo.
> 
> 
> ---------------------------------------------------------------------
> 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]

  • Populate action Joel Alejandro Espinosa Carra
    • RE: Populate action George.Dinwiddie

Reply via email to