Re: Huge File upload in struts 2

2009-06-04 Thread Johnson nickel

 Hi,
 
I have problem with this readInputStream method. I have checked in
(postgresql)database, which i
used column data type is bytea its default column size 1gb data. I will
explain my problem clearly,


Step1 :
  I checked in java file itself,

 public static void main(String args[])
{
byte[] filedata = readInputStream(new FileInputStream("test.pdf"));
// byte filedata = null
  // DB code to store binary data

}
 


If, i run the code, it shows outofmemory error java heap size.


 

  

 /** Read an input stream in its entirety into a byte array */
 public static byte[] readInputStream(InputStream inputStream) throws
 IOException {
 int bufSize = 1024 * 1024;
 byte[] content;

 List parts = new LinkedList();
 InputStream in = new BufferedInputStream(inputStream);

 byte[] readBuffer = new byte[bufSize];
 byte[] part = null;
 int bytesRead = 0;

 // read everyting into a list of byte arrays
 while ((bytesRead = in.read(readBuffer, 0, bufSize)) != -1) {
 part = new byte[bytesRead];
 System.arraycopy(readBuffer, 0, part, 0, bytesRead);
 parts.add(part);
 }

 // calculate the total size
 int totalSize = 0;
 for (byte[] partBuffer : parts) {
 totalSize += partBuffer.length;
 }

 // allocate the array
 content = new byte[totalSize];
 int offset = 0;
 for (byte[] partBuffer : parts) {
 System.arraycopy(partBuffer, 0, content, offset,
 partBuffer.length);
 offset += partBuffer.length;
 }

 return content;
 } 



-- 
View this message in context: 
http://www.nabble.com/Huge-File-upload-in-struts-2-tp23870472p23881060.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Huge File upload in struts 2

2009-06-04 Thread Dave Newton

Martin Gainty wrote:

if your OS and container supports sendfile you may want to enable sendfile for 
static files


Isn't that for sending data to the client? IIRC they were talking about 
uploads.


Dave

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



Re: Params not getting set

2009-06-04 Thread Dave Newton

Jim Collings wrote:

Hmmm, so it seems from testing that I've been doing that the constant
is mandatory in all cases where you want params set before Prepare is
called while using paramsPrepareParamsStack AND you are using the
Convention plugin.  K, got it. I think this also might explain why I
couldn't get the interceptor I was trying to write earlier to work.


Yes, it is--if you don't define the package the Convention-based actions 
are in via a @ParentPackage then without telling S2 otherwise it'll just 
put them in the Convention default package.


Dave

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



Re: HTML warnings for in xhtml theme

2009-06-04 Thread Dave Newton

Security Management wrote:

Using forms in the xhtml theme creates a 2 column table for *most* items.
The hidden item is not one of them, and gives html warnings for 
being inside of  instead of inside of a .

It's an easy fix by putting the following hidden.ftl in the xhtml theme
directory.  Is there any reason not to do this?

== Start hidden.ftl==


<#include "/${parameters.templateDir}/simple/hidden.ftl" />
<#include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" />
/>

== End hidden.ftl ==


Hey, that's funny; I just noticed that yesterday.

Dave

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



RE: (PROBLEM SOLVED) WAS 6.1: There is no Action mapped for namespace / and action name j_security_check

2009-06-04 Thread Struts Two

I had a PMR open with IBM and L3 support pointed me to the right direction by 
sifting through the logs.

--- On Fri, 6/5/09, Martin Gainty  wrote:

> From: Martin Gainty 
> Subject: RE: (PROBLEM SOLVED) WAS 6.1: There is no Action mapped for 
> namespace / and action name j_security_check
> To: "Struts Users Mailing List" 
> Received: Friday, June 5, 2009, 12:47 AM
> 
> Did you get a chance to contact IBM to apprise them of this
> solution?
> 
> Félicitations sur ce travail le plus excellent
> 
> !
> 
> Martin 
> __ 
> Note de déni et de confidentialité
> Ce message est confidentiel et peut être privilégié. Si
> vous n'êtes pas le destinataire prévu, nous te demandons
> avec bonté que pour satisfaire informez l'expéditeur.
> N'importe quelle diffusion non autorisée ou la copie de
> ceci est interdite. Ce message sert à l'information
> seulement et n'aura pas n'importe quel effet légalement
> obligatoire. Étant donné que les email peuvent facilement
> être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
> 
> 
> 
> 
> > Date: Thu, 4 Jun 2009 17:15:06 -0700
> > From: struts...@yahoo.ca
> > Subject: Re: (PROBLEM SOLVED) WAS 6.1: There is no
> Action mapped for namespace / and action name
> j_security_check
> > To: user@struts.apache.org
> > 
> > 
> > Finally, the problem with form based authentication
> got resovled. However; here is a summary of what happens
> that we get the error:
> > 
> > There is no Action mapped for namespace / and
> actionName j_security_check
> > 
> > With form-based authentication, Websphere
> authenticates a user by using URI
> //j_security_check.
> > 
> > Due to the fact that in struts 2.1 default action
> extension list (struts.action.extension) has changed from
> just 'action' to 'action' plus " , j_security_check is
> mistaken as an struts action.
> > 
> > Line:
> > 
> > config =
> configuration.getRuntimeConfiguration().getActionConfig(namespace,
> actionName);
> > 
> > in class com.opensymphony.xwork2.DefaultActionProxy
> located in method prepare() returns null for actionName
> j_security_check" and consquently
> > "no mapping error" is displayed.
> > 
> > Solution:
> > 
> > as described in migration guide in the following link
> [which makes it clear why everything in struts 2.0 works but
> not struts 2.1]:
> > 
> > http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html
> > 
> > Add the following to your struts.xml
> > 
> >  value="action" />
> > 
> > and then in your web.xml, change:
> > 
> >     
> >     
>    struts2
> >     
>    /*
> >  
> 
> >     
> >     TO 
> > 
> >     
> >     
>    struts2
> >     
>    *.action
> > 
>   
> > 
> > The form based authentication works just like basic
> authentication. You still need to have the following
> properties set:
> > 
> >
> com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror =
> true
> > com.ibm.ws.webcontainer.invokefilterscompatibility =
> true
> > 
> > 
> > 
> > 
> >   
>    __
> > Reclaim your name @ymail.com or @rocketmail.com. Get
> your new email address now! Go to http://ca.promos.yahoo.com/jacko/
> > 
> >
> -
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> > 
> 
> _
> Hotmail® has ever-growing storage! Don’t worry about
> storage limits. 
> http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009


  __
The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Yahoo!  
Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/

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



RE: (PROBLEM SOLVED) WAS 6.1: There is no Action mapped for namespace / and action name j_security_check

2009-06-04 Thread Martin Gainty

Did you get a chance to contact IBM to apprise them of this solution?

Félicitations sur ce travail le plus excellent

!

Martin 
__ 
Note de déni et de confidentialité
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




> Date: Thu, 4 Jun 2009 17:15:06 -0700
> From: struts...@yahoo.ca
> Subject: Re: (PROBLEM SOLVED) WAS 6.1: There is no Action mapped for 
> namespace / and action name j_security_check
> To: user@struts.apache.org
> 
> 
> Finally, the problem with form based authentication got resovled. However; 
> here is a summary of what happens that we get the error:
> 
> There is no Action mapped for namespace / and actionName j_security_check
> 
> With form-based authentication, Websphere authenticates a user by using URI 
> //j_security_check.
> 
> Due to the fact that in struts 2.1 default action extension list 
> (struts.action.extension) has changed from just 'action' to 'action' plus " , 
> j_security_check is mistaken as an struts action.
> 
> Line:
> 
> config = configuration.getRuntimeConfiguration().getActionConfig(namespace, 
> actionName);
> 
> in class com.opensymphony.xwork2.DefaultActionProxy located in method 
> prepare() returns null for actionName j_security_check" and consquently
> "no mapping error" is displayed.
> 
> Solution:
> 
> as described in migration guide in the following link [which makes it clear 
> why everything in struts 2.0 works but not struts 2.1]:
> 
> http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html
> 
> Add the following to your struts.xml
> 
> 
> 
> and then in your web.xml, change:
> 
> 
> struts2
> /*
>   
> 
> TO 
> 
> 
> struts2
> *.action
>
> 
> The form based authentication works just like basic authentication. You still 
> need to have the following properties set:
> 
> com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror = true
> com.ibm.ws.webcontainer.invokefilterscompatibility = true
> 
> 
> 
> 
>   __
> Reclaim your name @ymail.com or @rocketmail.com. Get your new email address 
> now! Go to http://ca.promos.yahoo.com/jacko/
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 

_
Hotmail® has ever-growing storage! Don’t worry about storage limits. 
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009

Re: (PROBLEM SOLVED) WAS 6.1: There is no Action mapped for namespace / and action name j_security_check

2009-06-04 Thread Struts Two

Finally, the problem with form based authentication got resovled. However; here 
is a summary of what happens that we get the error:

There is no Action mapped for namespace / and actionName j_security_check

With form-based authentication, Websphere authenticates a user by using URI 
//j_security_check.

Due to the fact that in struts 2.1 default action extension list 
(struts.action.extension) has changed from just 'action' to 'action' plus " , 
j_security_check is mistaken as an struts action.

Line:

config = configuration.getRuntimeConfiguration().getActionConfig(namespace, 
actionName);

in class com.opensymphony.xwork2.DefaultActionProxy located in method prepare() 
returns null for actionName j_security_check" and consquently
"no mapping error" is displayed.

Solution:

as described in migration guide in the following link [which makes it clear why 
everything in struts 2.0 works but not struts 2.1]:

http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html

Add the following to your struts.xml



and then in your web.xml, change:


struts2
/*
  

TO 


struts2
*.action
   

The form based authentication works just like basic authentication. You still 
need to have the following properties set:

com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror = true
com.ibm.ws.webcontainer.invokefilterscompatibility = true




  __
Reclaim your name @ymail.com or @rocketmail.com. Get your new email address 
now! Go to http://ca.promos.yahoo.com/jacko/

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



RE: Huge File upload in struts 2

2009-06-04 Thread Martin Gainty

http://spdn.ifas.ufl.edu/docs/config/http.html


(int)The socket receive buffer (SO_RCVBUF) size in bytes. Default value 
is 25188
socket.bufferPoolSize
(int)The NioChannel pool can also be size based, not used object based. 
The size is calculated as follows:

NioChannel buffer size = read buffer size + write buffer size

SecureNioChannel buffer
size = application read buffer size + application write buffer size +
network read buffer size + network write buffer size

The value is in bytes, the default value is 1024*1024*100 (100MB)

here is an example from $CATALINA_HOME/conf/server.xml

   
if your OS and container supports sendfile you may want to enable sendfile for 
static files

HTH
Martin Gainty 
__ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




> Date: Thu, 4 Jun 2009 15:05:28 -0400
> Subject: Re: Huge File upload in struts 2
> From: greg.lindh...@gmail.com
> To: user@struts.apache.org
> 
> I'm not having any problem with 20mb files using Struts 2.1.6 and the
> standard fileUpload interceptor.
> From what I see, Sir Evans is warning you that loading the entire file into
> memory may be a problem if your files are very large.  Nowadays 10mb is not
> really that large.  If you want to put 10mb pictures into a database as a
> byte array then you really don't have much choice but to load them into
> memory.
> 
> Now if you were actually talking about really HUGH files like hundreds of mb
> or multiple gb files (just like Evans said) that is larger then your memory
> then you will need take a different approach such as splitting the file or
> not putting it into the database, instead just store a reference to the
> file.
> 
> Have you tried this solution? Have you confirmed you actually have a
> problem?
> 
> On Thu, Jun 4, 2009 at 9:58 AM, Johnson nickel wrote:
> 
> >
> >
> >
> > Hi Evans,
> >
> > I'm facing problem to upload huge file like (size is
> > 7mb,10mb). In your last thread
> > you have specified it will work in only small datas or files. I want to
> > know
> > any other method
> > to solve in struts2 framework.
> >
> >
> > Disclaimer: This approach is limited to small files (multiple megabytes
> > > rather than hundreds/gigs) because of the inefficient memory
> > > consumption.  It's also quite slow as the commons fileuploader first
> > > receives all the data, then writes the entire temporary file, then it's
> > > read again entirely  into memory, then written back to your
> > > database/filesystem.  There's no other built-in approach in Struts2 but
> > > you'll find ajax fileuploaders on the web that handle massive files
> > > better than this.
> >
> > Jeromy Evans - Blue Sky Minds wrote:
> > >
> > >
> > >
> > > Johnson nickel wrote:
> > >> Hi Jeromy Evans,
> > >>
> > >>   Thanks for your reply. I would like to insert the images
> > >> into
> > >> my
> > >>   Databases. For that, i'm using byte[] array.
> > >>   In Struts 1.3,
> > >>  I used FormFile class. From this class i got the method
> > >> getFileData();
> > >>
> > >> In my db, ps.setBytes(1,filedata); // to store the
> > binary
> > >> datas in DB.
> > >>
> > >> /*FormFile mtfile = form.getTheFile();
> > >>  byte[] filedata = mtfile.getFileData();*/
> > >>
> > >>
> > >>
> > > Ahh, ok.
> > >
> > > In Struts2, the file is a reference to a temporary file created on your
> > > server.  If it's not HUGE, just read it into a byte array.
> > > The code follows.  This code is a fairly standard approach to read an
> > > arbitrary length inputstream into a byte array one chunk at a time.
> > > If the file can be HUGE, see my comment at bottom.
> > >
> > > byte[] filedata = readInputStream(new FileInputStream(upload));
> > >
> > > /** Read an input stream in its entirety into a byte array */
> > > public static byte[] readInputStream(InputStream inputStream) throws
> > > IOException {
> > > int bufSize = 1024 * 1024;
> > >

RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml

2009-06-04 Thread Mitchell, Steven
UDPATE: WebSphere 6.1.0.23 did indeed fix our basic auth issue with
Struts 2.1.6.  It now successfully challenges the user if the try to
access a protected Struts action.

It did not fix the welcome file issue (using
index.html).  I think I will retest Wes's
suggestion to use index.action with a corresponding zero byte file.

Steve Mitchell
http://www.ByteworksInc.com

-Original Message-
From: Struts Two [mailto:struts...@yahoo.ca] 
Sent: Thursday, June 04, 2009 12:55 PM
To: Struts Users Mailing List
Subject: RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in
web.xml


This is weird, as basic authentication works for me and I have got no
problem with it.

Anyways,Earlier today, I sent my Struts enterprise file to WAS Level 3
support for testing [form based authentication] and I will keep you
posted as soon as I hear sth.




  __
Ask a question on any topic and get answers from real people. Go to
Yahoo! Answers and share what you know at http://ca.answers.yahoo.com

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


--
NOTICE:  This electronic mail message and any attached files are confidential.  
The information is exclusively for the use of the individual or entity intended 
as the recipient.  If you are not the intended recipient, any use, copying, 
printing, reviewing, retention, disclosure, distribution or forwarding of the 
message or any attached file is not authorized and is strictly prohibited.  If 
you have received this electronic mail message in error, please advise the 
sender by reply electronic mail immediately and permanently delete the original 
transmission, any attachments and any copies of this message from your computer 
system. Thank you.

==


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



Re: Params not getting set

2009-06-04 Thread Jim Collings
> The configuration constant I pointed to still isn't in there.
>
> In the default stack, the params interceptor does not run before the
> prepare interceptor. For instances where you need the params set
> first, then the prepare interceptor fires afterwards, we created the
> paramsPrepareParamsStack. Now, you have the paramsPrepareParamsStack
> set as the default stack for the "something" package, but my point is
> that if you are using conventions, your actions are probably not a
> part of the "something" package. They are a part of the
> "conventions-default" package. You can move all of the actions in your
> app into the "something" package with the configuration constant I
> have pasted above, or you can move a single action into the
> "something" package using the @ParentPackage annotation (reference in
> the link I sent earlier).
>
> -Wes

Hmmm, so it seems from testing that I've been doing that the constant
is mandatory in all cases where you want params set before Prepare is
called while using paramsPrepareParamsStack AND you are using the
Convention plugin.  K, got it. I think this also might explain why I
couldn't get the interceptor I was trying to write earlier to work.


Jim C.

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



RE: Doubts about new project (Struts2 good way to do it?)

2009-06-04 Thread Martin Gainty

Good Afternoon Francisco
i have an opinion on the subject which i would be more than happy to share with 
you

> 1) User preferences: every user can configure its "window" and
maintain its configuration after save preferences and log in again. The
user can select options from a list and position them where he wants.
¿Maybe using portlets?¿Changing css dinamically depending on logged
user?¿Any other option?
MG>JetSpeed..tried and true Principal assignment to User,Group
http://portals.apache.org/jetspeed-2/

> 2) Languages: every user can
access in some languages. As I've tested, the language is configured
with regional settings. But it is possible to select the language in
the login page and maintain it during the session?
MG>simple as setting request_locate to en requst_locale=es
MG>http://struts.apache.org/2.1.6/docs/how-do-we-change-locales.html
> 
> 3) Persistence layer: better Hibernate or iBatis? About performance?
MG>I think hibernate has more deploys be aware of lazy_init not creating all 
dependent objects in object graph
https://www.hibernate.org/162.html
> 
> 4) E-commerce: shop cart, what about security?
MG>SSL all the way..dont send cleartext for anything unless you want mailicious 
eavesdropper intervention!
http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html
MG>i can give you SSL solutions for OAS, WL, Resin, JBOSS if you need it
> 
> 5) Sitemesh or Tiles? I've used tiles and it is ok, but the xml are too long. 
> About performance?
MG>Sitemesh is the css handler that is preconfigured for Struts

