RE: [STRUTS] Please !

2002-09-12 Thread Irwin, Chris

Somebody correct me if I'm wrong, but it's dangerous to use any
class-level variables in a Struts action class because these classes are
supposed to be reentrant.

>  -Original Message-
> From: kiuma <[EMAIL PROTECTED]>@AFG  
> Sent: Thursday, September 12, 2002 1:18 PM
> To:   struts-user
> Subject:  Re: [STRUTS] Please !
> 
> Thx, but since I'm complitely new to struts I don't know what to do:
> 
> *Here is my action class*
> 
> public class ListedUserAction extends LookupDispatchAction {
> 
>   protected String keyfinder = "";
> 
>   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
> {
>   //keyfinder = ((ListedUserForm)form).getUserToFind();
> 
>   return mapping.findForward( IStrutsConstants.SUCCESS );
>   //"/secure/userlist.jsp?userToFind=" + keyfinder
>   }
> 
>   public ActionForward find( ActionMapping mapping,
>   ActionForm form,
>   HttpServletRequest req,
>   HttpServletResponse res ) throws
> Exception
> {
>   //keyfinder = ((ListedUserForm)form).getUserToFind();
> 
>   return mapping.findForward( IStrutsConstants.SUCCESS );
>   //"/secure/userlist.jsp?userToFind=" + keyfinder
>   }
> 
>   public ActionForward append( ActionMapping mapping,
>   ActionForm form,
>   HttpServletRequest req,
>   HttpServletResponse res ) throws
> Exception
> {
>   //keyfinder = ((ListedUserForm)form).getUserToFind();
> 
>   return mapping.findForward( IStrutsConstants.SUCCESS );
>   //"/secure/userlist.jsp?userToFind=" + keyfinder
>   }
> 
> }
> 
> *my jsp page:*
> 
> <%@page language="java"
> contentType="text/html;charset=UTF-8"
> session="true"
> isThreadSafe="true"
> isErrorPage="false"
> import="javax.naming.*,
>   com.wingstech.webappointments.interfaces.*,
>   java.util.*"
> %>
> <%@ taglib uri="/WEB-INF/struts-html.tld"
> prefix="html" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld"
>   prefix="bean" %>
> 
> 
> 
> 
> 
>   
>   
> 
> 
> 
> 
> 
> 
>   
>   
>key="label.find.surname"/>: 
>   
>   
>   
>   
>   
>   
> 
> 
> 
> 
> 
> 
> 
> 
> 
> <%--  class="package.class" /> --%>
> <%--  /> --%>
> 
> 
> 
> 
> 
> *and my  config tag:*
> 
>  path="/userlist"
> type="com.wingstech.webappointments.ListedUserAction"
> parameter="submit"
> scope="request"
> validate="false">
>  />
> 
> 
> 
> *
> I really can't see the error, can you help me please?*
> 
> 



RE: DropDown-Selects

2002-09-10 Thread Irwin, Chris

You'll have to specify something like this:

 
  
  

Is what you're doing?  I see a pulldown list with more than one value displayed at 
once.


>  -Original Message-
> From: [EMAIL PROTECTED]@AFG   On Behalf Of "Fabian Sommer" <[EMAIL PROTECTED]>
> Sent: Tuesday, September 10, 2002 10:12 AM
> To:   [EMAIL PROTECTED]
> Subject:  DropDown-Selects
> 
> Hello folks!
> 
> I got a problem that´s perhaps noch struts-specific:
> 
> If I create a struts-html-select within a form with a size of 1, I
> expect to get a dropdown-list. Self-html describes this as the
> standard-behaviour. But when I have a look at my jsp I find a normal
> select-field with the size 1 and when I use the scroll-elements to its
> right, I just can scroll through my options, showing only one while I
> was hoping that there appears a dropdown-list when I click on the
> scroll-elements?
> Is this normal behaviour?
> And if so, how to create dropdown-lists within struts-forms?
> Thanks, Fabian Sommer
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 



RE: ServletContext in a Action

2002-09-09 Thread Irwin, Chris

What I meant was my action classes start something like this:

public class SHSMI_Action extends Action {

The Action class has a method defined as:

