Re: LookupDispatchAction default

2004-03-25 Thread Mark Shifman
Look at the sourc for LookupDispatchAction snippet below:
public ActionForward execute(
   ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response)
   throws Exception {
   // Identify the request parameter containing the method name
   String parameter = mapping.getParameter();
   if (parameter == null) {
   String message = messages.getMessage(dispatch.handler, 
mapping.getPath());
   throw new ServletException(message);
   }

   // Identify the string to lookup
   String name = request.getParameter(parameter);
   if (name == null) {
   String message =
   messages.getMessage(dispatch.parameter, 
mapping.getPath(), parameter);
   throw new ServletException(message);
   }

It looks for the parameter's value and throws if the name is null so it 
never gets a chance to get to unspecified in Dispatch action.

mas

Brian Sayatovic/AMIG wrote:

Well, I tried overriding unspecified and I still get the following (mind 
you that I didn't change the parameter name yet) when I hit 
/admin/list.do:

   Error 500: Request[/admin/list] does not contain handler parameter 
named submit 

My unspecified method I simply overrode from DispatchAction to call my 
normal refresh list method:

   protected ActionForward unspecified(
   ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response
   ) {
   return this.refreshList(mapping, form, request, response);
   }
While the JavaDocs do imply this should work, when I looked in the Struts 
1.1 source, the execute method of LookupDispatchAction generates the erorr 
message I see as soon as request.getParameter(parameterName) returns null. 
In fact, I can find no reference to 'unspecified' anywhere in 
LookupDispatchAction.

So I think there is a disconnect.  Maybe LookupDispatchAction is broken 
and should be fixed to also use 'unspecified', or maybe its JavaDocs 
should explicitly state that it does not utilize the 'unspecified' 
behavior of its parent class.  Or, maybe I missed something and didn't 
implement correctly?

Regards,
Brian.


Mark Lowe [EMAIL PROTECTED]
03/24/2004 09:21 AM
Please respond to Struts Users Mailing List
   To: Struts Users Mailing List [EMAIL PROTECTED]
   cc: 
   Subject:Re: LookupDispatchAction default



unspecified() is the method you want look at the javadoc.

you do need the method name though

/admin/list.do?method

I saw that using submit as the parameter name causes problems so i 
wouldn't use that.

On 24 Mar 2004, at 15:16, Brian Sayatovic/AMIG wrote:

 

I'd like to be able to have someone hit my action, /admin/list.do, 
without
having to specify a submit paramater.  However, the action is a 
subclass
of LookupDispatchAction whci requires that the request parameter be
supplied.  Looking in the struts source code, it would be nice if the
LookupDispatchAction could fall back to a default or not consider 
'null'
to be a bad value and just use 'null' as a key to the lookup Map.  For
now, any link or redirect to the page must specify what I consider to 
be
the default action -- refresh -- on the URL:
/admin/list/do?submit=Refresh.

Is there another way to do this?  Is it worth suggesting that
LookupDispatchAction support a default or null mapping?
Regards,
Brian.
   



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


 



--
Mark Shifman MD. Ph.D.
Yale Center for Medical Informatics
Phone (203)737-5219
[EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: blocking bookmarked actions

2004-03-25 Thread Mark Shifman
Thanks , I was using jakarta-struts-1.1-rc1 which did the nul parameter 
trapping.
mas

Wendy Smoak wrote:

From: Mark Shifman [mailto:[EMAIL PROTECTED] 
Unfortunately LookupDispatchAction checks for the parameter 
an throws an 
error before it gets a chance to use unspecified(), but it should
be easy enough to modify it and then override dispatchActions 
unspecified().
   

What version?  I think unspecified works right at least since 1.2.0,
probably before that.
But you can use the fact that execute is always called first, so
override execute and check for the parameter.  If it's there, just call
super.execute() and things will work, if it's not there, look
up/construct an ActionForward and return that.
Looking at some old code, that's what I used to do... The newer project
doesn't have an execute method and it works fine when the parameter for
a LookupDispatchAction is not in the request.
 



--
Mark Shifman MD. Ph.D.
Yale Center for Medical Informatics
Phone (203)737-5219
[EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: File upload location

2004-03-24 Thread Mark Shifman
Deepak wrote:

Hi,
   What is the default location of a file uploaded using html:file ? Can I upload it to one of the folders in my context path ?
 

It goes someplace temporary. If you look at the src for the UploadAction 
example in Struts, it shows how to save the temporary file.

I create a temporary dir with sessionCreated() in the 
HttpSessionListener ie myapp/temp/sessionID

then you can get to it via 
session.getServletContext().getRealPath(temp) + /+ session.getId();

and create an outputstream that goes there.

When the session is destroyed I remove the files and the dir 
myapp/temp/sessionID

thanks
Deepak
 



--
Mark Shifman MD. Ph.D.
Yale Center for Medical Informatics
Phone (203)737-5219
[EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


blocking bookmarked actions

2004-03-24 Thread Mark Shifman
Suppose someone bookmarked an action such as 
/yourhost/yourapp/someAction.do and you really want them to only go 
through the html pages.

How do your block or catch these actions and redirect them to the 
appropriate place?

mas

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: blocking bookmarked actions

2004-03-24 Thread Mark Shifman
where do I do the blocking?  The action I am having problems with is a 
LookupDispatchAction and I get this kind of error message

javax.servlet.ServletException: Request[/RechartFiles] does not contain handler 
parameter named method

org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:199)
...

Paul McCulloch wrote:

You code code your app to always use http POST, but block GETs. This may not
be suitable if you've already written the app though!
Paul

 

-Original Message-
From: Mark Shifman [mailto:[EMAIL PROTECTED]
Sent: 24 March 2004 18:17
To: Struts Users Mailing List
Subject: blocking bookmarked actions
Suppose someone bookmarked an action such as 
/yourhost/yourapp/someAction.do and you really want them to only go 
through the html pages.

How do your block or catch these actions and redirect them to the 
appropriate place?

mas

-
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]


Re: blocking bookmarked actions

2004-03-24 Thread Mark Shifman
Thanks.
Unfortunately LookupDispatchAction checks for the parameter an throws an 
error before it gets a chance to use unspecified(), but it should
be easy enough to modify it and then override dispatchActions unspecified().

mas

Wendy Smoak wrote:

From: Mark Shifman [mailto:[EMAIL PROTECTED] 
where do I do the blocking?  The action I am having problems 
with is a LookupDispatchAction and I get this kind of error message
javax.servlet.ServletException: Request[/RechartFiles] does 
not contain handler parameter named method
org.apache.struts.actions.LookupDispatchAction.execute(LookupD
ispatchAction.java:199)
   

We were just talking about that earlier today... Are you using a version
of LDA that has the 'unspecified' method inherited from Dispatch Action?
Implementing that method will stop the errors, and you may not need to
force them to go through the HTML page if you can do the default
behavior with no user input.
 



--
Mark Shifman MD. Ph.D.
Yale Center for Medical Informatics
Phone (203)737-5219
[EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: validation.xml multiple select

2004-03-08 Thread Mark Shifman
http://javaboutique.internet.com/tutorials/Struts11Val/

shows how to make a custom validator for multiple selects that worked for me

mas
Siamack wrote:
Hello Everyone:

I have a multiple select option as follows:

select name=countries multiple=multiple size=4
   option value=FA France /option
   option value=GR Germany/option
   option value=USA America /option
/select
in my struts-config.xml, I use a DynaValidatorForm as follows

form-beans  
 form-bean dynamic= true  name= UserForm  
type= org.apache.struts.validator.DynaValidatorForm   
   form-property name= username  type= java.lang.String[] /  
.
.
. 
 /form-bean  
/form-beans  

in my validation.xml I also have the following entry:

 field property=countries depends=required
   arg0 key=label.geographies/
  /field
.
.
The validation does not work when I select nothing, though the other fields such as checkboxes, textfields, etc are okay? It seems when nothing is selected an empty array of string of size 0 is returned rather than a null value. Is there any way that I can check for the length of string array to be 0 (nothing selected) or is there any other way to make this work.

I would greatly appreciate your replies in advance.





-
Post your free ad now! Yahoo! Canada Personals
 



--
Mark Shifman MD. Ph.D.
Yale Center for Medical Informatics
Phone (203)737-5219
[EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: FileUploading Error

2004-02-18 Thread Mark Shifman
I am using Mozilla 1.2.1. via redhat.  How can I see what is passed   
without doing an autopsy on the request handler?
mas

Andrew Hill wrote:

Hmmm. Sounds rather like a browser issue to me. You might want to see what
is actually being passed in that request - if its actually a valid multipart
request or not!
I had a try in IE, but IE's file selector is too smart to allow selection of
a folder as the upload file. Which browser are you using?
-Original Message-
From: Joe Germuska [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 17 February 2004 00:13
To: Struts Users Mailing List
Subject: Re: FileUploading Error
At 9:35 AM -0500 2/16/04, Mark Shifman wrote:
 

In trying to bulletproof file uploading I noticed something odd.

If I type some junk in the field for the file name and hit Submit, I get
a file of size 0. I can deal with that.  If I type in a directory name
in my home directory (admittedly a dumb thing to type) nothing seems to
happen and I get this error in my log file.
ERROR 2004-02-13 14:09:18,679
handleRequest(CommonsMultipartRequestHandler.java:241)
Failed to parse multipart request
org.apache.commons.fileupload.FileUploadException: Processing of
multipart/form-data request failed. Stream ended unexpectedly
...
This error seems to be thrown before it even gets to my UploadAction.
How do I catch this and tell the user the file typed in is invalid?
   

In Javascript, the value of the form field is the path to the file;
you might be able to apply a mask validation testing for a reasonable
filename -- this is far from perfect, but may help.  I use this as a
cheap way to get around the lack of support for the accepts
attribute -- I test to see if the file has a right extension using
the mask validator.
Just one thought...

Joe

--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
  Imagine if every Thursday your shoes exploded if you tied them
the usual way.  This happens to us all the time with computers, and
nobody thinks of complaining.
-- Jef Raskin
-
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]
 



--
Mark Shifman MD. Ph.D.
Yale Center for Medical Informatics
Phone (203)737-5219
[EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


FileUploading Error

2004-02-16 Thread Mark Shifman
In trying to bulletproof file uploading I noticed something odd.

If I type some junk in the field for the file name and hit Submit, I get
a file of size 0. I can deal with that.  If I type in a directory name
in my home directory (admittedly a dumb thing to type) nothing seems to
happen and I get this error in my log file.
ERROR 2004-02-13 14:09:18,679 handleRequest(CommonsMultipartRequestHandler.java:241)
Failed to parse multipart request
org.apache.commons.fileupload.FileUploadException: Processing of
multipart/form-data request failed. Stream ended unexpectedly
...
This error seems to be thrown before it even gets to my UploadAction.
How do I catch this and tell the user the file typed in is invalid?
--
  [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]