sitemesh

com.opensymphony.module.sitemesh.filter.PageFilter


sitemesh
/*


MG>if you like using VM macros coded thru SiteMesh then enable 
VelocityPageFilter in web.xml

sitemesh

org.apache.struts2.sitemesh.VelocityPageFilter


sitemesh
/*


and for freemarker

sitemesh

org.apache.struts2.sitemesh.FreeMarkerPageFilter



sitemesh

/*




Saludos Cordiales desde EEUU!
Martin
GMT+5(esta semana)
> 
> 
> 
> The options I've considered are:
> 
> Tomcat, MySQL, Struts2 with Spring IOC and open in view filter, Sitemesh or 
> Tiles, Hibernate or iBatis, Portlets. 
> 
> Other option is use JSF. Which selection do you think would be better?
> 


Martin Gainty 
__ 
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und 
Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Ez az
üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




> From: fcoexpos...@hotmail.com
> To: user@struts.apache.org
> Subject: Doubts about new project (Struts2 good way to do it?)
> Date: Thu, 4 Jun 2009 15:45:09 +
> 
> 
> Hello,
> 
> I want to create a portal with this functionalities, and I don't know if it 
> is possible to do it using Struts2 or what is better for it:
> 
> 1) User preferences: every user can configure its "window" and maintain its 
> configuration after save preferences and log in again. The user can select 
> options from a list and position them where he wants. ¿Maybe using 
> portlets?¿Changing css dinamically depending on logged user?¿Any other option?
> 
> 2) Languages: every user can access in some languages. As I've tested, the 
> language is configured with regional settings. But it is possible to select 
> the language in the login page and maintain it during the session?
> 
> 3) Persistence layer: better Hibernate or iBatis? About performance?
> 
> 4) E-commerce: shop cart, what about security?
> 
> 5) Sitemesh or Tiles? I've used tiles and it is ok, but the xml are too long. 
> About performance?
> 
> 
> 
> The options I've consider

Re: Formatting output, double without exponent

2009-06-04 Thread Greg Lindholm
You need to format the number how you would like it.
If you have a fixed format and don't have to worry about
internationalization then you could just add another method to your class
that returns it formatted the way you like i.e. getCurrentMoneyFormatted().

However if you need to internationalize your app and you want it formatted
correctly based on the Locale of the user then you can use a resource file
with formatting info.

MyResource:
my.money={0,number,currency}


   


See http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html for
info on the {0,number,currency} message format.

To make this stuff easier I would implement a formatCurrency() method in
your base action class so you could write like this:




On Thu, Jun 4, 2009 at 11:39 AM, Stefano Tranquillini <
stefano.tranquill...@gmail.com> wrote:

> Hi all.
> i've a little problem.
> I've a EJB inside my session, i take it from a jsp and print out some
> values:
> 
>
> now, this value is a double. and struts print 2.0E09
> how can i print 2.0. so the entire number without exponent?
> thanks
>
>
> --
> Stefano
>


Re: Huge File upload in struts 2

2009-06-04 Thread Greg Lindholm
I'm not having any problem with 20mb files using Struts 2.1.6 and the
standard fileUpload interceptor.
>From what I see, Sir Evans is warning you that loading the entire file into
memory may be a problem if your files are very large.  Nowadays 10mb is not
really that large.  If you want to put 10mb pictures into a database as a
byte array then you really don't have much choice but to load them into
memory.

Now if you were actually talking about really HUGH files like hundreds of mb
or multiple gb files (just like Evans said) that is larger then your memory
then you will need take a different approach such as splitting the file or
not putting it into the database, instead just store a reference to the
file.

Have you tried this solution? Have you confirmed you actually have a
problem?

On Thu, Jun 4, 2009 at 9:58 AM, Johnson nickel wrote:

>
>
>
> Hi Evans,
>
> I'm facing problem to upload huge file like (size is
> 7mb,10mb). In your last thread
> you have specified it will work in only small datas or files. I want to
> know
> any other method
> to solve in struts2 framework.
>
>
> Disclaimer: This approach is limited to small files (multiple megabytes
> > rather than hundreds/gigs) because of the inefficient memory
> > consumption.  It's also quite slow as the commons fileuploader first
> > receives all the data, then writes the entire temporary file, then it's
> > read again entirely  into memory, then written back to your
> > database/filesystem.  There's no other built-in approach in Struts2 but
> > you'll find ajax fileuploaders on the web that handle massive files
> > better than this.
>
> Jeromy Evans - Blue Sky Minds wrote:
> >
> >
> >
> > Johnson nickel wrote:
> >> Hi Jeromy Evans,
> >>
> >>   Thanks for your reply. I would like to insert the images
> >> into
> >> my
> >>   Databases. For that, i'm using byte[] array.
> >>   In Struts 1.3,
> >>  I used FormFile class. From this class i got the method
> >> getFileData();
> >>
> >> In my db, ps.setBytes(1,filedata); // to store the
> binary
> >> datas in DB.
> >>
> >> /*FormFile mtfile = form.getTheFile();
> >>  byte[] filedata = mtfile.getFileData();*/
> >>
> >>
> >>
> > Ahh, ok.
> >
> > In Struts2, the file is a reference to a temporary file created on your
> > server.  If it's not HUGE, just read it into a byte array.
> > The code follows.  This code is a fairly standard approach to read an
> > arbitrary length inputstream into a byte array one chunk at a time.
> > If the file can be HUGE, see my comment at bottom.
> >
> > byte[] filedata = readInputStream(new FileInputStream(upload));
> >
> > /** Read an input stream in its entirety into a byte array */
> > public static byte[] readInputStream(InputStream inputStream) throws
> > IOException {
> > int bufSize = 1024 * 1024;
> > byte[] content;
> >
> > List parts = new LinkedList();
> > InputStream in = new BufferedInputStream(inputStream);
> >
> > byte[] readBuffer = new byte[bufSize];
> > byte[] part = null;
> > int bytesRead = 0;
> >
> > // read everyting into a list of byte arrays
> > while ((bytesRead = in.read(readBuffer, 0, bufSize)) != -1) {
> > part = new byte[bytesRead];
> > System.arraycopy(readBuffer, 0, part, 0, bytesRead);
> > parts.add(part);
> > }
> >
> > // calculate the total size
> > int totalSize = 0;
> > for (byte[] partBuffer : parts) {
> > totalSize += partBuffer.length;
> > }
> >
> > // allocate the array
> > content = new byte[totalSize];
> > int offset = 0;
> > for (byte[] partBuffer : parts) {
> > System.arraycopy(partBuffer, 0, content, offset,
> > partBuffer.length);
> > offset += partBuffer.length;
> > }
> >
> > return content;
> > }
> >
> > Disclaimer: This approach is limited to small files (multiple megabytes
> > rather than hundreds/gigs) because of the inefficient memory
> > consumption.  It's also quite slow as the commons fileuploader first
> > receives all the data, then writes the entire temporary file, then it's
> > read again entirely  into memory, then written back to your
> > database/filesystem.  There's no other built-in approach in Struts2 but
> > you'll find ajax fileuploaders on the web that handle massive files
> > better than this.
> >
> > regards,
> >  Jeromy Evans
> >
> >
> >
> > -
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> >
> >
> >
> Quoted from:
>
> http://www.nabble.com/Struts-2-File-upload-to-store-the-filedata-tp14168069p14169822.html
>
>
> --
> View this message in context:
> http://www.nabble.com/Huge-File-upload-in-struts-2-tp23870472p23870472.html
> Sent from the Struts 

Re: Return to previous page without javascript

2009-06-04 Thread Paweł Wielgus
Hi Stefano,
add some kind of information about the page loging form is on, inside
the login form, then in login action resolve where to come back. It
can be also achieved by remebering the last request uri and params if
any. But there is no standard solution for this problem, as far as i
know. You can always face a scenario where user login without any
page, just by constructing a valid url.

Best greetings,
Pawel Wielgus.

2009/6/4, Stefano Tranquillini :
> Hi all.
> i want to do a thing. When a user do the login (i've the login in the left
> part of the web site, so in each pages the user can do the login) i want to
> redirect he at the pages that was visit before the login.
> how can i do that? (no JS)
>
>
> --
> Stefano
>

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



RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml

2009-06-04 Thread Struts Two

This is weird, as basic authentication works for me and I have got no problem 
with it.

