You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dakota Jack <da...@gmail.com> on 2005/02/28 16:08:49 UTC

Upload Requirements Suggestion for 1.3

Another try at communication on this upload thing.

There is no use of the multipart request wrapper in struts until after
its state is set in RequestUtils.  The state is set by the
MultipartRequestHandler which is not obtained until the populate
method of RequestUtils, which handler is determined by
Globals.MULTIPART_KEY.   There is no use for the wrapper until this
point and all prior references can be deleted without having anything
other than a positive impact on Struts.  (The wrapper is also earlier
identified under this key, but that is an error which Niall is
removing.  An earlier stateless wrapping, which is useless (also
DANGEROUS, because if state is ever set prior to RequestUtils many
applications using Struts will be busted), has to be unwrapped several
times even though the wrapping is completely without point to those
stages.)

If a use for the wrapper is found prior to RequestUtils, at this stage
that will break the code of all users that have built their own upload
applications.  The only way to get a handle on the request object
presently is by not implementing ActionForm and getting the request
after it is wrapped but before state is set into the wrapper from the
wrapped request.

The only thing Struts needs from either the wrapper or the handler in
populate is a Properties object full of the parameter names that do
not start with "org.apache.struts" and their values to pass with the
ActionForm object to BeanUtils.popluate();

Consequently, Struts could easily allow anyone to plugin if only the
following minimal requirements were met:

1.  Have the request handler and request wrapper classes set in
struts-config.xml.  These classes can do or be anything they want with
the following single exception.

2.  Require that the handler class have some method like
getStrutsNames() which would return all the parameter names and values
except for those starting with "org.apache.struts".

3.  Make the handler available:
    a.  only through a Globals key, or
    b.  through a method in ActionForm setting an Object, or
    c.  by setting the handler type with reflection from struts-config.xml.

Is this possible?

The sort of application I am trying to use Struts with and which the
preceding would allow, let's us do the following sort of thing:

UploadMonitorProgress listener =
(UploadMonitorProgress)session.getAttribute(UploadConstant.LISTENER);

 if(listener == null)
 {
 listener = new UploadMonitorProgress();
 session.setAttribute(UploadConstant.LISTENER,listener);
 }

 Vector listeners = new Vector();
 listeners.addElement(listener);
 UploadMultipartRequest umr = new UploadMultipartRequest(request,listeners);
 Upload upload = null;

 if((upload = (Upload)session.getAttribute(UploadConstant.UPLOAD)) == null)
 {
 upload = new Upload();
 session.setAttribute(UploadConstant.UPLOAD,upload);
 }

 upload.addUploadMonitor(listener);
 String userStore = LoadFileUtil.getUploadPath(stateUser.getId());
 upload.setStoreToFolder(userStore);
 upload.setParserTempDir(LoadFileUtil.UPLOAD_TEMP_FILES);
 upload.store(umr);
 Vector history = upload.getHistory();
 int historySize = history.size();

 for(int i = 0; i < historySize; i++)
 {
 UploadParams up = (UploadParams)history.elementAt(i);
 String fileName = up.getFileName();
 String fileSize = up.getFileSize();
 String contentType = up.getContentType();
 String storeType = up.getStoreTypeName();
 String sortInfo = up.getStoreInfo();
 }

Jack
-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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