  public ActionServlet getServlet() { return null;}



>  -Original Message-
> From: "rainer juenger" <[EMAIL PROTECTED]>@AFG  
> Sent: Monday, September 09, 2002 4:16 PM
> To:   Struts Users Mailing List
> Subject:  Re: ServletContext in a Action
> 
> Hi Chris
> 
> 
> >That's easy:
> >getServlet().getServletContext()
> >getServlet is in the Action class that you're extending...
> 
> nope, Action does not extend HttpServelt but Object ...
> there for getServlet() can not be used.
> 
> Rainer
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:
> 
> For additional commands, e-mail:
> 
> 



RE: ServletContext in a Action

2002-09-09 Thread Irwin, Chris

That's easy:

getServlet().getServletContext()

getServlet is in the Action class that you're extending...

>  -Original Message-
> From: "rainer juenger" <[EMAIL PROTECTED]>@AFG  
> Sent: Monday, September 09, 2002 4:05 PM
> To:   Struts Users Mailing List
> Subject:  ServletContext in a Action
> 
> Hi,
> 
> how can I get values out of the ServletContext within a Action?
> 
> such as:
> ServletContext ctx = getServletConfig().getServletContext();
> String dbdriver = ctx.getAttribute(Constants.DBDRIVER);
> 
> thanks rainer
> 
> 



Re: FormFile.destroy() vs DiskFile.destroy() -- bug?

2002-09-09 Thread Irwin, Chris

Maybe it works right on Linux, but the temp file doesn't seem to get
deleted on Windows if there is actually data in it.  If an upload didn't
really happen, the 0-byte temp file is destrotyed.

There must still be a handle on it somehow:

/**
 * Saves an attachment to the TEMP_ATTACHMENTS table
 * @param aDiskFile The DiskFile object from the Struts framework
 * @param aAttachmentDesc The description of the file-attachment
 * @param aDatabase The database object
 * @param aStatement The statement object
 * @param aSession the HTTP session
 * @returns An empty string if successful or the error message for an
invalid file
 * @throws Exception A SQL or Logged exception
 */
public static String saveAttachment(final DiskFile aDiskFile,
 final String aAttachmentDesc,
 final DB aDatabase,
 final Statement aStatement,
 final HttpSession aSession) throws
Exception {
  Table_TEMP_ATTACHMENTS ta=new Table_TEMP_ATTACHMENTS();
  ta.init(aSession.getId());
  ta.setAttachmentName(aDiskFile.getFileName());
  ta.setMimeType(aDiskFile.getContentType());
  ta.setAttachmentDesc(aAttachmentDesc);
  ta.setBlob(aDiskFile);
  if (aDiskFile.getFileSize()>0) {
ta.save(aDatabase,aStatement);
aDiskFile.destroy(); // <---  Not working
return StringEx.EMPTY_STRING;
  }
  else
return "ERROR: The file '"+aDiskFile.getFileName()+"' does not exist
or is empty.";
}


From: SCHACHTER,MICHAEL (HP-NewJersey,ex2) <[EMAIL PROTECTED]>
Subject: FormFile.destroy() vs DiskFile.destroy() -- bug?
Date: Thu, 6 Sep 2001 09:50:09 -0700 
Content-Type: text/plain;
charset="iso-8859-1"

Min,

Since FormFile is an interface, you're calling on DiskFile.destroy()
regardless.
However, DiskFile.destroy() calls on java.io.File.delete().  I've
encountered
problems in the past with java.io.File.delete() where the file doesn't
get
deleted.
I'll file a bug report on this and get to it when I have a chance.

-Original Message-
From: Mindaugas Idzelis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 06, 2001 10:39 AM
To: struts
Subject: FormFile.destroy() vs DiskFile.destroy() -- bug?


Struts,

It seems to me that there is a problem in either FormFile or
DiskFile. In
order for me to get the path information about the file stored on disk,
I
have to cast FormFile to DiskFile and call getFilePath(). It would be
convenient if DiskFile.destroy() would actually get rid of the temporary
files. In order for me to get rid of them I have to up-cast DiskFile to
FormFile and then call destroy() on the interface. As far as I can tell,
calling destroy() on DiskFile does nothing. Is this a bug or a feature?

--Min Idzelis