Anyways,Earlier today, I sent my Struts enterprise file to WAS Level 3 support 
for testing [form based authentication] and I will keep you posted as soon as I 
hear sth.




  __
Ask a question on any topic and get answers from real people. Go to Yahoo! 
Answers and share what you know at http://ca.answers.yahoo.com

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



Re: Params not getting set

2009-06-04 Thread Wes Wannemacher
On Thu, Jun 4, 2009 at 12:47 PM, Jim Collings  wrote:
[...]
>>
>> > />
>>
[...]
> OK, well it should have been:
>
> 
>    
>    
>    
>     value="com.stuff.something.web"/>
>    
>        
> 
>
> In any case, it is not this type of mapping problem because the
> Prepare method is getting called just fine. The parameters are passed
> in a link though and the property that the Prepare method requires is
> not being set. I can't find any reason why it wouldn't be but tracing
> through shows that params is not being called before Prepare.
>
>

The configuration constant I pointed to still isn't in there.

In the default stack, the params interceptor does not run before the
prepare interceptor. For instances where you need the params set
first, then the prepare interceptor fires afterwards, we created the
paramsPrepareParamsStack. Now, you have the paramsPrepareParamsStack
set as the default stack for the "something" package, but my point is
that if you are using conventions, your actions are probably not a
part of the "something" package. They are a part of the
"conventions-default" package. You can move all of the actions in your
app into the "something" package with the configuration constant I
have pasted above, or you can move a single action into the
"something" package using the @ParentPackage annotation (reference in
the link I sent earlier).

-Wes


-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

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



RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml

2009-06-04 Thread Mitchell, Steven
Wes,

Go ahead, stir the pot!!! WAS 6.1 is a total cluster. I would love to drop kick 
it out of here.

By the way, my security problem really wasn't fixed.  Here is how I fixed.

I gave the team the green light to start testing on DEV and they all said they 
were getting 404 errors.  I showed them that I was testing the application from 
my box, but as soon as I closed my browser and tried again I too got the 404 
error.

The basic auth session must live on cached in the header. I got signed in 
because I created that test file under a directory mirroring my action 
namespace. Once I saw security was working I removed it, and some other test 
files, and redeployed the application.

In the end, the only way I could get Basic Auth to work running Struts 2.1.6 on 
WAS 6.1.0.19 was by putting a physical file in protected resource path: 
http://myServer/myContext/mySecurePath/index.html.  The file does a redirect to 
the desired protected struts 2 action.  When you hit that HTML file it causes 
WebSphere to do the Basic Auth challenge, after which the user gets redirected 
to Strtus 2 and life is good.

The WAS Admin is downloading 6.1.0.23.  Perhaps it will work better.

Steve Mitchell
http://www.ByteworksInc.com

-Original Message-
From: Wes Wannemacher [mailto:w...@wantii.com] 
Sent: Thursday, June 04, 2009 11:39 AM
To: Struts Users Mailing List
Subject: Re: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml

For the record, we have requested licenses for WebSphere because there
have been more than a few problems. I know Martin Cooper worked hard
to get us access to different versions of WebSphere in a way that kept
apache, us developers and struts safe while keeping IBM happy. I don't
think we were ever told "no," but the process has been very slow.

//not really trying to stir the pot (well, maybe a little)

-Wes

On Thu, Jun 4, 2009 at 12:11 PM, Mitchell, Steven
 wrote:
> Half of this problem has been solved--the important half.  During testing I 
> disabled security to verify that all of the Struts2 mappings worked, which 
> they did.  When my war was deployed to WebSphere by our auto-deploy script it 
> caused the LDAP role mappings to be dropped, which is the reason why security 
> did not once I re-enabled it.
>
> The problem with the welcome file persists.  As a test, I commented out the 
> Struts 2 filers.  I created a directory matching a secured Struts 2 
> namespace, and added a HTML file matching the welcome-file in the web.xml 
> file.  When I hit the base URL of the protected Strtus2 namespace, 
> http://myServer/myContext/mySecuredNameSpace/, with the Struts 2 filter 
> disabled Basic auth was triggered and WebSphere successfully returned the 
> index.html file in the root of that directory.  When I re-enabled the Struts 
> 2 filters the welcome-file quit working again.
>
> I would still like to understand why the welcome-file doesn't work on 
> WebSphere 6.1 with Struts 2, but it is not a show stopper.  We will simply 
> provide the users a deep link directly to the desired, secured action.
>
> Steve Mitchell
> http://www.ByteworksInc.com
>
> -Original Message-
> From: Mitchell, Steven
> Sent: Wednesday, June 03, 2009 4:48 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml
>
> Wes,
>
> That was an interesting exercise.  I changed my welcome-file to be 
> "index.action", added the zero-byte file "/webapp/index.action", and defined 
> the following action:
>
> 
>    /index.html
> 
>
> This worked the same on Tomcat 5.5 as it did when my welcome-file was just 
> "index.html."  Unfortunately, on WebSphere I still got the message: "Error 
> 404: There is no Action mapped for namespace / and action name index ." Of 
> course, if I type http://myserver/mycontext/index.action in the browser that 
> works fine.  Something is seriously hosed on WAS 6.1.
>
> I've asked the WAS Admin to bump us up to 6.1.0.23 and I'll continue testing 
> tomorrow.
>
> Thank you for your suggestion.
>
> Steve Mitchell
> http://www.ByteworksInc.com
>
> -Original Message-
> From: Mitchell, Steven [mailto:steven.mitch...@umb.com]
> Sent: Wednesday, June 03, 2009 4:18 PM
> To: Struts Users Mailing List
> Subject: RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml
>
> Wes,
>
> Boy do I wish the client would just use Tomcat! I'll try going down the 
> action route.  I'm actually using index.html now, which is a real file that I 
> can access if I type the whole URL: http://myserver/mycontext/index.html.  If 
> I understand what you are asking me to try, I will create a zero byte 
> /webapp/index.action, change my Web.xml from:
>
> 
>    index.html
> 
>
> to:
>
> 
>    index.action
> 
>
> and add an action named "index".  Is that correct?  Actually, my index.html 
> redirects to /mynamespace/myaction.action.  If I just used that I would need 
> to create a directory named /mynamespace with a zero byte file called 
>

Re: Params not getting set

2009-06-04 Thread Jim Collings
> I'm assuming you are using the conventions plugin (since there is no
> action definition). How are you making sure your
> conventions-configured actions are in the "stuff" package? If this is
> your configuration, in whole, then you need to add -
>
> 
>
> Just matching up namespace is not enough.
>
> Another option is to use the @ParentPackage annotation on the action class -
> http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-ParentPackageannotation
>
> -Wes

OK, well it should have been:










In any case, it is not this type of mapping problem because the
Prepare method is getting called just fine. The parameters are passed
in a link though and the property that the Prepare method requires is
not being set. I can't find any reason why it wouldn't be but tracing
through shows that params is not being called before Prepare.


Jim C.

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



Re: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml

2009-06-04 Thread Wes Wannemacher
For the record, we have requested licenses for WebSphere because there
have been more than a few problems. I know Martin Cooper worked hard
to get us access to different versions of WebSphere in a way that kept
apache, us developers and struts safe while keeping IBM happy. I don't
think we were ever told "no," but the process has been very slow.

//not really trying to stir the pot (well, maybe a little)

-Wes

On Thu, Jun 4, 2009 at 12:11 PM, Mitchell, Steven
 wrote:
