struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darren Hill <dh...@724.com>
Subject RE: [kiuma ] LookupDispatchAction ...
Date Fri, 20 Sep 2002 14:05:40 GMT
I'm trying to code with low coupling to anything .. but here's what I'm
using.

JBoss 3.0.2 w/Strits 1.1 with MS SQL 2000 as a back-end.

The code I'm asking for would having nothing to do with this.

Just a snippet from the sturts-config.xml and the jsp that utilizes
LookupDispatchAction.

-----Original Message-----
From: kiuma [mailto:kiuma@usa.net]
Sent: September 20, 2002 9:45 AM
To: Struts Users Mailing List
Subject: Re: [kiuma ] LookupDispatchAction ...


Do u use jboss + struts + postgres , under linux.

If so I could share my code with you.
I'm planning to do this.

Part deploy undere lgpl (or similar) as a case study,
Part as a commercial app (not yet implemented.

Would you like to use jboss I can help you to start if you are not 
familiar with.

Darren Hill wrote:

>By the way ... 
>
>If that is your actual code .. I have a few suggestions.
>
>1)  Create a plug-in that, on initilization, stores the JNDI context into
>either the Applciation or Session object.
>	- rather the create it every time.
>
>2)  Make use of the EJBHomeFactory pattern when gaining access to the EJB
>Home interfaces.
>	- reduces calls and produces less redundant code.
>
>3)  Make use of a Session facade to hide all EJB activity.
>	- Centralizes a service layer that can be interchanged ( in case you
>want to use your app with some other the EJB )
>
>
>Any help you need with that ... I here for ya.
>
>D.
>
>Do you have an example struts-config.xml and jsp for that code below for
me?
>
>
>
>-----Original Message-----
>From: kiuma [mailto:kiuma@usa.net]
>Sent: September 20, 2002 8:40 AM
>To: Struts Users Mailing List
>Subject: Re: LookupDispatchAction
>
>
>I hope this can help u,
>bye,
>kiuma
>
>
>/*
> * CustomerCustomerAction.java
> *
> * Created on 9 settembre 2002, 14.16
> */
>
>package com.wingstech.webappointments;
>
>import org.apache.struts.actions.*;
>import org.apache.struts.action.*;
>import org.apache.struts.util.MessageResources;
>import javax.servlet.http.HttpSession;
>import javax.servlet.http.HttpServletRequest;
>import javax.servlet.http.HttpServletResponse;
>import com.wingstech.webappointments.utils.*;
>import com.wingstech.webappointments.interfaces.*;
>import javax.naming.*;
>import java.util.*;
>import org.w3c.dom.*;
>/**
> *
> * @author  kiuma
> *
> *
> *
> *
> */
>
>//LookupDispatch
>
>public class ListedCustomerAction extends LookupDispatchAction {
>//public class ListedCustomerAction extends Action {   
>   
>   
>    protected Map getKeyMethodMap()
>    {
>            Map map = new HashMap();
>            map.put("button.find", "find");
>            map.put("button.delete.selected", "delete");
>            map.put("button.append", "append");
>            return map;
>    }
>
>    public ActionForward delete( ActionMapping mapping,
>                                  ActionForm form,
>                                  HttpServletRequest req,
>                                  HttpServletResponse res ) throws 
>Exception
>    {      
>        Collection customersToDelete = 
>((ListedCustomerForm)form).getListCustomerChecked();
>        try {
>            Context lContext = new InitialContext();
>            CustomerSessionHome lHome = (CustomerSessionHome) 
>lContext.lookup(
>                "java:comp/env/ejb/webappointments/CustomerSession"
>            );
>            CustomerSession cSession = lHome.create();           
>            cSession.deleteCustomerByIDs( customersToDelete );
>           
>            HttpSession hSession = req.getSession(true);
>            Collection collSave = 
>((Collection)hSession.getAttribute(IStrutsConstants.SESSION_CUSTOMER_LIST))
;
>            Iterator iter = collSave.iterator();
>           
>            int i;
>            int currArrayPos = 0;          
>            while (iter.hasNext())
>            {
>                CustomerData cData = ((CustomerData)iter.next());
>                if ( customersToDelete.contains( cData.getId() + "" ) 
>)               
>                {                   
>                    iter.remove();
>                }                              
>            }
>            
>hSession.setAttribute(IStrutsConstants.SESSION_CUSTOMER_LIST, collSave);
>           
>            return mapping.findForward( IStrutsConstants.SUCCESS );
>        } catch (Exception e) {
>            return mapping.findForward( IStrutsConstants.SUCCESS );
>        }
>              
>    }
>   
>    public ActionForward find( ActionMapping mapping,
>                                  ActionForm form,
>                                  HttpServletRequest req,
>                                  HttpServletResponse res ) throws 
>Exception
>    {
>
>        String keyfinder = ((ListedCustomerForm)form).getCustomerToFind();
>       
>       
>        if ( !keyfinder.equals("") )
>        {
>            CustomerData uData;
>            Collection cCustomers;
>            Iterator iter;           
>            try {
>                Context lContext = new InitialContext();
>                CustomerSessionHome lHome = (CustomerSessionHome) 
>lContext.lookup(
>                    "java:comp/env/ejb/webappointments/CustomerSession"
>                );
>                CustomerSession cSession = lHome.create();
>                cCustomers = cSession.getAllWithName( keyfinder );
>                HttpSession hSession = req.getSession(true);
>                
>hSession.removeAttribute(IStrutsConstants.SESSION_CUSTOMER_LIST);
>                if (cCustomers.size() > 0)
>                    
>hSession.setAttribute(IStrutsConstants.SESSION_CUSTOMER_LIST, cCustomers);
>            } catch (Exception e) {
>                System.out.println( e.getMessage() );
>                return mapping.findForward( IStrutsConstants.FAILURE );
>            }
>        }
>       
>        return mapping.findForward( IStrutsConstants.SUCCESS );
>    }
>   
>    public ActionForward append( ActionMapping mapping,
>                                  ActionForm form,
>                                  HttpServletRequest req,
>                                  HttpServletResponse res ) throws 
>Exception
>    {       
>        return mapping.findForward( IStrutsConstants.CUSTOMER_APPEND );    
>    }
>   
>}
>
>
>
>Darren Hill wrote:
>
>>Hey everyone .. happy Friday.
>>
>>Does anyone have a working example the uses LookupDispatchAction.  I think
>>
>I
>
>>understand ... just wanna see some working example code.
>>
>>D.
>>
>>--
>>To unsubscribe, e-mail:
>>
><mailto:struts-user-unsubscribe@jakarta.apache.org>
>
>>For additional commands, e-mail:
>>
><mailto:struts-user-help@jakarta.apache.org>
>
>>.
>>
>
>
>
>--
>To unsubscribe, e-mail:
><mailto:struts-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail:
><mailto:struts-user-help@jakarta.apache.org>
>
>--
>To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>
>
>.
>



--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message