Re: Struts2 Fileupload user defined messages

2008-07-20 Thread Joachim Rohde

Hi Dirk,

I had the same problem and after spending the whole day trying things 
out, I found something that works.


In WEB-INF/classes I created a class struts-messages.properties with 
following content:


struts.messages.error.uploading=Fehler beim hochladen der Datei
struts.messages.error.file.too.large=Die Datei ist zu groß!
struts.messages.error.content.type.not.allowed = Der Dateityp wird 
leider nicht unterstützt.



In my strus.properties I added:

struts.multipart.parser=org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest 


struts.multipart.maxSize=1
struts.custom.i18n.resources=struts-messages

My action-definition looks like:

action name=SaveSettings class=saveSettings
interceptor-ref name=fileUpload
param name=allowedTypes
image/x-png,image/png,image/gif,image/jpeg,image/pjpeg
/param
param name=maximumSize12
/param
/interceptor-ref
[...]
 /action

It seems like that the value in struts.multipart.maxSize is passed to 
commons-fileupload. If the uploaded file exceeds this value, the message 
you mentioned is displayed. BUT: if we set this value quite high (so 
that commons-fileupload is not complaining about it), the Struts 
FileUploadInterceptor checks again for the parameter maximumSize, which 
is passed in the action-definition. (In my case I don't want to have 
files bigger than 12 bytes.) If the file-size exceeds this value, 
the message declared in struts.messages.error.file.too.large is loaded.


This behaviour is really annoying and it took an eternity to find it 
out. So let me know if this is working for you.


Greetings from Flensburg,

Joachim

Dirk Schumacher schrieb:

Hello,

I am troubleling with the Fileupload in S2.

I want to have printed my own messages on failure of the file upload 
which takes place in the interceptor.

I am uploading files exceeding the set maximum size
The documentation talks about the struts-message-properties, where is 
declared:


struts.messages.error.uploading=Error uploading: {0}
struts.messages.error.file.too.large=File too large: {0} {1} {2}
struts.messages.error.content.type.not.allowed=Content-Type not allowed: 
{0} {1} {2}


The message printed via the ActionError is complete different text I 
cannot find in any file:


the request was rejected because its size (2352563) exceeds the 
configured maximum (2097152)


Where is this Text declared?

A colleague talked about the commons-fileupload which is declaring the 
printed text
The Jakarta File... seems to me the right instance of takiong care of 
the ActionError


When looking at the sources I figured that not the FileUploadInterceptor 
instantiates the ActionError. It is done by the

parse()-Method of the MultipartRequestWrapper, or somewhere deeper.

So figure that the struts-message.properties is never applied and the 
ActionError is setup in-code instead of the usage of an external 
property file.


Is there any documentation out there on this issue? - I just want to set 
my own (localed) messages for the different errors that may occure, just 
like intended by the S2 FileUploadInterceptor, which seems somewhat not 
fully useful to me right now.


I appreciate your help in advance,

best greetings from cologne,
Dirk





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





No virus found in this incoming message.
Checked by AVG. 
Version: 8.0.100 / Virus Database: 270.4.0/1506 - Release Date: 17.06.2008 16:30


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



Re: fileUpload vs custom servlet

2008-07-11 Thread Joachim Rohde
If you don't need the file-upload interceptor then remove it from your 
interceptor stack or exclude it for those actions which rely on your 
custom fileupload-servlet.


webdev2 schrieb:

I upgraded my app to Struts2, which provides file uploading.   Now my custom
servlet for uploading an attachment no longer receives the request.   Is
there a configurable option for restoring the old functionality of having
the custom servlet upload the attachment?   Thanks.

FYI - 1) Initially an exception was thrown as a result of
FilterDispatcher.doFilter handing off multipart handling.   This was due to
a jar mismatch.  So, I got the correct versions of the commons-io.jar and
commons-fileupload.jar, and the exception is gone.  But my servlet never
receives the request. 2) I have a custom interceptor stack containing
defaultStack.   That means the fileUpload interceptor is available.


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



Re: textarea Encoding

2008-07-11 Thread Joachim Rohde

Hi,

are the values still correct within your controller? And which Server 
are you using?


I once had a similar problem, but I am not sure, if my solution can be 
applied to your problem. In my case I tried to deliver strings with 
umlauts as a GET-request-parameter to my controller, which failed. As 
server I used Tomcat. I had to set the URIEncoding of Tomcat to UTF-8 
what solved my problem. A comprehensive description of the problem (and 
solution) can be found here: 
http://tompson.wordpress.com/2007/01/29/encoding-filter-for-java-web-applications/