> Half of this problem has been solved--the important half.  During testing I 
> disabled security to verify that all of the Struts2 mappings worked, which 
> they did.  When my war was deployed to WebSphere by our auto-deploy script it 
> caused the LDAP role mappings to be dropped, which is the reason why security 
> did not once I re-enabled it.
>
> The problem with the welcome file persists.  As a test, I commented out the 
> Struts 2 filers.  I created a directory matching a secured Struts 2 
> namespace, and added a HTML file matching the welcome-file in the web.xml 
> file.  When I hit the base URL of the protected Strtus2 namespace, 
> http://myServer/myContext/mySecuredNameSpace/, with the Struts 2 filter 
> disabled Basic auth was triggered and WebSphere successfully returned the 
> index.html file in the root of that directory.  When I re-enabled the Struts 
> 2 filters the welcome-file quit working again.
>
> I would still like to understand why the welcome-file doesn't work on 
> WebSphere 6.1 with Struts 2, but it is not a show stopper.  We will simply 
> provide the users a deep link directly to the desired, secured action.
>
> Steve Mitchell
> http://www.ByteworksInc.com
>
> -Original Message-
> From: Mitchell, Steven
> Sent: Wednesday, June 03, 2009 4:48 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml
>
> Wes,
>
> That was an interesting exercise.  I changed my welcome-file to be 
> "index.action", added the zero-byte file "/webapp/index.action", and defined 
> the following action:
>
> 
>    /index.html
> 
>
> This worked the same on Tomcat 5.5 as it did when my welcome-file was just 
> "index.html."  Unfortunately, on WebSphere I still got the message: "Error 
> 404: There is no Action mapped for namespace / and action name index ." Of 
> course, if I type http://myserver/mycontext/index.action in the browser that 
> works fine.  Something is seriously hosed on WAS 6.1.
>
> I've asked the WAS Admin to bump us up to 6.1.0.23 and I'll continue testing 
> tomorrow.
>
> Thank you for your suggestion.
>
> Steve Mitchell
> http://www.ByteworksInc.com
>
> -Original Message-
> From: Mitchell, Steven [mailto:steven.mitch...@umb.com]
> Sent: Wednesday, June 03, 2009 4:18 PM
> To: Struts Users Mailing List
> Subject: RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml
>
> Wes,
>
> Boy do I wish the client would just use Tomcat! I'll try going down the 
> action route.  I'm actually using index.html now, which is a real file that I 
> can access if I type the whole URL: http://myserver/mycontext/index.html.  If 
> I understand what you are asking me to try, I will create a zero byte 
> /webapp/index.action, change my Web.xml from:
>
> 
>    index.html
> 
>
> to:
>
> 
>    index.action
> 
>
> and add an action named "index".  Is that correct?  Actually, my index.html 
> redirects to /mynamespace/myaction.action.  If I just used that I would need 
> to create a directory named /mynamespace with a zero byte file called 
> myaction.action.  Is that correct?
>
> Steve Mitchell
> http://www.ByteworksInc.com
>
> -Original Message-
> From: Wes Wannemacher [mailto:w...@wantii.com]
> Sent: Wednesday, June 03, 2009 4:00 PM
> To: Struts Users Mailing List
> Subject: Re: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml
>
> On Wed, Jun 3, 2009 at 4:54 PM, Mitchell, Steven
>  wrote:
> [...]
>>
>>     Error 404: SRVE0190E: File not found: /secure/MySecureAction.action
> [...]
>
> I don't know about all of the problems, but one thing that might help
> you understand this a little bit... This 404 might not be WAS' fault.
> In the Spec (can't remember if it was 2.3 / 2.4) it was specified that
> a file had to exist on the file system for it to be usable as a
> welcome-file. This is sort of a pain for Struts2. One quick hack that
> worked in Tomcat is to just create a zero-byte file called
> index.action. I can't guarantee that WAS will be happy with that, but
> I have used that before.
>
> -Wes
>
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
> --

RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml

2009-06-04 Thread Mitchell, Steven
Half of this problem has been solved--the important half.  During testing I 
disabled security to verify that all of the Struts2 mappings worked, which they 
did.  When my war was deployed to WebSphere by our auto-deploy script it caused 
the LDAP role mappings to be dropped, which is the reason why security did not 
once I re-enabled it.

The problem with the welcome file persists.  As a test, I commented out the 
Struts 2 filers.  I created a directory matching a secured Struts 2 namespace, 
and added a HTML file matching the welcome-file in the web.xml file.  When I 
hit the base URL of the protected Strtus2 namespace, 
http://myServer/myContext/mySecuredNameSpace/, with the Struts 2 filter 
disabled Basic auth was triggered and WebSphere successfully returned the 
index.html file in the root of that directory.  When I re-enabled the Struts 2 
filters the welcome-file quit working again.

I would still like to understand why the welcome-file doesn't work on WebSphere 
6.1 with Struts 2, but it is not a show stopper.  We will simply provide the 
users a deep link directly to the desired, secured action.

Steve Mitchell
http://www.ByteworksInc.com

-Original Message-
From: Mitchell, Steven 
Sent: Wednesday, June 03, 2009 4:48 PM
To: 'Struts Users Mailing List'
Subject: RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml

Wes,

That was an interesting exercise.  I changed my welcome-file to be 
"index.action", added the zero-byte file "/webapp/index.action", and defined 
the following action:


/index.html


This worked the same on Tomcat 5.5 as it did when my welcome-file was just 
"index.html."  Unfortunately, on WebSphere I still got the message: "Error 404: 
There is no Action mapped for namespace / and action name index ." Of course, 
if I type http://myserver/mycontext/index.action in the browser that works 
fine.  Something is seriously hosed on WAS 6.1.

I've asked the WAS Admin to bump us up to 6.1.0.23 and I'll continue testing 
tomorrow.

Thank you for your suggestion.

Steve Mitchell
http://www.ByteworksInc.com

-Original Message-
From: Mitchell, Steven [mailto:steven.mitch...@umb.com] 
Sent: Wednesday, June 03, 2009 4:18 PM
To: Struts Users Mailing List
Subject: RE: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml

Wes,

Boy do I wish the client would just use Tomcat! I'll try going down the action 
route.  I'm actually using index.html now, which is a real file that I can 
access if I type the whole URL: http://myserver/mycontext/index.html.  If I 
understand what you are asking me to try, I will create a zero byte 
/webapp/index.action, change my Web.xml from:


index.html


to:


index.action


and add an action named "index".  Is that correct?  Actually, my index.html 
redirects to /mynamespace/myaction.action.  If I just used that I would need to 
create a directory named /mynamespace with a zero byte file called 
myaction.action.  Is that correct?

Steve Mitchell
http://www.ByteworksInc.com

-Original Message-
From: Wes Wannemacher [mailto:w...@wantii.com] 
Sent: Wednesday, June 03, 2009 4:00 PM
To: Struts Users Mailing List
Subject: Re: Adding Struts 2.1.6 on WAS 6.1 breaks welcome-file in web.xml

On Wed, Jun 3, 2009 at 4:54 PM, Mitchell, Steven
 wrote:
[...]
>
>     Error 404: SRVE0190E: File not found: /secure/MySecureAction.action
[...]

I don't know about all of the problems, but one thing that might help
you understand this a little bit... This 404 might not be WAS' fault.
In the Spec (can't remember if it was 2.3 / 2.4) it was specified that
a file had to exist on the file system for it to be usable as a
welcome-file. This is sort of a pain for Struts2. One quick hack that
worked in Tomcat is to just create a zero-byte file called
index.action. I can't guarantee that WAS will be happy with that, but
I have used that before.

-Wes


-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

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


--
NOTICE:  This electronic mail message and any attached files are confidential.  
The information is exclusively for the use of the individual or entity intended 
as the recipient.  If you are not the intended recipient, any use, copying, 
printing, reviewing, retention, disclosure, distribution or forwarding of the 
message or any attached file is not authorized and is strictly prohibited.  If 
you have received this electronic mail message in error, please advise the 
sender by reply electronic mail immediately and permanently delete the original 
transmission, any attachments and any copies of this message from your computer 
system. Thank you.

==

Doubts about new project (Struts2 good way to do it?)

2009-06-04 Thread Francisco Exposito

Hello,

I want to create a portal with this functionalities, and I don't know if it is 
possible to do it using Struts2 or what is better for it:

1) User preferences: every user can configure its "window" and maintain its 
configuration after save preferences and log in again. The user can select 
options from a list and position them where he wants. ¿Maybe using 
portlets?¿Changing css dinamically depending on logged user?¿Any other option?

2) Languages: every user can access in some languages. As I've tested, the 
language is configured with regional settings. But it is possible to select the 
language in the login page and maintain it during the session?

3) Persistence layer: better Hibernate or iBatis? About performance?

4) E-commerce: shop cart, what about security?

5) Sitemesh or Tiles? I've used tiles and it is ok, but the xml are too long. 
About performance?



The options I've considered are:

Tomcat, MySQL, Struts2 with Spring IOC and open in view filter, Sitemesh or 
Tiles, Hibernate or iBatis, Portlets. 

Other option is use JSF. Which selection do you think would be better?

Thanks in advance.

Francisco

_
Chatea sin límites en Messenger con la tarifa plana de Orange
http://serviciosmoviles.es.msn.com/messenger/orange.aspx

Formatting output, double without exponent

2009-06-04 Thread Stefano Tranquillini
Hi all.
i've a little problem.
I've a EJB inside my session, i take it from a jsp and print out some
values:


now, this value is a double. and struts print 2.0E09
how can i print 2.0. so the entire number without exponent?
thanks


-- 
Stefano


Return to previous page without javascript

2009-06-04 Thread Stefano Tranquillini
Hi all.
i want to do a thing. When a user do the login (i've the login in the left
part of the web site, so in each pages the user can do the login) i want to
redirect he at the pages that was visit before the login.
how can i do that? (no JS)


-- 
Stefano


Re: Params not getting set

