You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Allen, Daniel" <Da...@kbcfp.com> on 2008/03/06 23:56:07 UTC

[s2] IndexedProperties set via forms

Hi, all.

I have a question about using indexed properties. I need to have the
user upload some arbitrary (to be dynamically increased via Javascript
while the user is on the form page) number of files as part of a form. I
figured it makes sense to create an indexed property so that then I have
a List<File> in my action whose elements I can then store as needed. I
can't find anything in the documents about how to get Struts to fill in
indexed properties from forms, though. (Well, plenty of Struts1 results
come up, which is why I assume this is possible, but no Struts2
examples.)

So, the question is: what syntax do I need to use to tell Struts2 that
some form elements will all be part of the same property in the action?
Also, are there any inconsistencies between File upload form elements
and others (aside from the need to have the FileUploadInterceptor on
your stack)?

(I also thought maybe I could just implement RequestAware and then get
them all out of the map, but this seems cleaner if it's possible.)

~Dan Allen



___________________________________
The action which would receive the files:
public class DocumentUploadAction extends MidasAction implements
Validateable {
	
	private List<File> docContents = new ArrayList<File>();
	
	
	public void setDocumentFiles(List<File> files) {
		this.docContents = files;
	}
	public List<File> getDocumentFiles() {
		return this.docContents;
	}

	public String execute() {
		// Do some stuff with the files.
	}
}

-- 
This message may contain confidential, proprietary, or legally privileged information. No confidentiality or privilege is waived by any transmission to an unintended recipient. If you are not an intended recipient, please notify the sender and delete this message immediately. Any views expressed in this message are those of the sender, not those of any entity within the KBC Financial Products group of companies (together referred to as "KBC FP"). 

This message does not create any obligation, contractual or otherwise, on the part of KBC FP. It is not an offer (or solicitation of an offer) of, or a recommendation to buy or sell, any financial product. Any prices or other values included in this message are indicative only, and do not necessarily represent current market prices, prices at which KBC FP would enter into a transaction, or prices at which similar transactions may be carried on KBC FP's own books. The information contained in this message is provided "as is", without representations or warranties, express or implied, of any kind. Past performance is not indicative of future returns.


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


RE: [s2] IndexedProperties set via forms

Posted by "Allen, Daniel" <Da...@kbcfp.com>.
Wow, in the FAQs, even. My Google-fu is miserable.

Thanks/sorry.
~DVA 

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Thursday, March 06, 2008 6:02 PM
To: Struts Users Mailing List
Subject: Re: [s2] IndexedProperties set via forms

--- "Allen, Daniel" <Da...@kbcfp.com> wrote:
> I have a question about using indexed properties. I need to have the
> user upload some arbitrary (to be dynamically increased via Javascript
> while the user is on the form page) number of files as part of a form.
I
> figured it makes sense to create an indexed property so that then I
have
> a List<File> in my action whose elements I can then store as needed. I
> can't find anything in the documents about how to get Struts to fill
in
> indexed properties from forms, though.

http://struts.apache.org/2.x/docs/how-do-we-upload-files.html should
cover
what you're asking here, I believe.

Dave



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


-- 
This message may contain confidential, proprietary, or legally privileged information. No confidentiality or privilege is waived by any transmission to an unintended recipient. If you are not an intended recipient, please notify the sender and delete this message immediately. Any views expressed in this message are those of the sender, not those of any entity within the KBC Financial Products group of companies (together referred to as "KBC FP"). 

This message does not create any obligation, contractual or otherwise, on the part of KBC FP. It is not an offer (or solicitation of an offer) of, or a recommendation to buy or sell, any financial product. Any prices or other values included in this message are indicative only, and do not necessarily represent current market prices, prices at which KBC FP would enter into a transaction, or prices at which similar transactions may be carried on KBC FP's own books. The information contained in this message is provided "as is", without representations or warranties, express or implied, of any kind. Past performance is not indicative of future returns.


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


Re: [s2] IndexedProperties set via forms

Posted by Dave Newton <ne...@yahoo.com>.
--- "Allen, Daniel" <Da...@kbcfp.com> wrote:
> I have a question about using indexed properties. I need to have the
> user upload some arbitrary (to be dynamically increased via Javascript
> while the user is on the form page) number of files as part of a form. I
> figured it makes sense to create an indexed property so that then I have
> a List<File> in my action whose elements I can then store as needed. I
> can't find anything in the documents about how to get Struts to fill in
> indexed properties from forms, though.

http://struts.apache.org/2.x/docs/how-do-we-upload-files.html should cover
what you're asking here, I believe.

Dave



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