Hope that helps


Juan Pablo Pizarro schrieb:

Hi All, I've a problem with textarea encoding. I use struts 2.0.11. I
put things like áí or ü into a text area, then I pass that value to
others pages (through session) and the the characters appear as ?.

I looked forums and all problems had a Db involved, not mine.

Any idea?

Thanks.

Juan Pablo.

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



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



Re: Can't stop console warnings

2008-06-15 Thread Joachim Rohde

Hi,

add in your web.xml following snippet:

context-param
param-namelog4jConfigLocation/param-name
param-value/WEB-INF/classes/log4j.properties/param-value
/context-param  

And in the log4j.properties you add following line:

log4j.category.com.opensymphony.xwork2.util.logging.jdk.JdkLogger=ERROR

That should log only error-messages coming from this class.

Joachim

jefetech schrieb:

I just converted from struts 1 to 2.1.  I've got everything working, but I
can't seem to stop this warning from being spit out in the console every
time struts runs.  Any help would be great.  thank you.

Jun 15, 2008 11:43:01 AM com.opensymphony.xwork2.util.logging.jdk.JdkLogger
warn
WARNING: Could not find property [struts.valueStack]
Jun 15, 2008 11:43:01 AM com.opensymphony.xwork2.util.logging.jdk.JdkLogger
warn
WARNING: Could not find property [org.apache.catalina.jsp_file]



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



Re: dojo with struts 2.0.11.1.

2008-06-12 Thread Joachim Rohde
As Dave mentioned, the sx:... tags are Struts 2.1. So download the 
2.1.2 distribution ( http://struts.apache.org/download.cgi#struts212 ) 
and you'll find the dojo-plugin in the lib-directory.


Joachim

Lalchandra Rampersaud schrieb:

Thanks for the quick reply.

I assume that the plugin is in a jar file.
Where can i get the plugin?  


Lalchandra

Carpe diem


- Original Message - 
From: Dave Newton [EMAIL PROTECTED]

To: Struts Users Mailing List user@struts.apache.org
Sent: Thursday, June 12, 2008 7:24 AM
Subject: Re: dojo with struts 2.0.11.1.



--- On Thu, 6/12/08, Lalchandra Rampersaud [EMAIL PROTECTED] wrote:


From: Lalchandra Rampersaud [EMAIL PROTECTED]
Subject: dojo with struts 2.0.11.1.
To: Struts Users Mailing List user@struts.apache.org
Date: Thursday, June 12, 2008, 12:48 PM
hey all
whenever i put %@ taglib prefix=sx
uri=/struts-dojo-tags%  on my jsp pages
eclipse gives me an error.  i am using struts-2.0.11.1.

the docs has include the Dojo Plugin distributed with
Struts 2 in your /WEB-INF/lib folder but i can't seem
to find it anywhere..

what could be the problem?

The sx:... tags are Struts 2.1, and the Dojo functionality is moved into a 
plugin.

Dave


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







No virus found in this incoming message.
Checked by AVG. 
Version: 8.0.100 / Virus Database: 270.3.0/1499 - Release Date: 12.06.2008 07:13


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



Re: struts 2.1.2 - strange bug

2008-05-09 Thread Joachim Rohde

Hi,

you are using spring, aren't you? If so, you have to set the scope of 
your bean in the applicationContext.xml to prototype (or setting the 
attribute singleton to false, depending on the version of spring you 
are using).


Joachim

Alec C4 schrieb:

Hi, all.
I have a config with

action name=Registration
result/pages/register.jsp/result
/action
action name=Register class=UserAction
result/pages/result.jsp/result
result name=input/pages/register.jsp/result
/action

action with

public String execute() {
userManager.registerUser(getEmail(), getPassword());
return SUCCESS;
}

public void validate() {
if (getEmail().length() == 0) {
addFieldError(email, 
getText(user.registration.errors.no.email));
}
if (getPassword().length() == 0) {
addFieldError(password,

getText(user.registration.errors.no.password));
}
if (getPasswordConfirmation().length() == 0) {
addFieldError(
passwordConfirmation,

getText(user.registration.errors.no.password.confirmation));
}
}

and jsp register.jsp with

s:form action=Register
s:textfield name=email label=email/
s:password name=password label=password/
s:password name=passwordConfirmation label=password 
confirmation/
s:submit /

/s:form


but, when i'm trying to submit zero-form i'm of course see FieldError
messages, but when i'm pressing submit button again - i see double amount of
same messages, again - triple amount ... and i cannot understand - why i see
too much same messages?


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