2009-06-04 Thread Wes Wannemacher
I'm assuming you are using the conventions plugin (since there is no
action definition). How are you making sure your
conventions-configured actions are in the "stuff" package? If this is
your configuration, in whole, then you need to add -



Just matching up namespace is not enough.

Another option is to use the @ParentPackage annotation on the action class -
http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-ParentPackageannotation

-Wes

On Thu, Jun 4, 2009 at 11:24 AM, Jim Collings  wrote:
> So I have a Preparable action and in the Preparable method, I need
> access to a parameter. Others have gone over my struts.xml and seem to
> think that it is correct:
>
> 
>    
>    
>    
>     value="com.stuff.something.web"/>
>    
>    
> 
>
> I have a getter and a setter for the property but it is not being set.
> It is being called from a link like so:
>
> http://localhost:3/someproject-web/admin/person-change?ldapUidSelected=SOMEUSER
>
> So... any ideas why the ldapUidSelected  property is not being set  in
> the PersonChangeAction class prior to calling Prepare() ?
>
>
> Jim C.
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>



-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

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



Params not getting set

2009-06-04 Thread Jim Collings
So I have a Preparable action and in the Preparable method, I need
access to a parameter. Others have gone over my struts.xml and seem to
think that it is correct:










I have a getter and a setter for the property but it is not being set.
It is being called from a link like so:

http://localhost:3/someproject-web/admin/person-change?ldapUidSelected=SOMEUSER

So... any ideas why the ldapUidSelected  property is not being set  in
the PersonChangeAction class prior to calling Prepare() ?


Jim C.

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



Huge File upload in struts 2

2009-06-04 Thread Johnson nickel



Hi Evans,
 
 I'm facing problem to upload huge file like (size is
7mb,10mb). In your last thread
you have specified it will work in only small datas or files. I want to know
any other method
to solve in struts2 framework.


Disclaimer: This approach is limited to small files (multiple megabytes
> rather than hundreds/gigs) because of the inefficient memory
> consumption.  It's also quite slow as the commons fileuploader first
> receives all the data, then writes the entire temporary file, then it's
> read again entirely  into memory, then written back to your
> database/filesystem.  There's no other built-in approach in Struts2 but
> you'll find ajax fileuploaders on the web that handle massive files
> better than this.
  
Jeromy Evans - Blue Sky Minds wrote:
>
>
>
> Johnson nickel wrote:
>> Hi Jeromy Evans,
>>
>>   Thanks for your reply. I would like to insert the images
>> into
>> my
>>   Databases. For that, i'm using byte[] array.
>>   In Struts 1.3,
>>  I used FormFile class. From this class i got the method
>> getFileData();
>>
>> In my db, ps.setBytes(1,filedata); // to store the binary
>> datas in DB.
>>
>> /*FormFile mtfile = form.getTheFile();
>>  byte[] filedata = mtfile.getFileData();*/
>>  
>>  
>>  
> Ahh, ok.
>
> In Struts2, the file is a reference to a temporary file created on your
> server.  If it's not HUGE, just read it into a byte array.
> The code follows.  This code is a fairly standard approach to read an
> arbitrary length inputstream into a byte array one chunk at a time.
> If the file can be HUGE, see my comment at bottom.
>
> byte[] filedata = readInputStream(new FileInputStream(upload));
>
> /** Read an input stream in its entirety into a byte array */
> public static byte[] readInputStream(InputStream inputStream) throws
> IOException {
> int bufSize = 1024 * 1024;
> byte[] content;
>
> List parts = new LinkedList();
> InputStream in = new BufferedInputStream(inputStream);
>
> byte[] readBuffer = new byte[bufSize];
> byte[] part = null;
> int bytesRead = 0;
>
> // read everyting into a list of byte arrays
> while ((bytesRead = in.read(readBuffer, 0, bufSize)) != -1) {
> part = new byte[bytesRead];
> System.arraycopy(readBuffer, 0, part, 0, bytesRead);
> parts.add(part);
> }
>
> // calculate the total size
> int totalSize = 0;
> for (byte[] partBuffer : parts) {
> totalSize += partBuffer.length;
> }
>
> // allocate the array
> content = new byte[totalSize];
> int offset = 0;
> for (byte[] partBuffer : parts) {
> System.arraycopy(partBuffer, 0, content, offset,
> partBuffer.length);
> offset += partBuffer.length;
> }
>
> return content;
> }
>
> Disclaimer: This approach is limited to small files (multiple megabytes
> rather than hundreds/gigs) because of the inefficient memory
> consumption.  It's also quite slow as the commons fileuploader first
> receives all the data, then writes the entire temporary file, then it's
> read again entirely  into memory, then written back to your
> database/filesystem.  There's no other built-in approach in Struts2 but
> you'll find ajax fileuploaders on the web that handle massive files
> better than this.
>
> regards,
>  Jeromy Evans
>
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
>
Quoted from:
http://www.nabble.com/Struts-2-File-upload-to-store-the-filedata-tp14168069p14169822.html


-- 
View this message in context: 
http://www.nabble.com/Huge-File-upload-in-struts-2-tp23870472p23870472.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



RE: Ajax file upload + RE: About the "struts.multipart.saveDir" for file upload

2009-06-04 Thread Qunhuan Mei
Ok Wes, I'll wait for your code to be ready. You guys hard work make us
developers' work easier. Many thanks for that! Qunhuan

-Original Message-
From: Wes Wannemacher [mailto:w...@wantii.com] 
Sent: 04 June 2009 13:38
To: Struts Users Mailing List
Subject: Re: Ajax file upload + RE: About the "struts.multipart.saveDir" for
file upload


Really, I haven't gotten that far yet, I am only working to improve
the integration with Jakarta FileUpload. JFU is quite capable and
mature, but I figured the first step would be to expose more
functionality since there were a few JIRAs related to people asking
for more than what is currently offered.

I committed a partially complete plugin to the sandbox yesterday
before I left my office, but I still need to glue it together with
configuration, etc. (and work out a bug I realized I had in the middle
of the night last night). Once I get the plugin to an installable
state, you can check it out. I figure the first step is to make the
plugin work, then the next step is building an example UI. I am not
sure how I am going to build the example UI, but JQuery is probably
the most likely candidate for me.

As far as selecting multiple files with Ctrl-Click, I'm not sure if
that is possible... Not from a struts/jquery perspective, but I don't
know if the browser will let you do that. I think Flash may be the
only option (or a java applet or something, but flash is more likely),
so we can come back to that later.

-Wes

On Thu, Jun 4, 2009 at 4:07 AM, Qunhuan Mei  wrote:
> Hi Wes,
>
> Struts’ ajax file upload would be very interesting to me since I have
> implemented jQuery (http://www.phpletter.com/Our-Projects/AjaxFileUpload/)
> and Struts for ajax file upload in my application and had one or two
> problem(s).
>
> FYI: My use case is to upload a file, together with utf8 encoded caption.
> The problem I had is utf8 encoded caption needs to be sent via HTTP POST,
it
> won’t work with HTTP get. But the jQuery arrangement is sending file in
POST
> while sending caption in Get. So what I did is to send caption and file in
> two POSTs which cause other complications. Later the author (Øyvind
Saltvik
> oyvind.salt...@gmail.com) sent me the following code contributed by
> (Prokofiev Nikolay nprokof...@gmail.com) which added the parameter POSTing
> (e.g. caption) to jQuery’s file upload.
>
> $.ajaxFileUpload
>        (
>            {
>                url:document.location+'&ajax=true',
>                secureuri:false,
>                fileElementId:'fileToUpload',
>                data: {foo: 'ghffgh', bar: 'fghfhgg'},
>                dataType: 'json',
>                success: function (data, status)
>                {
>                    if(typeof(data.error) != 'undefined')
>                    {
>                        if(data.error != '')
>                        {
>                            alert(data.error);
>                        }else
>                        {
>                            alert(data.msg);
>                        }
>                    }
>                },
>                error: function (data, status, e)
>                {
>                    alert(e);
>                }
>            }
>        )
>
> here is the script:
> jQuery.extend({
>    createUploadIframe: function(id, uri)
>    {
>            //create frame
>            var frameId = 'jUploadFrame' + id;
>
>            if(window.ActiveXObject) {
>                var io = document.createElement('');
>                if(typeof uri== 'boolean'){
>                    io.src = 'javascript:false';
>                }
>                else if(typeof uri== 'string'){
>                    io.src = uri;
>                }
>            }
>            else {
>                var io = document.createElement('iframe');
>                io.id = frameId;
>                io.name = frameId;
>            }
>            io.style.position = 'absolute';
>            io.style.top = '-1000px';
>            io.style.left = '-1000px';
>
>            document.body.appendChild(io);
>
>            return io
>    },
>    createUploadForm: function(id, fileElementId, postData)
>    {
>        //create form
>        var formId = 'jUploadForm' + id;
>        var fileId = 'jUploadFile' + id;
>        var form = $(' id="' + formId + '" enctype="multipart/form-data">');
>        var oldElement = $('#' + fileElementId);
>        var newElement = $(oldElement).clone();
>        $(oldElement).attr('id', fileId);
>        $(oldElement).before(newElement);
>        $(oldElement).appendTo(form);
>        try
>        {
>            for(param in postData)
>            {
>                  var   input = document.createElement('input');
>                      input.setAttribute('name', param);
>                      input.setAttribute('value', postData[param]);
>                      $(input).appendTo(form);
>            }
>        }
>        catch(e) {}
>        //set attributes
>        $(form).css('position', 'absolute');
>

Formatting output, double without exponent

2009-06-04 Thread Stefano
Hi all.
i've a little problem.
I've a EJB inside my session, i take it from a jsp and print out some
values:


now, this value is a double. and struts print 2.0E09
how can i print 2.0. so the entire number without exponent?
thanks

-- 
Stefano


Re: Struts 2.1.6 with ajax and progressing image

2009-06-04 Thread rajeevP

Tahnks  Dave
I am using the sx: div fucntionalities. in this how can we disable/enable
the submit button.?
Giving my JSP with this, if you can say how and where to do these things, it
will be very helpful.



<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<% String relPath = request.getContextPath(); %>




Add Demand



html,body {
height: 100%;
}



function show_details() {
//alert('in show details11');
dojo.event.topic.publish("show_detail");
}




 
















   
   





















 









-- 
View this message in context: 
http://www.nabble.com/Struts-2.1.6-with-ajax--and-progressing-image-tp23868465p23869662.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Introducing Spring in Struts2 Project

2009-06-04 Thread Wes Wannemacher
On Thu, Jun 4, 2009 at 7:52 AM, alee amin
 wrote:
[...]
>
> 
> *One question that i asked earlier, going to ask again here. *
>
> integrating spring in struts through spring plugin, does not mean that you
> have struts as your base framework and then adding spring as one part of it?
> in my knowledge, spring is the base framework and other are added on top of
> it.
>
[...]

I don't really think of it as a one-framework-or-the-other kind of
setup. IMO, you really just have to know both. I use Struts for
building the UI and integrating with the business logic. The business
logic might include writing data to a database, calling remote web
services, etc. Struts doesn't really care about things like database
integration. Struts is built to deal with POJOs and assumes that your
business logic will be easily introspected (which is good design).
Spring fits in quite nicely to glue together the business logic and
turn it into easy to maintain POJOs. Things like JDBC or JPA
integration become quite a bit easier with Spring. So, I see my
applications like this -

User Interface --> Business Logic > Backend Systems
Struts --> Spring > Database/Web Service/whatever

Struts makes building the UI easy (if the business logic code is based
on simple beans). Spring makes it easy to build business logic code
that is based on beans. So, I don't know if that really answers your
question, but I will say that I prefer to know both pretty well. I
have looked at Spring MVC and it seems like the one attraction is how
well it is integrated with Spring Core. I prefer the tag library and
flexibility of Struts over it and with the Spring Plugin, the
integration between Struts & Spring is quite good.

-Wes



-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

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



Re: Ajax file upload + RE: About the "struts.multipart.saveDir" for file upload

2009-06-04 Thread Wes Wannemacher
Really, I haven't gotten that far yet, I am only working to improve
the integration with Jakarta FileUpload. JFU is quite capable and
mature, but I figured the first step would be to expose more
functionality since there were a few JIRAs related to people asking
for more than what is currently offered.

I committed a partially complete plugin to the sandbox yesterday
before I left my office, but I still need to glue it together with
configuration, etc. (and work out a bug I realized I had in the middle
of the night last night). Once I get the plugin to an installable
state, you can check it out. I figure the first step is to make the
plugin work, then the next step is building an example UI. I am not
sure how I am going to build the example UI, but JQuery is probably
the most likely candidate for me.

As far as selecting multiple files with Ctrl-Click, I'm not sure if
that is possible... Not from a struts/jquery perspective, but I don't
know if the browser will let you do that. I think Flash may be the
only option (or a java applet or something, but flash is more likely),
so we can come back to that later.

-Wes

On Thu, Jun 4, 2009 at 4:07 AM, Qunhuan Mei  wrote:
> Hi Wes,
>
> Struts’ ajax file upload would be very interesting to me since I have
> implemented jQuery (http://www.phpletter.com/Our-Projects/AjaxFileUpload/)
> and Struts for ajax file upload in my application and had one or two
> problem(s).
>
> FYI: My use case is to upload a file, together with utf8 encoded caption.
> The problem I had is utf8 encoded caption needs to be sent via HTTP POST, it
> won’t work with HTTP get. But the jQuery arrangement is sending file in POST
> while sending caption in Get. So what I did is to send caption and file in
> two POSTs which cause other complications. Later the author (Øyvind Saltvik
> oyvind.salt...@gmail.com) sent me the following code contributed by
> (Prokofiev Nikolay nprokof...@gmail.com) which added the parameter POSTing
> (e.g. caption) to jQuery’s file upload.
>
> $.ajaxFileUpload
>        (
>            {
>                url:document.location+'&ajax=true',
>                secureuri:false,
>                fileElementId:'fileToUpload',
>                data: {foo: 'ghffgh', bar: 'fghfhgg'},
>                dataType: 'json',
>                success: function (data, status)
>                {
>                    if(typeof(data.error) != 'undefined')
>                    {
>                        if(data.error != '')
>                        {
>                            alert(data.error);
>                        }else
>                        {
>                            alert(data.msg);
>                        }
>                    }
>                },
>                error: function (data, status, e)
>                {
>                    alert(e);
>                }
>            }
>        )
>
> here is the script:
> jQuery.extend({
>    createUploadIframe: function(id, uri)
>    {
>            //create frame
>            var frameId = 'jUploadFrame' + id;
>
>            if(window.ActiveXObject) {
>                var io = document.createElement('');
>                if(typeof uri== 'boolean'){
>                    io.src = 'javascript:false';
>                }
>                else if(typeof uri== 'string'){
>                    io.src = uri;
>                }
>            }
>            else {
>                var io = document.createElement('iframe');
>                io.id = frameId;
>                io.name = frameId;
>            }
>            io.style.position = 'absolute';
>            io.style.top = '-1000px';
>            io.style.left = '-1000px';
>
>            document.body.appendChild(io);
>
>            return io
>    },
>    createUploadForm: function(id, fileElementId, postData)
>    {
>        //create form
>        var formId = 'jUploadForm' + id;
>        var fileId = 'jUploadFile' + id;
>        var form = $(' id="' + formId + '" enctype="multipart/form-data">');
>        var oldElement = $('#' + fileElementId);
>        var newElement = $(oldElement).clone();
>        $(oldElement).attr('id', fileId);
>        $(oldElement).before(newElement);
>        $(oldElement).appendTo(form);
>        try
>        {
>            for(param in postData)
>            {
>                  var   input = document.createElement('input');
>                      input.setAttribute('name', param);
>                      input.setAttribute('value', postData[param]);
>                      $(input).appendTo(form);
>            }
>        }
>        catch(e) {}
>        //set attributes
>        $(form).css('position', 'absolute');
>        $(form).css('top', '-1200px');
>        $(form).css('left', '-1200px');
>        $(form).appendTo('body');
>        return form;
>    },
>    ajaxFileUpload: function(s) {
>        // TODO introduce global settings, allowing the client to modify
> them for all requests, not only timeout
>        s = jQuery.extend({}, jQuery.ajaxSettings, s

Re: Struts 2.1.6 with ajax and progressing image

2009-06-04 Thread Dave Newton

rajeevP wrote:

We are using struts2.1.6 and ajax in our application. In one of our screen
we have only 4 fields, in that one fields has ajax calling. so how can we
stop the user to submit that form upto the ajax response came.
Means upto that ajax repsonse reached in the screen, we need to restrict the
user to click on the submit button.


Disable/hide the submit button, and enable/show the submit button as 
part of the Ajax callback?


Dave

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



Struts 2.1.6 with ajax and progressing image

2009-06-04 Thread rajeevP

Hi Everybody,

We are using struts2.1.6 and ajax in our application. In one of our screen
we have only 4 fields, in that one fields has ajax calling. so how can we
stop the user to submit that form upto the ajax response came.
Means upto that ajax repsonse reached in the screen, we need to restrict the
user to click on the submit button.

Thanks in advance..

Rajeev
-- 
View this message in context: 
http://www.nabble.com/Struts-2.1.6-with-ajax--and-progressing-image-tp23868465p23868465.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Introducing Spring in Struts2 Project

2009-06-04 Thread alee amin
thanks a lot martin. That's an excellent help. i can not imagine something
more eloquent for this specific problem that i had. Thanks.

Just for quick review, if i am not using convention plugin at the moment. I
would be converting my action class from struts.xml as

 class="mop.page.authenticated.EditTableProductsReadOnlyAction"
> method="execute">
> /jsp/EditTableGenericAjax.jsp
> 
>

to my spring - applicationContext.xml

> 
> class="mop.page.authenticated.EditTableProductsReadOnlyAction"/>
> 
>

and then adding this thing to struts.xml as

>  method="execute">
> /jsp/EditTableGenericAjax.jsp
> 
>

and this would definitely be done after setting the autowire property and
factory settings for spring.


*One question that i asked earlier, going to ask again here. *

integrating spring in struts through spring plugin, does not mean that you
have struts as your base framework and then adding spring as one part of it?
in my knowledge, spring is the base framework and other are added on top of
it.

..alee
http://techboard.wordpress.com



On Wed, Jun 3, 2009 at 6:46 PM, Martin Gainty  wrote:

>
> a few considerations:
> using convention plugin to create/determine action name
> http://struts.apache.org/2.x/docs/convention-plugin.html
>
> 1)
> Action name overrides using annotations as in the example
>  @Action("FOO-BAR") "FOO-BAR" is action name
> 2)
> struts.convention.action.name.lowercase=false "foo-bar" is action name
>
> action locational characteristics:
>  By default, the Convention plugin will find all action classes
> -that implement com.opensymphony.xwork2.Action or
> -whose name ends with the word Action in specific packages.
> so these Action classes will be 'found'
> com.example.actions.MainAction
> com.example.actions.products.Display (implements
> com.opensymphony.xwork2.Action)
> com.example.struts.company.details.ShowCompanyDetailsActionso we now know
> how the action name is created  and found
>
> SPRING:
> http://struts.apache.org/2.x/docs/spring-plugin.html
>
> first we need to define StrutsSpringObjectFactory via Struts.properties
> struts.objectFactory = org.apache.struts2.spring.StrutsSpringObjectFactory
>
>
>
> struts.xml
> 
>   value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 
>
> //you configured your action-name as defined above with annotation and /or
> lowercase
> struts.objectFactory.spring.autoWire = name
> //you can use Spring to auto-create actions or beans
>
> if you are using context in your xml for params you will need the
> ContextLoaderListener defined in web.xml e.g.
>
> 
>
>  
> org.springframework.web.context.ContextLoaderListener
> 
> //application-context.xml contains the name and the class for the 'wired'
> bean
> as defined here
>  BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd";>
> 
>
> 
> //be aware that name assignment will be 'personManager'
>
>
> //USING context other then applicationContext you can specify so here
> 
>contextConfigLocation
>
>  
> /WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml
> 
>
> 
> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>"http://struts.apache.org/dtds/struts-2.0.dtd";>
> 
>
>
>
>bar.ftl
>
>
> 
> 
>
> 
>  http://www.springframework.org/dtd/spring-beans.dtd";>
> 
>
> 
> additional considerations
> struts.objectFactory.spring.autoWire.alwaysRespect=true
> (currently alwaysRespect false has a bug assigned)
>
> //choosing autowire type is a safe choice as Action name might be changed
> modified by convention-plugin mods
> struts.objectFactory.spring.autoWire=type
>
> I hope this makes the topic clearer to you
> Martin Gainty
> __
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
>
>
>
>
> > Date: Wed, 3 Jun 2009 04:31:15 -0700
> > From: bphill...@ku.edu
> > To: user@struts.apache.org
> > Subject

File Upload in IE

2009-06-04 Thread Mageshwaran

Hi All,

	In my jsp code i had used "size="20" onkeypress = "killEvent(event)"/>" for file upload using IFrame.


Issue: While loading in IE browser, if i paste a file name in the 
text field with wrong file path, it allows and script error occurs on form submit.


Is there any option to restrict copy paste event ?

Thanks,
Mageshwaran P.



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



Ajax file upload + RE: About the "struts.multipart.saveDir" for file upload

2009-06-04 Thread Qunhuan Mei
Hi Wes, 

Struts’ ajax file upload would be very interesting to me since I have
implemented jQuery (http://www.phpletter.com/Our-Projects/AjaxFileUpload/)
and Struts for ajax file upload in my application and had one or two
problem(s).

FYI: My use case is to upload a file, together with utf8 encoded caption.
The problem I had is utf8 encoded caption needs to be sent via HTTP POST, it
won’t work with HTTP get. But the jQuery arrangement is sending file in POST
while sending caption in Get. So what I did is to send caption and file in
two POSTs which cause other complications. Later the author (Øyvind Saltvik
oyvind.salt...@gmail.com) sent me the following code contributed by
(Prokofiev Nikolay nprokof...@gmail.com) which added the parameter POSTing
(e.g. caption) to jQuery’s file upload. 

$.ajaxFileUpload
(
{
url:document.location+'&ajax=true', 
secureuri:false,
fileElementId:'fileToUpload',
data: {foo: 'ghffgh', bar: 'fghfhgg'},
dataType: 'json',
success: function (data, status)
{
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
alert(data.error);
}else
{
alert(data.msg);
}
} 
},
error: function (data, status, e)
{ 
alert(e);
}
}
)

here is the script:
jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;

if(window.ActiveXObject) {
var io = document.createElement('');
if(typeof uri== 'boolean'){
io.src = 'javascript:false';
}
else if(typeof uri== 'string'){
io.src = uri;
}
}
else {
var io = document.createElement('iframe');
io.id = frameId;
io.name = frameId;
}
io.style.position = 'absolute';
io.style.top = '-1000px';
io.style.left = '-1000px';

document.body.appendChild(io);

return io
},
createUploadForm: function(id, fileElementId, postData)
{
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = $('');
var oldElement = $('#' + fileElementId);
var newElement = $(oldElement).clone();
$(oldElement).attr('id', fileId);
$(oldElement).before(newElement);
$(oldElement).appendTo(form);
try
{
for(param in postData)
{
  var   input = document.createElement('input');
  input.setAttribute('name', param);
  input.setAttribute('value', postData[param]);
  $(input).appendTo(form);
}
}
catch(e) {}
//set attributes
$(form).css('position', 'absolute');
$(form).css('top', '-1200px');
$(form).css('left', '-1200px');
$(form).appendTo('body');
return form;
},
ajaxFileUpload: function(s) {
// TODO introduce global settings, allowing the client to modify
them for all requests, not only timeout
s = jQuery.extend({}, jQuery.ajaxSettings, s);
var id = new Date().getTime()
var form = jQuery.createUploadForm(id, s.fileElementId, s.data);
var io = jQuery.createUploadIframe(id, s.secureuri);
var frameId = 'jUploadFrame' + id;
var formId = 'jUploadForm' + id;
// Watch for a new set of requests
if ( s.global && ! jQuery.active++ )
{
jQuery.event.trigger( "ajaxStart" );
}
var requestDone = false;
// Create the request object
var xml = {}   
if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]);
// Wait for a response to come back
var uploadCallback = function(isTimeout)
{
var io = document.getElementById(frameId);
try 
{
if(io.contentWindow)
{
 xml.responseText =
io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null
;
 xml.responseXML =
io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:
io.contentWindow.document;
 
}else if(io.contentDocument)
{
 xml.responseText =
io.cont

RE: About the "struts.multipart.saveDir" for file upload

2009-06-04 Thread Qunhuan Mei
Thanks a lot for all those replied by query.

The reason why I want to set saveDir in my Java code is that as a developer,
I would like to take everything under my own control but I suppose if the
default upload saveDir, without externally setting it in struts.xml, works
in all occasions, e.g. Windows, Linux, … (I am not an expert here) then the
existing arrangement of the saveDir arrangement is satisfactory.

Cheers,

Qunhuan

-Original Message-
From: Dave Newton [mailto:newton.d...@yahoo.com] 
Sent: 04 June 2009 01:12
To: Struts Users Mailing List
Subject: Re: About the "struts.multipart.saveDir" for file upload


Qunhuan Mei wrote:
> When implementing file upload, it is required to specify an absolute
> directory in struts.xml such as following:
> 
> 
> 
> But this might be difficult to achieve, say when the project war is
deployed
> in a external shared server and we do not have much idea about the
directory
> structure of the target server machine.

The current, canonical way to handle file uploads is to copy them from 
the default upload directory to wherever you want them.

It's not required to set the saveDir; it defaults to the default 
temporary directory. The file upload interceptor currently deletes the 
uploaded file after the action executes, which is why the copy is needed.

Sounds like this will all be changing pretty quick-like, though.

Dave

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






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